Simple Horserace Game Worksheet For Visual Basic 2008
This uses the timer to create automatic random movement. Create two instances of this and you have a horse race game that can be adapted to a variety of other gaming situations. Should work with all versions of VB - You do need the shapes add on installed that comes with the express version but has to be manually added to the professional version. If you don't have the shapes add on then you can use textboxes or labels instead.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
353 views
Simple Horserace Game Worksheet For Visual Basic 2008
This uses the timer to create automatic random movement. Create two instances of this and you have a horse race game that can be adapted to a variety of other gaming situations. Should work with all versions of VB - You do need the shapes add on installed that comes with the express version but has to be manually added to the professional version. If you don't have the shapes add on then you can use textboxes or labels instead.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 4
38827058.
doc Ray Davies Page 1 of 4
Change the fill style to colour it Horse Race Game
Give it a Create a shape meaningful name from here
Create a button called
btnGo
Select the shape and
find the Location property. Move the shape and notice how the co ordinates change
The first number is left to
right with 0 on the lefthand side The second number is top to bottom with 0 at the top
Creer Sur 19/08/10 19:30
38827058.doc Ray Davies Page 2 of 4 Declare a variable for the up down movement and give it the starting point (you can get this by reading it from the properties)
Put this code behind the
button
Okily dokily programerinos – change
the code so you can make the shape go down and sideways as well
Put in some code that detects when
the horse reaches the finish line
Mmmnn nnn mmm nnnnnn mmmm
nnnnMMmm
[we need to add automated movement
to make it more tasty]
Creer Sur 19/08/10 19:30
38827058.doc Ray Davies Page 3 of 4
Adding Automated Movement
It appears at Enabled means it’s
Add a timer the bottom of ticking and Interval is the screen how often it ticks
The timer does all the
work cut the code from behind the button and put it behind the timer
Change this line to …
Timer1.enabled = false (it will switch the timer off)
Now behind the button
simply switch the timer on
Run the program and the horse should move
up the screen on it’s own, but it’s a bit boring we want some random movement
Set up the random number where
global variables are declared
And use it in the
formula for a Creer Sur 19/08/10 19:30 38827058.doc Ray Davies Page 4 of 4
Tuk Tuk Tuk Tuk Tuk Tuk
Tuk Tuk Tuk Tuk Tuk Tuk Tuk Tuk Tuk Tuk Tuk Tuk
[Check it works OK and
add another horse to make a proper game]
Most of it is just a copy and paste job but
here is the revised code to stop it when someone has one