sync on
sync rate 40
set display mode 1024,768,16
autocam off
hide mouse
randomize timer()
 
set global collision on
global speed# = 10.0
global size = 200
global money = 500
global bid = 0
global amount = 0
global winner
global weather
global weather_name$
 
intro()
textures()
media()
camera()
bets()
 
do
   winner = check_winner()
   if winner > 0 then post_winner(winner)
   race()
   camera_change()
   sync
loop
 
 
function post_winner(winner)
center text screen width()/2,screen height()/2,"The WINNER is horse "+str$(winner)
sync
check()
endfunction
 
function check_winner()
hitnum = object collision(100,0)
endfunction hitnum
 
function media()
`make horses
for h = 1 to 5
make object box h,3,3,3
next h
`make wall object
make object box 100,60,5,5
position object 100,20,0,200
ghost object on 100
`make matrix
make matrix 1,50,size,10,10
prepare matrix texture 1,1,1,1
position matrix 1,0,-1,0
`positioning horses
position object 1,48,0,0
position object 2,38,0,0
position object 3,28,0,0
position object 4,18,0,0
position object 5,8,0,0
endfunction
 
function camera_change()
`different camera position
if keystate(3)
position camera 0,30,10,140
`point camera 0,0,-10,-100
point camera 0,object position x(3),object position y(3),object position z(3)
else
position camera 0,170,50,100
point camera 0,-100,0,100
endif
endfunction
 
function camera()
`camera position
position camera 0,170,50,100
point camera 0,-100,0,100
endfunction
 
function race()
`set info box
box 0,0,1024,100,rgb(125,120,250),rgb(15,220,50),rgb(212,20,50),rgb(75,70,80)
set cursor 450,10
print "Current money: $",money,
set cursor 450,25
print "Betting horse: ",bid,
set cursor 450,40
print "Weather conditions:",weather_name$,
if weather < 10
`store sunny weather values
ran1# = rnd(8)/speed#+rnd(0.8)
ran2# = rnd(8)/speed#+rnd(0.7)
ran3# = rnd(7)/speed#+rnd(0.6)
ran4# = rnd(8)/speed#+rnd(0.4)
ran5# = rnd(8)/speed#+rnd(0.5)
else
if weather > 10
`store rainy weather values
ran1# = rnd(7)/speed#+rnd(0.7)
ran2# = rnd(8)/speed#+rnd(0.6)
ran3# = rnd(8)/speed#+rnd(0.7)
ran4# = rnd(8)/speed#+rnd(0.5)
ran5# = rnd(8)/speed#+rnd(0.6)
endif
endif
`move horses
move object 1,ran1#
move object 2,ran2#
move object 3,ran3#
move object 4,ran4#
move object 5,ran5#
endfunction
 
function textures()
`makes textures for game
for x = 1 to 300
for y = 1 to 300
color = rgb(rnd(50),rnd(200),rnd(169))
dot x,y,color
next x
next y
get image 1,0,0,300,300
`make another texture
for x = 1 to 300
for y = 1 to 300
color1 = rgb(rnd(148),rnd(128),rnd(100))
dot x,y,color1
next x
next y
get image 2,0,0,300,300
endfunction
 
function intro()
`Give introduction
set text font "Arial"
ink rgb(255,0,0),0
set text size 27
sync
center text 512,300,"Horbox Racing"
ink rgb(0,192,23),0
set text size 17
center text 512,330,"Place your bets, watch your horses and hopefully"
center text 512,360,"win some more money! Bid carfully though or you might"
center text 512,390,"end up broke!"
ink rgb(24,24,255),0
center text 768,690,"Bronze edition Created by Benjamin"
sync
wait key
cls
ink rgb(255,0,0),0
set text to bold
center text 512,280,"Gameplay:"
set text to normal
ink rgb(0,192,23),0
center text 512,295,"Place your bet on the horse you think will win watch them"
center text 512,310,"in the arena and see if you win! Becareful though, weather"
center text 512,325,"will effect your horse. For better or worse!"
ink rgb(255,0,0),0
set text to bold
center text 512,340,"Controls:"
set text to normal
ink rgb(0,192,23),0
center text 512,355,"While the game is in play press the number '2' button to"
center text 512,370,"change the camera view to a more cinematic look and feel!"
ink rgb(255,0,0),0
set text to bold
center text 512,385,"Weather:"
set text to normal
ink rgb(0,192,23),0
center text 512,400,"There are currently two different types of weather that can"
center text 512,415,"effect your horse, Sun and Rain. Being simple humans we can not"
center text 512,430,"predict the weather! We have to wait for the race to begin!"
ink rgb(255,0,0),0
set text to bold
center text 512,445,"Horses:"
set text to normal
ink rgb(0,192,23),0
center text 512,460,"Horse one: Fast in the sun, quick in the rain. Odds 1:2"
center text 512,475,"Horse two: Quick in the sun, average in the rain. Odds 1:3"
center text 512,490,"Horse three: Average in the sun, quick in the rain. Odds 1:5"
center text 512,505,"Horse four: Slow in the sun, average in the rain. Odds 1:10"
center text 512,520,"Horse five: Average in the sun, average in the rain. Odds 1:8"
center text 512,550,"Press any key"
sync
wait key
endfunction
 
function bets()
`place your bets!
`reset every all the hores
position object 1,48,0,0
position object 2,38,0,0
position object 3,28,0,0
position object 4,18,0,0
position object 5,8,0,0
`reset the camera position
position camera 0,170,50,100
point camera 0,-100,0,100
`make the weather effect
weather = rnd(20)
if weather < 10
prepare matrix texture 1,1,1,1
weather_name$ = "Sunny"
else
if weather > 10
prepare matrix texture 1,2,1,1
weather_name$ = "Rainy"
endif
endif
`on with the game!!
cls
sync
`sets the text colour and size
ink rgb(255,255,255),0
set text size 20
set text to bold
`makes the two boxes that will hold my text positionins them and rotates them
make object box 200,0,0.3,2
make object box 210,0,0.3,2
`rotate objects
for i = 200 to 210 step 10
xrotate object i,0
zrotate object i,0
next i
`positions all the objects
position object 200,camera position x(0)-5,camera position y(0)-0,camera position z(0)
position object 210,camera position x(0)-5,camera position y(0)-0.8,camera position z(0)
`get all the text into images for our objects
ink rgb(255,255,255),0
check$ = "Set bid amount:"
info$ = "Choose horse 1-5:"
text 0,0,check$
get image 3,0,0,text width(check$),text height(check$),1
texture object 200,3
`next image
cls
ink rgb(255,255,255),0
sync
text 0,0,info$
get image 4,0,0,text width(info$),text height(info$),2
texture object 210,4
set object light 200,0
set object light 210,0
`Another text box!
cls
ink rgb(255,0,0),0
center text 512,384,"Current Money:$"+str$(money)
center text 512,404,"Press any key"
sync
wait key
ink rgb(255,255,255),0
`get amount
money:
set cursor 512,300
input amount
if amount > money then goto money
if amount <= 0 then goto money
money = money-amount
bid:
set cursor 512,390
input bid
if bid > 5 then goto bid
if bid <= 0 then goto bid
`refresh screen and sets text colours back to normal
ink rgb(255,255,255),0
`deletes objects
for i = 200 to 210 step 10
delete object i
next i
`bye bye
endfunction
 
function winning()
`shows you have won
center text 512,384,"YOU WIN MONEY!!!"
`horse one
if bid = 1 and winner = 1
money = amount*2+money
endif
`horse two
if bid = 2 and winner = 2
money = amount*3+money
endif
`horse three
if bid = 3 and winner = 3
money = amount*5+money
endif
`horse one
if bid = 4 and winner = 4
money = amount*10+money
endif
`horse one
if bid = 5 and winner = 5
money = amount*8+money
endif
sync
wait key
bets()
endfunction
 
function losing()
`shows that you have lost
center text 512,384,"YOU LOSE MONEY!!!"
money = money
if money = 0 then exit_()
sync
wait key
bets()
endfunction
 
function check()
`check to see if you have won
wait key
ink rgb(255,255,255,),0
cls
if bid = winner
winning()
else
if bid <> winner
losing()
endif
endif
endfunction
 
function exit_()
cls
ink rgb(255,255,255,),0
center text 512,384,"Sorry kid your out of Mula!!"
sync
wait key
end
endfunction