'Tech Invaders 2
'Game made on July 27, 2019
'By Ken G.
'Freeware
'---------------------------------------------------------------------------------------------------------------------------------------
'Directions:
'Move your shooter with the left and right arrow keys and press the space bar to fire at the enemies above.
'The up and down arrow keys make your shooter stop moving.
'Esc key ends at anytime.
'After a couple of rounds, there is the Boss to destroy, which has a health bar that shrinks when you hit him.
'---------------------------------------------------------------------------------------------------------------------------------------
'I have put some descriptions in the code below to make it easier to learn from.
'
begin:
DIM NAME$
(50), nm$
(50), score
(50), sccc
(50) DD = 0
PRINT " Use left and right arrow keys to move back and forth." PRINT " Use up or down arrow keys to stop moving." PRINT " Use space bar to fire." PRINT " Esc to end anytime." INPUT " Press Enter to start.", start$
e1 = 0
E2 = 0
e3 = 0
lives = 5
points = 0
ushoot = 0
shooting = 0
level = 1
level2 = 1
start = 0
s = 0
xt = 400
yt = 560
B = 0
boss = 0
'Draw your shooter.
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(139, 249, 255), BF
OPENINGSOUND
'This is the start of the main loop.
go:
'Choose a random place for the enemy.
'Each level has its own loop so it can set a different equation and speed of the enemy.
c1 = 128: c2 = 127: c3 = 255
one:
'sec is not time, it's related to the coordinate of the enemy and speed it goes related to the loop speed.
sec = sec + .02
s = (60 - sec) * 6 + 180
x
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y
= INT(COS(s
/ 180 * 3.141592) * 180) + 225 x3
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y3
= INT(COS(s
/ 180 * 3.141592) * 180) + 225 x4
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y4
= INT(COS(s
/ 180 * 3.141592) * 180) + 225
'GOSUB to drawing draws the enemy robot.
sec = 0
'GOSUB's go to keyboard control and enemy shooting.
onedone:
'This level uses the spiral equation so it's a bit different than the others.
c1 = 127: c2 = 216: c3 = 127
xx = 400: yy = 300
xx2 = 100: yy2 = 300
xx3 = 600: yy3 = 300
s = s + .2
x
= COS(s
* 3.141592 / 180) * D
y
= SIN(s
* 3.151492 / 180) * D
x3
= COS(s
* 3.141592 / 180) * D
y3
= SIN(s
* 3.151492 / 180) * D
x4
= COS(s
* 3.141592 / 180) * D
y4
= SIN(s
* 3.151492 / 180) * D
s = s - .2
x
= COS(s
* 3.141592 / 180) * D
y
= SIN(s
* 3.151492 / 180) * D
x3
= COS(s
* 3.141592 / 180) * D
y3
= SIN(s
* 3.151492 / 180) * D
x4
= COS(s
* 3.141592 / 180) * D
y4
= SIN(s
* 3.151492 / 180) * D
c1 = 255: c2 = 0: c3 = 0
three:
sec = sec + .02
s = (60 - sec) * 6 + 180
x
= INT(SIN(s
/ 90 * 3.141592) * 180) + 325 y
= INT(COS(s
/ 180 * 3.141592) * 180) + 225 x3
= INT(SIN(s
/ 90 * 3.141592) * 180) + 325 y3
= INT(COS(s
/ 180 * 3.141592) * 180) + 225 x4
= INT(SIN(s
/ 90 * 3.141592) * 180) + 325 y4
= INT(COS(s
/ 180 * 3.141592) * 180) + 225 sec = 0
threedone:
c1 = 255: c2 = 255: c3 = 127
four:
sec = sec + .02
s = (60 - sec) * 6 + 180
x
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y
= INT(COS(s
/ 90 * 3.141592) * 180) + 225 x3
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y3
= INT(COS(s
/ 90 * 3.141592) * 180) + 225 x4
= INT(SIN(s
/ 180 * 3.141592) * 180) + 325 y4
= INT(COS(s
/ 90 * 3.141592) * 180) + 225 sec = 0
fourdone:
c1 = 133: c2 = 28: c3 = 255
five:
sec = sec + .02
s = (60 - sec) * 6 + 180
x
= INT(SIN(s
/ 135 * 3.141592) * 180) + 325 y
= INT(COS(s
/ 33.75 * 3.141592) * 180) + 225 x3
= INT(SIN(s
/ 135 * 3.141592) * 180) + 325 y3
= INT(COS(s
/ 33.75 * 3.141592) * 180) + 225 x4
= INT(SIN(s
/ 135 * 3.141592) * 180) + 325 y4
= INT(COS(s
/ 33.75 * 3.141592) * 180) + 225 sec = 0
fivedone:
e1 = 0: E2 = 1: e3 = 1
boss = 1
c1 = 255: c2 = 0: c3 = 0
six:
sec = sec + .02
s = (60 - sec) * 6 + 180
x
= INT(SIN(s
/ 45 * 3.141592) * 180) + 325 y
= INT(COS(s
/ 360 * 3.141592) * 180) + 225 sec = 0
sixdone:
'GOTO goes back to the start of the main loop.
'Draws the enemy tank and erases it for animation.
drawing:
x2 = x + xx: y2 = y + yy
drawing3:
x5 = x3 + xx2: y5 = y3 + yy2
drawing4:
x6 = x4 + xx3: y6 = y4 + yy3
'Draws the Boss Robot.
drawing2:
x2 = x + xx: y2 = y + yy
LINE (x2
- 10, y2
- 10)-(x2
+ 10, y2
+ 10), _RGB32(0, 255, 0), BF
LINE (x2
- 2, y2
+ 10)-(x2
+ 2, y2
+ 15), _RGB32(0, 255, 0), BF
LINE (x2
- 10, y2
+ 15)-(x2
+ 10, y2
+ 25), _RGB32(0, 255, 0), BF
LINE (x2
- 5, y2
+ 4)-(x2
+ 5, y2
+ 8), _RGB32(0, 0, 0), BF
LINE (x2
- 10, y2
- 10)-(x2
+ 10, y2
+ 10), _RGB32(0, 0, 0), BF
LINE (x2
- 2, y2
+ 10)-(x2
+ 2, y2
+ 15), _RGB32(0, 0, 0), BF
LINE (x2
- 10, y2
+ 15)-(x2
+ 10, y2
+ 25), _RGB32(0, 0, 0), BF
'Keyboard control for your movement and shooting.
keyboard:
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(0, 0, 0), BF
xt = xt + 1
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(139, 249, 255), BF
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(0, 0, 0), BF
xt = xt - 1
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(139, 249, 255), BF
r = 0: l = 0
'The start of your shot.
youshoot:
'sx2 and sy2 are your shot coordinates.
sx2 = xt + 10
sy2 = yt - 20
ushoot = 1
'The drawing and movement of your shot and if it reaches the enemy.
youshoot2:
sy2 = sy2 - 3
ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy
points = points + 100
e1 = 1
level = level + 1
level2 = level2 + 1
e1 = 0: E2 = 0: e3 = 0
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
ushoot = 0
ENEMYEXPLOSION2 sx2, sy2, x5, y5, sx3, sy3
points = points + 100
E2 = 1
level = level + 1
level2 = level2 + 1
e1 = 0: E2 = 0: e3 = 0
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
ushoot = 0
ENEMYEXPLOSION3 sx2, sy2, x6, y6, sx4, sy4
points = points + 100
e3 = 1
level = level + 1
level2 = level2 + 1
e1 = 0: E2 = 0: e3 = 0
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
ushoot = 0
'To see if you hit the Boss.
B = B + 1
BB = 10 - B
LINE (150, 30)-(bx
+ 150, 50), _RGB32(0, 0, 0), BF
bxx:
bx = BB * 10
LINE (150, 30)-(bx
+ 150, 50), _RGB32(227, 0, 0), BF
bxx2:
points = points + 100
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
IF B
> 10 THEN ENEMYEXPLOSION sx2
, sy2
, x2
, y2
, sx
, sy
bx = 0
BB = 0
B = 0
boss = 0
points = points + 1000
level = level + 1
level2 = level2 + 1
e1 = 0: E2 = 0: e3 = 0
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
ushoot = 0
redrawshooter:
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(139, 249, 255), BF
'The enemy's shot and if it reaches you.
shoot:
'sx and sy are the first enemy shot coordinates.
sx = x2 + 10
sy = y2 + 10
shooting = 1
nexone:
'sx3 and sy3 are the second enemy shot coordinates.
sx3 = x5 + 10
sy3 = y5 + 10
shooting2 = 1
nexone2:
'sx4 and sy4 are the third enemy shot coordinates.
sx4 = x6 + 10
sy4 = y6 + 10
shooting3 = 1
nexone3:
'To see if first enemy hit you.
sy = sy + 3
shooting = 0
nex4:
'To see if second enemy hit you.
sy3 = sy3 + 3
shooting2 = 0
nexx:
'To see if third enemy hit you.
sy4 = sy4 + 3
shooting3 = 0
explosion:
LINE (xt
+ 8, yt
- 7)-(xt
+ 12, yt
- 15), _RGB(0, 0, 0), BF
yourexplosion:
DD = DD + 1
dxx = dxx + dxx / 4
dxx2 = dxx2 + dxx2 / 4
dxx3 = dxx3 + dxx3 / 4
dxx4 = dxx4 + dxx4 / 4
dxx5 = dxx5 + dxx5 / 4
dxx6 = dxx6 + dxx6 / 4
dyy = dyy + dyy / 4
dyy2 = dyy2 + dyy2 / 4
dyy3 = dyy3 + dyy3 / 4
dyy4 = dyy4 + dyy4 / 4
dyy5 = dyy5 + dyy5 / 4
dyy6 = dyy6 + dyy6 / 4
LINE (xt
+ dxx
, yt
+ dyy
)-(xt
+ dxx
+ 2, yt
+ dyy
+ 2), _RGB32(255, 0, 0), BF
LINE (xt
+ dxx2
, yt
+ dyy2
)-(xt
+ dxx2
+ 2, yt
+ dyy2
+ 2), _RGB32(0, 255, 0), BF
LINE (xt
+ dxx3
, yt
+ dyy3
)-(xt
+ dxx3
+ 2, yt
+ dyy3
+ 2), _RGB32(255, 0, 0), BF
LINE (xt
+ dxx4
, yt
+ dyy4
)-(xt
+ dxx4
+ 2, yt
+ dyy4
+ 2), _RGB32(0, 255, 0), BF
LINE (xt
+ dxx5
, yt
+ dyy5
)-(xt
+ dxx5
+ 2, yt
+ dyy5
+ 2), _RGB32(255, 0, 0), BF
LINE (xt
+ dxx6
, yt
+ dyy6
)-(xt
+ dxx6
+ 2, yt
+ dyy6
+ 2), _RGB32(0, 255, 0), BF
LINE (xt
+ dxx
, yt
+ dyy
)-(xt
+ dxx
+ 2, yt
+ dyy
+ 2), _RGB32(0, 0, 0), BF
LINE (xt
+ dxx2
, yt
+ dyy2
)-(xt
+ dxx2
+ 2, yt
+ dyy2
+ 2), _RGB32(0, 0, 0), BF
LINE (xt
+ dxx3
, yt
+ dyy3
)-(xt
+ dxx3
+ 2, yt
+ dyy3
+ 2), _RGB32(0, 0, 0), BF
LINE (xt
+ dxx4
, yt
+ dyy4
)-(xt
+ dxx4
+ 2, yt
+ dyy4
+ 2), _RGB32(0, 0, 0), BF
LINE (xt
+ dxx5
, yt
+ dyy5
)-(xt
+ dxx5
+ 2, yt
+ dyy5
+ 2), _RGB32(0, 0, 0), BF
LINE (xt
+ dxx6
, yt
+ dyy6
)-(xt
+ dxx6
+ 2, yt
+ dyy6
+ 2), _RGB32(0, 0, 0), BF
back2:
DD = 0
lives = lives - 1
_TITLE "Tech Invaders 2 Lives: " + lives$
+ " Level: " + level$
+ " Score: " + points$
LINE (xt
- 22, yt
- 42)-(xt
+ 42, yt
+ 42), _RGB32(0, 0, 0), BF
LOCATE 25, 40:
INPUT "Press Enter to go to Top Ten Scores.", tt$
'Top Ten Scores
scc = points
READ toptenname$
, toptenscore!
NN = n
PRINT "You have made the Top Ten!" typename:
INPUT "Type your name here (25 letters and spaces maximum.):", nm$
(NN
) PRINT "Name too long, try again." sccc(NN) = scc
sct = 1
nex5:
nex6:
nex7:
nex8:
nm$(n) = ""
score(n) = 0
sccc(n) = 0
NN = 0
n = 0
sct = 0
scc = 0
INPUT "Would you like to play again? (Yes/No)", ag$
IF ag$
= "y" OR ag$
= "Y" OR ag$
= "YES" OR ag$
= "yes" OR ag$
= "Yes" OR ag$
= "yES" OR ag$
= "yeS" OR ag$
= "YEs" THEN GOTO begin:
OPENINGSOUND
checktoshoot:
originaltopten:
DATA Karen Kryptonite
,2750
snd = 300
snd2 = 800
snd = snd + 10
SUB ENEMYEXPLOSION
(sx2
, sy2
, x2
, y2
, sx
, sy
) explosion1:
dd = dd + 1
dxx = dxx + dxx / 4
dxx2 = dxx2 + dxx2 / 4
dxx3 = dxx3 + dxx3 / 4
dxx4 = dxx4 + dxx4 / 4
dxx5 = dxx5 + dxx5 / 4
dxx6 = dxx6 + dxx6 / 4
dyy = dyy + dyy / 4
dyy2 = dyy2 + dyy2 / 4
dyy3 = dyy3 + dyy3 / 4
dyy4 = dyy4 + dyy4 / 4
dyy5 = dyy5 + dyy5 / 4
dyy6 = dyy6 + dyy6 / 4
LINE (x2
+ dxx
, y2
+ dyy
)-(x2
+ dxx
+ 2, y2
+ dyy
+ 2), _RGB32(255, 0, 0), BF
LINE (x2
+ dxx2
, y2
+ dyy2
)-(x2
+ dxx2
+ 2, y2
+ dyy2
+ 2), _RGB32(0, 255, 0), BF
LINE (x2
+ dxx3
, y2
+ dyy3
)-(x2
+ dxx3
+ 2, y2
+ dyy3
+ 2), _RGB32(255, 0, 0), BF
LINE (x2
+ dxx4
, y2
+ dyy4
)-(x2
+ dxx4
+ 2, y2
+ dyy4
+ 2), _RGB32(0, 255, 0), BF
LINE (x2
+ dxx5
, y2
+ dyy5
)-(x2
+ dxx5
+ 2, y2
+ dyy5
+ 2), _RGB32(255, 0, 0), BF
LINE (x2
+ dxx6
, y2
+ dyy6
)-(x2
+ dxx6
+ 2, y2
+ dyy6
+ 2), _RGB32(0, 255, 0), BF
LINE (x2
+ dxx
, y2
+ dyy
)-(x2
+ dxx
+ 2, y2
+ dyy
+ 2), _RGB32(0, 0, 0), BF
LINE (x2
+ dxx2
, y2
+ dyy2
)-(x2
+ dxx2
+ 2, y2
+ dyy2
+ 2), _RGB32(0, 0, 0), BF
LINE (x2
+ dxx3
, y2
+ dyy3
)-(x2
+ dxx3
+ 2, y2
+ dyy3
+ 2), _RGB32(0, 0, 0), BF
LINE (x2
+ dxx4
, y2
+ dyy4
)-(x2
+ dxx4
+ 2, y2
+ dyy4
+ 2), _RGB32(0, 0, 0), BF
LINE (x2
+ dxx5
, y2
+ dyy5
)-(x2
+ dxx5
+ 2, y2
+ dyy5
+ 2), _RGB32(0, 0, 0), BF
LINE (x2
+ dxx6
, y2
+ dyy6
)-(x2
+ dxx6
+ 2, y2
+ dyy6
+ 2), _RGB32(0, 0, 0), BF
goingback:
dd = 0
LINE (x2
- 21, y2
- 21)-(x2
+ 41, y2
+ 41), _RGB32(0, 0, 0), BF
SUB ENEMYEXPLOSION2
(sx2
, sy2
, x5
, y5
, sx3
, sy3
) explosion2:
dd = dd + 1
dxx = dxx + dxx / 4
dxx2 = dxx2 + dxx2 / 4
dxx3 = dxx3 + dxx3 / 4
dxx4 = dxx4 + dxx4 / 4
dxx5 = dxx5 + dxx5 / 4
dxx6 = dxx6 + dxx6 / 4
dyy = dyy + dyy / 4
dyy2 = dyy2 + dyy2 / 4
dyy3 = dyy3 + dyy3 / 4
dyy4 = dyy4 + dyy4 / 4
dyy5 = dyy5 + dyy5 / 4
dyy6 = dyy6 + dyy6 / 4
LINE (x5
+ dxx
, y5
+ dyy
)-(x5
+ dxx
+ 2, y5
+ dyy
+ 2), _RGB32(255, 0, 0), BF
LINE (x5
+ dxx2
, y5
+ dyy2
)-(x5
+ dxx2
+ 2, y5
+ dyy2
+ 2), _RGB32(0, 255, 0), BF
LINE (x5
+ dxx3
, y5
+ dyy3
)-(x5
+ dxx3
+ 2, y5
+ dyy3
+ 2), _RGB32(255, 0, 0), BF
LINE (x5
+ dxx4
, y5
+ dyy4
)-(x5
+ dxx4
+ 2, y5
+ dyy4
+ 2), _RGB32(0, 255, 0), BF
LINE (x5
+ dxx5
, y5
+ dyy5
)-(x5
+ dxx5
+ 2, y5
+ dyy5
+ 2), _RGB32(255, 0, 0), BF
LINE (x5
+ dxx6
, y5
+ dyy6
)-(x5
+ dxx6
+ 2, y5
+ dyy6
+ 2), _RGB32(0, 255, 0), BF
LINE (x5
+ dxx
, y5
+ dyy
)-(x5
+ dxx
+ 2, y5
+ dyy
+ 2), _RGB32(0, 0, 0), BF
LINE (x5
+ dxx2
, y5
+ dyy2
)-(x5
+ dxx2
+ 2, y5
+ dyy2
+ 2), _RGB32(0, 0, 0), BF
LINE (x5
+ dxx3
, y5
+ dyy3
)-(x5
+ dxx3
+ 2, y5
+ dyy3
+ 2), _RGB32(0, 0, 0), BF
LINE (x5
+ dxx4
, y5
+ dyy4
)-(x5
+ dxx4
+ 2, y5
+ dyy4
+ 2), _RGB32(0, 0, 0), BF
LINE (x5
+ dxx5
, y5
+ dyy5
)-(x5
+ dxx5
+ 2, y5
+ dyy5
+ 2), _RGB32(0, 0, 0), BF
LINE (x5
+ dxx6
, y5
+ dyy6
)-(x5
+ dxx6
+ 2, y5
+ dyy6
+ 2), _RGB32(0, 0, 0), BF
goingback2:
dd = 0
LINE (x5
- 21, y5
- 21)-(x5
+ 41, y5
+ 41), _RGB32(0, 0, 0), BF
SUB ENEMYEXPLOSION3
(sx2
, sy2
, x6
, y6
, sx4
, sy4
) explosion3:
dd = dd + 1
dxx = dxx + dxx / 4
dxx2 = dxx2 + dxx2 / 4
dxx3 = dxx3 + dxx3 / 4
dxx4 = dxx4 + dxx4 / 4
dxx5 = dxx5 + dxx5 / 4
dxx6 = dxx6 + dxx6 / 4
dyy = dyy + dyy / 4
dyy2 = dyy2 + dyy2 / 4
dyy3 = dyy3 + dyy3 / 4
dyy4 = dyy4 + dyy4 / 4
dyy5 = dyy5 + dyy5 / 4
dyy6 = dyy6 + dyy6 / 4
LINE (x6
+ dxx
, y6
+ dyy
)-(x6
+ dxx
+ 2, y6
+ dyy
+ 2), _RGB32(255, 0, 0), BF
LINE (x6
+ dxx2
, y6
+ dyy2
)-(x6
+ dxx2
+ 2, y6
+ dyy2
+ 2), _RGB32(0, 255, 0), BF
LINE (x6
+ dxx3
, y6
+ dyy3
)-(x6
+ dxx3
+ 2, y6
+ dyy3
+ 2), _RGB32(255, 0, 0), BF
LINE (x6
+ dxx4
, y6
+ dyy4
)-(x6
+ dxx4
+ 2, y6
+ dyy4
+ 2), _RGB32(0, 255, 0), BF
LINE (x6
+ dxx5
, y6
+ dyy5
)-(x6
+ dxx5
+ 2, y6
+ dyy5
+ 2), _RGB32(255, 0, 0), BF
LINE (x6
+ dxx6
, y6
+ dyy6
)-(x6
+ dxx6
+ 2, y6
+ dyy6
+ 2), _RGB32(0, 255, 0), BF
LINE (x6
+ dxx
, y6
+ dyy
)-(x6
+ dxx
+ 2, y6
+ dyy
+ 2), _RGB32(0, 0, 0), BF
LINE (x6
+ dxx2
, y6
+ dyy2
)-(x6
+ dxx2
+ 2, y6
+ dyy2
+ 2), _RGB32(0, 0, 0), BF
LINE (x6
+ dxx3
, y6
+ dyy3
)-(x6
+ dxx3
+ 2, y6
+ dyy3
+ 2), _RGB32(0, 0, 0), BF
LINE (x6
+ dxx4
, y6
+ dyy4
)-(x6
+ dxx4
+ 2, y6
+ dyy4
+ 2), _RGB32(0, 0, 0), BF
LINE (x6
+ dxx5
, y6
+ dyy5
)-(x6
+ dxx5
+ 2, y6
+ dyy5
+ 2), _RGB32(0, 0, 0), BF
LINE (x6
+ dxx6
, y6
+ dyy6
)-(x6
+ dxx6
+ 2, y6
+ dyy6
+ 2), _RGB32(0, 0, 0), BF
goingback3:
dd = 0
LINE (x6
- 21, y6
- 21)-(x6
+ 41, y6
+ 41), _RGB32(0, 0, 0), BF