AHH DUCK HUNT

TommyHM111
07-25-2001, 07:51 PM
ive been making a duck hunt game for a couple of months now with very little progress. i have 4 ducks each controlled by a different timer... 2 timers per duck. 1 to move it the other to make it fall off the screen. how do i make it so when one duck goes off the creen th other comes up and it says miss?

Computer_Guy
07-26-2001, 02:53 PM
You're going to have to reword this, I can't understand what you're asking, if you already hit the duck, and the other duck says "miss"

TommyHM111
07-26-2001, 08:23 PM
when one duck flies off the screen....... a message that is a lable says MISS and another duck comes out. see before i had the other ducks moving code in the click event of the first duck...
-Tommy__

JDT
07-27-2001, 02:53 AM
Here is an example that needs a picturebox and a timer. It will move the pic box randomly and when it leaves the form a message will be displayed informing you which side of the form it left.

<pre><font color=blue>Option Explicit</font color=blue>

<font color=blue>Private Sub</font color=blue> Form_Load()

<font color=green>'Set up timer</font color=green>
<font color=blue>With</font color=blue> Timer1
.Enabled = <font color=blue>True</font color=blue>
.Interval = 100
<font color=blue>End With</font color=blue>

<font color=green>'Set up form</font color=green>
<font color=blue>With</font color=blue> Me
.Height = 2000
.Width = 2000
.Left = (Screen.Width / 2) - (Me.Width / 2)
.Top = (Screen.Height / 2) - (Me.Height / 2)
<font color=blue>End With</font color=blue>

<font color=green>'Set up picture box</font color=green>
picture1.Move (Me.Width / 2) - (picture1.Width / 2), _
(Me.Height / 2) - (picture1 / 2), 500, 500

<font color=blue>End Sub</font color=blue>

<font color=blue>Private Sub</font color=blue> Timer1_Timer()

<font color=blue>Dim</font color=blue> strMSG <font color=blue>As String</font color=blue> <font color=green>'<----Message from function</font color=green>

<font color=green>'Randomly move picturebox</font color=green>
picture1.Move picture1.Left + (-500 + (Rnd() * 1000)), _
picture1.Top + (-500 + (Rnd() * 1000))

<font color=green>'Call sub to see if pic box is off the form</font color=green>
strMSG = OffScreen(picture1)

<font color=green>'Display msg if pic box left the form</font color=green>
<font color=blue>If</font color=blue> strMSG <> "" <font color=blue>Then</font color=blue>
MsgBox strMSG, , ""
picture1.Move Me.Width \ 2, Me.Height \ 2
<font color=blue>End If</font color=blue>

<font color=blue>End Sub</font color=blue>

<font color=blue>Private Function</font color=blue> OffScreen(pic <font color=blue>As</font color=blue> PictureBox) <font color=blue>As String</font color=blue>

<font color=green>'check to see if the pic box has left the borders</font color=green>
<font color=green>'of the form an return a message to the calling</font color=green>
<font color=green>'procedure indicating which side of the form it left.</font color=green>
<font color=blue>If</font color=blue> pic.Top + pic.Height < 0 <font color=blue>Then</font color=blue> <font color=green>'<-------Top</font color=green>
OffScreen = "Flew off top of form"
<font color=blue>ElseIf</font color=blue> pic.Left > Me.Width <font color=blue>Then</font color=blue> <font color=green>'<--------Right</font color=green>
OffScreen = "Flew off right of form."
<font color=blue>ElseIf</font color=blue> pic.Left + pic.Width < 0 <font color=blue>Then</font color=blue> <font color=green>'<---Left</font color=green>
OffScreen = "Flew off left form."
<font color=blue>ElseIf</font color=blue> pic.Top > Me.Height <font color=blue>Then</font color=blue> <font color=green>'<--------Bottom</font color=green>
OffScreen = "Flew off bottom of form."
<font color=blue>End If</font color=blue>

<font color=blue>End Function</font color=blue></pre>

Hope this helps

JDT

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum