|
-
Feb 5th, 2012, 05:17 PM
#1
Thread Starter
New Member
Beginners Game
Hello Guys,
Im working on a small vb game, the game is basically pushing boxes.
Everthing was going fine, until suddenly, the game is no longer doing what i wrote in the source code, i mean the source code is there , it just looks like its not being executed.
Here is the Source Code, i hope you guys can help me find this wierd error.
Timer1 set to true and the interval is 1
Timer2 set to true and the interval is 10
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Dim tecla As Boolean = GetAsyncKeyState(Keys.W)
Dim tecla2 As Boolean = GetAsyncKeyState(Keys.S)
Dim tecla3 As Boolean = GetAsyncKeyState(Keys.A)
Dim tecla4 As Boolean = GetAsyncKeyState(Keys.D)
'Form Load
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
End Sub
'Move
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.W Then
player.Location = New Point(player.Location.X, player.Location.Y - 50)
ElseIf e.KeyCode = Keys.S Then
player.Location = New Point(player.Location.X, player.Location.Y + 50)
ElseIf e.KeyCode = Keys.A Then
player.Location = New Point(player.Location.X - 50, player.Location.Y)
ElseIf e.KeyCode = Keys.D Then
player.Location = New Point(player.Location.X + 50, player.Location.Y)
End If
End Sub
'Collision Timer 1
Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
'Topo
If tecla = True And player.Top + player.Height = fronteira.Top Then
player.Top = player.Top + 50
End If
'Baixo No rectangulo 16
If tecla2 = True And player.Top = RectangleShape16.Top + RectangleShape16.Height Then
player.Top = player.Top - 50
End If
'Esquerda
If tecla3 = True And player.Left + player.Width = fronteira.Left Then
player.Left = player.Left + 50
End If
'Direita no rectangulo 13
If tecla4 = True And player.Left = RectangleShape13.Left + RectangleShape13.Width Then
player.Left = player.Left - 50
End If
'top = top
'left = left
'left + width = right
'top + height = bottom
End Sub
'Push Box
Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
'Empurrar para direita
If player.Left = caixa.Left And tecla4 = True And player.Location.Y = caixa.Location.Y Then
caixa.Left = caixa.Left + 50
End If
'Empurrar para esquerda
If player.Left + player.Width = caixa.Left + caixa.Width And tecla3 = True And player.Location.Y = caixa.Location.Y Then
caixa.Left = caixa.Left - 50
End If
'Empurrar para baixo
If player.Top + player.Height = caixa.Top + caixa.Height And tecla2 = True And player.Location.X = caixa.Location.X Then
caixa.Top = caixa.Top + 50
End If
'Empurrar para cima
If player.Top = caixa.Top And tecla = True And player.Location.X = caixa.Location.X Then
caixa.Top = caixa.Top - 50
End If
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|