Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VB.net how to loop a bunch of bitmaps hitting the bottom of the form

pocketpocket Greater LondonPosts: 2Member

Hi there,

I would like to loop some bitmaps I have moving down the form.

Private Sub Timermain_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timermain.Tick moveasteroid() checkgameover() moverocketship() firemissile() checkhit()

**Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load**
    loadsettings()
End Sub

Private Sub loadsettings()
    asteroiddown = True
    asteroidspeed = 2
    asteroiddrop = 40
    checkgameover()
    rocketspeed = 21
    missilespeed = 22
    missile.Visible = False
    firemissile()
    checkhit()
End Sub

**Private Sub moveasteroid()**
        'Asteroid 1
        If asteroiddown = True Then
            PictureBox1.Top += asteroidspeed
        Else
            PictureBox1.Left -= asteroidspeed
        End If
        If PictureBox1.Left + PictureBox1.Width > Me.ClientRectangle.Bottom Then
            asteroiddown = False
            PictureBox1.Top += asteroiddrop
        End If

Private Sub checkgameover() If PictureBox1.Top + PictureBox1.Width >= Me.ClientRectangle.Bottom And PictureBox1.Visible = True Then Timermain.Enabled = False MsgBox("Game Over- Region of space not protected!") End If

I don't think button code is necessary or for missile fire code to be posted. I only want to loop the program when either of the following occur in 'moveasteroid' and 'checkgameover' subs.

I tried the basic loops such Do until loop, they don't work for this.

Thank you.

Sign In or Register to comment.