'Coin Race! By SierraKen
'August 16, 2020
'Use the arrow keys to race against the computer to collect coins.
'Press the S key to turn the sound off and on.
'Control speed of game with + and - keys.
start:
score = 0
score$ = ""
score2 = 0
score2$ = ""
soun = 1
coin = 0
speed = 5
x = 5
y = 5
cc = 0
co = 0
ry = 0: rx = 0
ex = 270: ey = 300
ex2 = 330: ey2 = 300
'Setup Coins
co = co + 1
xx(co) = xx: yy(co) = yy
coin = coin + 1
coin = coin - 67 'Delete the coin count in the red boxes.
IF a$
= "s" OR a$
= "S" THEN soun
= soun
+ 1 IF a$
= "-" THEN speed
= speed
- 1 IF a$
= "+" THEN speed
= speed
+ 1 'Erase Future Vehicle
LINE (oldx
, oldy
)-(oldx
+ 15, oldy
+ 15), _RGB32(0, 0, 255), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
'Check to see if you hit a red square.
d = 0
'Check to see if you got a coin.
cc = cc + 1
score = score + 1
_TITLE "Coin Race! Time: " + t1$
+ " You: " + score$
+ " Computer: " + score2$
+ " Speed Of Game (Keys + / -): " + speed$
xx(cc) = -100: yy(cc) = -100
nex3:
cc = 0
'Direction of vehicle and movement.
oldx = x
oldy = y
nex:
'If you go off the screen.
'Draw Future Vehicle
LINE (x
, y
)-(x
+ 15, y
+ 15), _RGB32(0, 255, 0), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
'Blocks (red squares)
LINE (ix
, iy
)-(ix
+ 30, iy
+ 30), _RGB32(255, 0, 0), BF
'Computer -------------------------------------------------------
'If computer goes off the screen.
'Erase the older computer.
LINE (oldex
, oldey
)-(oldex
+ 15, oldey
+ 15), _RGB32(0, 0, 255), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
LINE (oldex2
, oldey2
)-(oldex2
+ 15, oldey2
+ 15), _RGB32(0, 0, 255), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
'Check to see if computer went over a coin.
cc2 = cc2 + 1
IF oldex
+ cx
= xx
(cc2
) AND oldey
+ cy
= yy
(cc2
) THEN xx(cc2) = -200: yy(cc2) = -200
score2 = score2 + 1
_TITLE "Coin Race! Time: " + t1$
+ " You: " + score$
+ " Computer: " + score2$
+ " Speed Of Game (Keys + / -): " + speed$
nex6:
IF oldex2
+ cx
= xx
(cc2
) AND oldey2
+ cy
= yy
(cc2
) THEN xx(cc2) = -200: yy(cc2) = -200
score2 = score2 + 1
_TITLE "Coin Race! Time: " + t1$
+ " You: " + score$
+ " Computer: " + score2$
+ " Speed Of Game (Keys + / -): " + speed$
nex5:
cc2 = 0
IF ee
> 970 THEN 'This number is how often the computer changes direction, the smaller the more frequent. oldex = ex: oldey = ey
IF dir
= 1 THEN ex
= ex
+ speed
IF dir
= 2 THEN ex
= ex
- speed
IF dir
= 3 THEN ey
= ey
+ speed
IF dir
= 4 THEN ey
= ey
- speed
IF ee2
> 970 THEN 'This number is how often the computer changes direction, the smaller the more frequent. oldex2 = ex2: oldey2 = ey2
IF dir2
= 1 THEN ex2
= ex2
+ speed
IF dir2
= 2 THEN ex2
= ex2
- speed
IF dir2
= 3 THEN ey2
= ey2
+ speed
IF dir2
= 4 THEN ey2
= ey2
- speed
'Check to see if the computer hit a square.
IF dir
= 1 THEN dir
= 3: ex
= ex
- 5 IF dir
= 2 THEN dir
= 4: ex
= ex
+ 5 IF dir
= 3 THEN dir
= 1: ey
= ey
- 5 IF dir
= 4 THEN dir
= 2: ey
= ey
+ 5 IF dir
= 1 THEN dir
= 3: ex2
= ex2
- 5 IF dir
= 2 THEN dir
= 4: ex2
= ex2
+ 5 IF dir
= 3 THEN dir
= 1: ey2
= ey2
- 5 IF dir
= 4 THEN dir
= 2: ey2
= ey2
+ 5 nex4:
'Draw the computer.
LINE (ex
, ey
)-(ex
+ 15, ey
+ 15), _RGB32(255, 133, 0), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
LINE (ex2
, ey2
)-(ex2
+ 15, ey2
+ 15), _RGB32(255, 133, 0), BF
IF tires
= 4 THEN ty
= 15: tx
= 15 ty = 0: tx = 0
_TITLE "Coin Race! Time: " + t1$
+ " You: " + score$
+ " Computer: " + score2$
+ " Speed Of Game (Keys + / -): " + speed$
done:
_TITLE "T H E E N D........ You: " + score$
+ " Computer: " + score2$
+ " Again? (Y/N)" again3: