Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
hi guys
I'm developing my 1st game in VB and i need to learn some ideas about making objects jump when i press a specific button
here is the code for only moving a car
i need the car to jump when i press UP button
any ideas ?

What I have tried:

VB
Public Class Form1
    Dim x As Integer = 1, y As Integer = 1, speed As Integer = 1
    '=========================================
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MovemenT.Enabled = True
    End Sub

    Private Sub MovemenT_Tick(sender As Object, e As EventArgs) Handles MovemenT.Tick
        PictureBox1.Left -= speed
        Select Case x
            Case 1
                PictureBox1.Image = My.Resources.Car2
                x += 1
            Case 2
                PictureBox1.Image = My.Resources.Car3
                x += 1
            Case 3
                PictureBox1.Image = My.Resources.Car4
                x = 1
        End Select
    End Sub
End Class
Posted
Updated 14-Jan-18 21:50pm
v3

1 solution

It depends on your jump trajectory. A simple way would be using arrays for y and x increments while the car is in the status of 'jumping'. Upon reaching the end of the array, the car status can return to 'moving'.
 
Share this answer
 
Comments
Member 13622627 16-Jan-18 1:17am    
Good idea.
Thnx dude!
CPallini 20-Jan-18 4:53am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900