My friend is making a duck hunt game. He went through the process of making the for statements to move the duck(s) around. He wants to know how to have it done randomely, with a different pattern of movement each time. :)
Printable View
My friend is making a duck hunt game. He went through the process of making the for statements to move the duck(s) around. He wants to know how to have it done randomely, with a different pattern of movement each time. :)
What is your question?
We really can't help with that until we see some of the code he already has.
Phreak
Option Explicit
Dim x As Integer, y As Integer, c As Integer
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Sub command1_click()
Do
Command1.Visible = False
imgbird.Visible = True
x = 1000
For y = 125 To 8000 Step 10
imgbird.Top = y - 50
imgbird.Left = x
x = x + 16
Sleep 1
DoEvents
Next y
c = c + 1
For y = 8000 To 125 Step -10
imgbird.Top = y + 50
imgbird.Left = x
Sleep 1
DoEvents
Next y
For y = 125 To 8000 Step 10
imgbird.Top = y + 50
imgbird.Left = x
x = x - 19
Sleep 2
DoEvents
Next y
Loop While c < 4
End Sub
Private Sub birdisdead()
imgdead.Visible = True
imgbird.Visible = False
Dim deadbird As Integer
For deadbird = y To 11100 Step 20
imgdead.Top = deadbird
imgdead.Left = x
Sleep 4
DoEvents
Next deadbird
End Sub
Private Sub Form_Load()
Form1.BackColor = vbBlack
'c = 0
End Sub
Private Sub imgbird_Click()
birdisdead
imgbird.Visible = False
End Sub
Next time use vbcode tags.
Any you still haven't told us what the problem is.
He wants the bird to move in a random direction every time
Use Rnd and Randomize.
http://msdn.microsoft.com/library/de...l/vafctRnd.asp
you could place the duck image in a frame, and put this code in a timer.
VB Code:
Randomize imgDuck.Left = Int((Frame1.Width - imgDuck.Width + 1) * Rnd) imgDuck.Top = Int((Frame1.Height - imgDuck.Height + 1) * Rnd)
My friend is making a duck hunt game. For one level, he wants multiple birds to fly out on the screen in random directions (as well as random birds). Any help would be appreciated.
Thanks guys
Read your other post, this is a dual post!!