I only want a bomb to move...

queechi
12-21-2001, 09:22 AM
I'm new to vb and whenever I press the space key the bomb won't move the 80 twips down but instead shoots to the left of the screen and stays there:
Private Sub bombdown_Timer()
bomb.Move bomb.Top + 80
If bomb.Top = bin.Top Then
binleft.Enabled = False
binright.Enabled = False
bin.Visible = False
bin2.Visible = False
boom.Visible = True
bombdown.Enabled = False
End If
If bomb.Top > 5000 Then
bomb.Top = 120
bombdown.Enabled = False
binleft.Enabled = True
binright.Enabled = True
End If
End Sub


Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then
bomb.Move bomb.Left - 500
If bomb.Left < 0 Then
bomb.Left = 8000
End If
ElseIf KeyCode = vbKeyRight Then
bomb.Move bomb.Left + 500
If bomb.Left > 7080 Then
bomb.Left = 100
End If
ElseIf KeyCode = vbKeySpace Then
bombdown.Enabled = True
End If
End Sub

Private Sub binright_Timer()
bin.Move bin.Left + 120
bin2.Move bin2.Left + 120
boom.Move boom.Left + 120
If bin.Left = 7080 Then
bin.Visible = False
bin2.Visible = True
binright.Enabled = False
binleft.Enabled = True
End If
End Sub


Private Sub binleft_Timer()
bin.Move bin.Left - 120
bin2.Move bin2.Left - 120
boom.Move boom.Left - 120
If bin.Left < 10 Then
bin.Visible = True
bin2.Visible = False
binright.Enabled = True
binleft.Enabled = False
End If
End Sub

robot313
12-21-2001, 10:13 AM
Well if it was my game I would do something like this:<pre>
bomb.Top = bomb.Top + 80</pre>

But you could still do it the way you are trying, but just look at this syntax for Move:
object.Move left, top, width, height
So, you want to make it move down, so you would need to put your code for the second parameter, like this:<pre>
bomb.Move bomb.Left, bomb.Top + 80</pre>
Hope this helps.

Squirm
12-21-2001, 10:23 AM
Your problem is with your Move calls. The first parameter is always the left property, then the height property. So if you have:

bomb.Move bomb.Top + 80

then that tells it to move the Left of the bomb to wherever the Top of the bomb is + 80. It should be:

bomb.Move bomb.Left, bomb.Top + 80

queechi
12-22-2001, 08:32 AM
thanks that did it, now to blow up bin ladens head!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum