how to make an EASY car game in visual basic 2010 Step by Step

preview_player
Показать описание
I really recommend you to buy the new amazon echo product from the amazon site through this link:

hello guys today I will show you how to make a car game .
this is the code :

Public Class Form1
Dim road(6) As PictureBox
Dim cars(4) As PictureBox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Stop()
Timer2.Stop()
Timer3.Stop()

road(1) = PictureBox1
road(2) = PictureBox2
road(3) = PictureBox3
road(4) = PictureBox4
road(5) = PictureBox5
road(6) = PictureBox6
cars(1) = PictureBox8
cars(2) = PictureBox9
cars(3) = PictureBox10
cars(4) = PictureBox11

End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For x = 1 To 6
road(x).Top += 15
If road(x).Top = Me.Height Then
road(x).Top = -road(x).Height
End If
Next
End Sub

Private Sub Form1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Select Case e.KeyCode
Case Keys.Left
PictureBox7.Left -= 5
Case Keys.Right
PictureBox7.Left += 5
End Select
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
For y = 1 To 4
cars(y).Top += 10
If cars(y).Top = Me.Height Then
cars(y).Top = -(Rnd() * 10)
End If
If PictureBox7.Bounds.IntersectsWith(cars(y).Bounds) Then
Timer1.Stop()
Timer2.Stop()
Timer3.Stop()

MsgBox("game over")
End If
Next
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
Label1.Text = Label1.Text + 0.1
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Start()
Timer2.Start()
Timer3.Start()
Button1.Enabled = False
Button1.Visible = False
End Sub
End Class
Рекомендации по теме
Комментарии
Автор

Thanks prof, I learned a lot from his video.

abdurrahmaninuwa
Автор

Hey can you please make an updated one I know it may not have changed but I want to make my own game where i can learn to be a game dev

Alexlabtester
Автор

thx but need improve like if u lose re show start button and rest agame and re tnx

HoshangHassan
Автор

dude can u give me this file link... 😐

banglagaming
Автор

pleaaaase send to me the car photo ^^

abdljalilsadaoui