How to create a game [vb 2008]
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
6 posts
Page 1 of 1
Hello, this tutorial will teach you the basics of making a game in visual basic 2008.
Moving the player with key arrows:
You need:
1 Picturebox (named: Player)
1 Timer
Codes:
Under: Public Class Form1:
Player meets wall:
You need:
Picturebox (named Wall)
Bullet:
This will show you how to make a bullet
You need:
Picturebox (named: Bullet)
Timer1
Timer2
Under: Public Class Form1:
Bullet goes up:
Get points:
You need:
Picturebox (named: coins)
label (named: score) (score.text = "0")
Now you can create a game, i might add more soon ^^
-RunarM
Moving the player with key arrows:
You need:
1 Picturebox (named: Player)
1 Timer
Codes:
Under: Public Class Form1:
Code: Select all
Form1_Keydown code:
Dim playerx As Integer = 0
Dim playery As Integer = 0
Code: Select all
Form_keyup code:
'This will move the player when you click right, left etc.. arrow
If e.KeyCode = Keys.Right Then
playerx = 5
ElseIf e.KeyCode = Keys.Left Then
playerx = -5
ElseIf e.KeyCode = Keys.Up Then
playery = -5
ElseIf e.KeyCode = Keys.Down Then
playery = 5
End If
Code: Select all
Form_Load code:
'This will stop the player when you doesn't press keys anymore..
If e.KeyCode = Keys.Right Or e.KeyCode = Keys.Left Or e.KeyCode = Keys.Up Or e.KeyCode = Keys.Down Then
playerx = 0
playery = 0
End If
Code: Select all
Timer1_Tick code:
KeyPreview = True
Timer1.Enabled = true
Timer1.Interval = 1
Code: Select all
'This will move the player
Me.Player.Left = Me.Player.Left + playerx
Me.Player.Top = Me.Player.Top + playery
Player meets wall:
You need:
Picturebox (named Wall)
Code: Select all
'When player meets then something happens...
If Player.Bounds.IntersectsWith(wall.Bounds) Then
'what should happen?
End If
Bullet:
This will show you how to make a bullet
You need:
Picturebox (named: Bullet)
Timer1
Timer2
Under: Public Class Form1:
Code: Select all
Timer1_Tick:Dim bulletspeed As Integer = 0
Bullet goes up:
Code: Select all
Timer2_Tick:
Me.Bullet.Top = Me.Bullet.Top + bulletspeed
Code: Select all
Form1_KeyDown:
textx.Text = Player.Location.X
texty.Text = Player.Location.Y
Code: Select all
'When you press space the bullet will go to a location.
If e.KeyCode = Keys.Space Then
Bullet.Location = New Point(textx.Text, texty.Text)
End If
Get points:
You need:
Picturebox (named: coins)
label (named: score) (score.text = "0")
Code: Select all
If Player.Bounds.IntersectsWith(coins.Bounds) Then
coins.visible = false
score.text += 1
End If
Now you can create a game, i might add more soon ^^
-RunarM
Last edited by RunarM on Mon Nov 08, 2010 4:40 pm, edited 12 times in total.
Just another day in my life.
http://www.codexvideos.com
http://www.codexvideos.com
Here are some examples.
This pack includes:
*I hate snow
*A new game i'm working on ;)
(viewtopic.php?f=70&t=3431)
![Image]()
The files is copyrighted © to RunarM 2010, so you may NOT post it any other places.
This pack includes:
*I hate snow
*A new game i'm working on ;)


The files is copyrighted © to RunarM 2010, so you may NOT post it any other places.
You do not have the required permissions to view the files attached to this post.
Just another day in my life.
http://www.codexvideos.com
http://www.codexvideos.com
this is basic but very useful for those who want to make more advanced games in .Net
Thanks RunarM
Thanks RunarM
You can find me on Facebook or on Skype mihai_92b
Great tutorial, i always wanted to know how to make collision
ooh collisions!!!!!
Nailing my feet to the floor is easier than using my own muscles to balance, but you don't see me doing that 

Very nice tutorial, I might have a crack at making a simple game using this
I'll give you credits if I do make it

Visit BW Photography and check out my photos!
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023