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
Contributors
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

How to create a game [vb 2008]
RunarM
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:
Code: Select all
    Dim playerx As Integer = 0
    Dim playery As Integer = 0
Form1_Keydown code:
Code: Select all
      
'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
Form_keyup code:
Code: Select all
'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
Form_Load code:
Code: Select all
KeyPreview = True
Timer1.Enabled = true
Timer1.Interval = 1
Timer1_Tick code:
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
Dim bulletspeed As Integer = 0
Timer1_Tick:
Bullet goes up:
Code: Select all
 Me.Bullet.Top = Me.Bullet.Top + bulletspeed
Timer2_Tick:
Code: Select all
textx.Text = Player.Location.X
        texty.Text = Player.Location.Y
Form1_KeyDown:
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
User avatar
RunarM
Hardcore Programmer
Hardcore Programmer
Posts: 508
Joined: Wed Nov 18, 2009 11:33 pm

Re: How to create a game [vb 2008]
RunarM
Here are some examples.

This pack includes:
*I hate snow
*A new game i'm working on ;)


Image (viewtopic.php?f=70&t=3431)
Image


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
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Re: How to create a game [vb 2008]
XTechVB
this is basic but very useful for those who want to make more advanced games in .Net
Thanks RunarM
You can find me on Facebook or on Skype mihai_92b
User avatar
DarkyKnife
Top Poster
Top Poster
Posts: 109
Joined: Thu Apr 29, 2010 4:59 pm

Great tutorial, i always wanted to know how to make collision
Visit my Youtube chanel
User avatar
zachman61
VIP - Donator
VIP - Donator
Posts: 1892
Joined: Wed Dec 16, 2009 9:56 pm

Re: How to create a game [vb 2008]
zachman61
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 :)
User avatar
MrBrockWalker
VIP - Donator
VIP - Donator
Posts: 171
Joined: Mon Jul 05, 2010 10:30 am

Very nice tutorial, I might have a crack at making a simple game using this :D I'll give you credits if I do make it
Visit BW Photography and check out my photos!
6 posts Page 1 of 1
Return to “Tutorials”