Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
06-23-2022, 12:59 AM
(This post was last modified: 06-24-2022, 01:52 AM by SierraKen.)
This is a new and improved version of my old Tech Invaders 2 I made a few years ago. This version uses your mouse to control your shooter back and forth and press the button to fire.
I also changed the looks of your shooter and the enemies as well as different sounds. As with Tech Invaders 2, this will automatically generate a small text (.txt) file called toptentech.txt in the same directory you save this game in, which is for the Top Ten scores. It will save your score if you beat any of the current ones. Thanks goes to B+ and the rest of the gang a few years ago for some help. I did make version 2 when I was fairly new with QB64 so it probably has around 5 times more code than needed, but I didn't want to keep messing with over 1000 lines of code and countless variables to make it smaller.
Enjoy!
Code deleted because of a much better version I posted below.
Posts: 3,978
Threads: 177
Joined: Apr 2022
Reputation:
220
I definitely prefer mouse over arrow keys! Those enemies are cute! Nice update
b = b + ...
Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
Thanks B+!
Posts: 660
Threads: 142
Joined: Apr 2022
Reputation:
58
Took me 3 tries to get the Boss the first time.
Was there a reason you put in multiple "randomize timer" commands in the program? I usually just slap it into a program once at initialization and don't worry about it later. Just curious if there is a technical reason.
Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
No, when I used to program in QBasic in the 1990's I used to think I needed to do it many times, so when I began QB64 I did the same thing. I removed a couple for this version but I guess I didn't see the others. Thanks for telling me.
Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
06-24-2022, 12:02 AM
(This post was last modified: 06-24-2022, 12:03 AM by SierraKen.)
I'm cleaning up the code right now and just got rid of over 100 lines of code since I don't need the last few SUBs when I can put every Enemyexplosion SUB into just 1. I'll make 1 or 2 other changes as well and repost real soon.
Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
06-24-2022, 01:51 AM
(This post was last modified: 06-24-2022, 05:57 PM by SierraKen.)
Here is the updated version. I added a 3rd saucer or alien to shoot at per screen (besides the face alien), which includes the face you shoot too. Since I added this 3rd saucer, I'm back to over 1000 lines of code, but it's OK. At least I removed all those unneeded SUBs. I also cleaned up the code a little bit and DIMed most of the variables. I DIMed them mostly because I tried a 3rd alien the other day and it froze on me. Either I had something wrong or the app ran out of memory or something. But it works great now. I also fixed the looks of the aliens that are on the screen right after you defeat the Boss Robot. They now look the same as they do at the very start of the game. Tell me what you think. As with the other one, this will make a small text file for your Top Ten scores in a text file called toptentech.txt so it would be best to put this in its own directory. Enjoy!
Code: (Select All) 'Tech Invaders 3
'Game made on June 23, 2022.
'By SierraKen
'Freeware
'I have put some descriptions in the code below to make it easier to learn from.
'Changes to this version are better looking aliens and your shooter, as well as moving your shooter with your mouse, and different sounds.
'Also added a third saucer per screen to shoot!
_ScreenMove _Middle
begin:
_Limit 1000
Dim name$(50), nm$(50), score(50), sccc(50)
Dim x As Single, y As Single, x2 As Single, y2 As Single, x5 As Single, y5 As Single, x6 As Single, y6 As Single, x7 As Single, y7 As Single, xt As Single, yt As Single
Dim enemy As Single, e1 As Single, e2 As Single, e3 As Single, e4 As Single
Dim lives As Single, level As Single, ushoot As Single, points As Single, level2 As Single, DD As Single, start As Single, b As Single, boss As Single
Dim xx As Single, yy As Single, xx2 As Single, yy2 As Single, xx3 As Single, yy3 As Single, xx4 As Single, yy4 As Single
Dim c1 As Single, c2 As Single, c3 As Single
Dim x3 As Single, y3 As Single, x4 As Single, y4 As Single
Dim csaucer1 As Single, csaucer2 As Single, csaucer3 As Single
Dim sz As Single, s As Single, sec As Single, mo As Single, mouth As Single, mo2 As Single, mouth2 As Single, t As Single
Dim sx As Single, sy As Single, sx2 As Single, sy2 As Single, sx3 As Single, sy3 As Single, sx4 As Single, sy4 As Single, sx5 As Single, sy5 As Single
_Title "Tech Invaders 3 - by SierraKen"
Cls
Screen _NewImage(800, 600, 32)
Print: Print: Print
For tt = 79 To 34 Step -2
Locate 3, tt + 2: Print " "
Locate 3, tt: Print "T"
_Delay .03
Next tt
For ee = 79 To 36 Step -2
Locate 3, ee + 2: Print " "
Locate 3, ee: Print "E"
_Delay .03
Next ee
For cc = 79 To 38 Step -2
Locate 3, cc + 2: Print " "
Locate 3, cc: Print "C"
_Delay .03
Next cc
For hh = 79 To 40 Step -2
Locate 3, hh + 2: Print " "
Locate 3, hh: Print "H"
_Delay .03
Next hh
For II = 79 To 54 Step -2
Locate 3, II + 2: Print " "
Locate 3, II: Print "I"
_Delay .03
Next II
For NN = 79 To 56 Step -2
Locate 3, NN + 2: Print " "
Locate 3, NN: Print "N"
_Delay .03
Next NN
For VV = 79 To 58 Step -2
Locate 3, VV + 2: Print " "
Locate 3, VV: Print "V"
_Delay .03
Next VV
For AA = 79 To 60 Step -2
Locate 3, AA + 2: Print " "
Locate 3, AA: Print "A"
_Delay .03
Next AA
For DD = 79 To 62 Step -2
Locate 3, DD + 2: Print " "
Locate 3, DD: Print "D"
_Delay .03
Next DD
For EE2 = 79 To 64 Step -2
Locate 3, EE2 + 2: Print " "
Locate 3, EE2: Print "E"
_Delay .03
Next EE2
For RR = 79 To 66 Step -2
Locate 3, RR + 2: Print " "
Locate 3, RR: Print "R"
_Delay .03
Next RR
For ss = 79 To 68 Step -2
Locate 3, ss + 2: Print " "
Locate 3, ss: Print "S"
_Delay .03
Next ss
DD = 0
Print: Print: Print
Print " T H R E E"
Print: Print: Print
Print " by SierraKen"
Print: Print: Print
Print " Use the Mouse to steer your shooter left and right."
Print " Use left Mouse Button to fire."
Print " Esc to end anytime."
Print: Print: Print
Print " Press Mouse Button To Start."
Do
If _MouseInput Then
If _MouseButton(1) Then GoTo startgame:
End If
Loop
startgame:
Cls
e1 = 0
e2 = 0
e3 = 0
e4 = 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
sx2 = 0
sy2 = 0
'Draw your shooter.
For sz = .25 To 10 Step .25
Line (xt - 10 - sz, yt + 10)-(xt - sz, yt - 10), _RGB32(0, 255, 128)
Line (xt + 10 + sz, yt + 10)-(xt + sz, yt - 10), _RGB32(0, 255, 128)
Next sz
OPENINGSOUND
Randomize Timer
'This is the start of the main loop.
go:
'Choose a random place for the enemy.
If e1 = 0 And e2 = 0 And e3 = 0 Then
xx = Int(Rnd * 200) + 100
yy = Int(Rnd * 100) + 40
xx2 = Int(Rnd * 200) + 200
yy2 = Int(Rnd * 100) + 40
xx3 = Int(Rnd * 200) + 250
yy3 = Int(Rnd * 100) + 40
xx4 = Int(Rnd * 200) + 300
yy4 = Int(Rnd * 100) + 40
End If
'Each level has its own loop so it can set a different equation and speed of the enemy.
If level = 1 Then
c1 = 128: c2 = 127: c3 = 255
csaucer1 = 0: csaucer2 = 0: csaucer3 = 0
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 / 360 * 3.141592) * 180) + 125
y = Int(Cos(s / 25 * 3.141592) * 180) + 225
x3 = Int(Sin(s / 360 * 3.141592) * 180) + 125
y3 = Int(Cos(s / 25 * 3.141592) * 180) + 225
x4 = Int(Sin(s / 360 * 3.141592) * 180) + 125
y4 = Int(Cos(s / 25 * 3.141592) * 180) + 225
x7 = Int(Sin(s / 360 * 3.141592) * 180) + 125
y7 = Int(Cos(s / 25 * 3.141592) * 180) + 225
'GOSUB to drawing draws the enemy robot.
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
If sec > 180 Then
sec = 0
GoTo onedone:
End If
'GOSUB's go to keyboard control and enemy shooting.
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
GoTo one:
onedone:
End If
'This level uses the spiral equation so it's a bit different than the others.
If level = 2 Then
c1 = 127: c2 = 216: c3 = 127
csaucer1 = 127: csaucer2 = 216: csaucer3 = 127
xx = 400: yy = 300
xx2 = 100: yy2 = 300
xx3 = 600: yy3 = 300
For d = 160 To 0 Step -.125
_Limit 1000
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
x7 = Cos(s * 3.141592 / 180) * d
y7 = Sin(s * 3.151492 / 180) * d
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
Next d
For d = 0 To 160 Step .125
_Limit 1000
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
x7 = Cos(s * 3.141592 / 180) * d
y7 = Sin(s * 3.151492 / 180) * d
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
Next d
End If
If level = 3 Then
c1 = 255: c2 = 0: c3 = 0
csaucer1 = 255: csaucer2 = 0: csaucer3 = 0
three:
sec = sec + .02
s = (60 - sec) * 6 + 180
x = Int(Sin(s / 360 * 3.141592) * 180) + 25
y = Int(Cos(s / 65 * 3.141592) * 180) + 225
x3 = Int(Sin(s / 360 * 3.141592) * 180) + 25
y3 = Int(Cos(s / 65 * 3.141592) * 180) + 225
x4 = Int(Sin(s / 360 * 3.141592) * 180) + 25
y4 = Int(Cos(s / 65 * 3.141592) * 180) + 225
x7 = Int(Sin(s / 360 * 3.141592) * 180) + 25
y7 = Int(Cos(s / 65 * 3.141592) * 180) + 225
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
If sec > 60 Then
sec = 0
GoTo threedone:
End If
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
GoTo three:
threedone:
End If
If level = 4 Then
c1 = 255: c2 = 255: c3 = 127
csaucer1 = 255: csaucer2 = 255: csaucer3 = 127
four:
sec = sec + .02
s = (60 - sec) * 6 + 180
x = Int(Sin(s / 120 * 3.141592) * 180) + 25
y = Int(Cos(s / 200 * 3.141592) * 180) + 225
x3 = Int(Sin(s / 120 * 3.141592) * 180) + 75
y3 = Int(Cos(s / 200 * 3.141592) * 180) + 225
x4 = Int(Sin(s / 120 * 3.141592) * 180) + 125
y4 = Int(Cos(s / 200 * 3.141592) * 180) + 225
x7 = Int(Sin(s / 120 * 3.141592) * 180) + 325
y7 = Int(Cos(s / 200 * 3.141592) * 180) + 225
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
If sec > 60 Then
sec = 0
GoTo fourdone:
End If
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
GoTo four:
fourdone:
End If
If level = 5 Then
c1 = 133: c2 = 28: c3 = 255
csaucer1 = 133: csaucer2 = 28: csaucer3 = 255
five:
sec = sec + .02
s = (60 - sec) * 6 + 180
x = Int(Sin(s / 45 * 3.141592) * 180) + 25
y = Int(Cos(s / 360 * 3.141592) * 180) + 225
x3 = Int(Sin(s / 45 * 3.141592) * 180) + 75
y3 = Int(Cos(s / 360 * 3.141592) * 180) + 225
x4 = Int(Sin(s / 45 * 3.141592) * 180) + 125
y4 = Int(Cos(s / 360 * 3.141592) * 180) + 225
x7 = Int(Sin(s / 45 * 3.141592) * 180) + 200
y7 = Int(Cos(s / 360 * 3.141592) * 180) + 225
If e1 <> 1 Then GoSub drawing:
If e2 <> 1 Then GoSub drawing3:
If e3 <> 1 Then GoSub drawing4:
If e4 <> 1 Then GoSub drawing5:
_Delay .006
If sec > 60 Then
sec = 0
GoTo fivedone:
End If
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
GoTo five:
fivedone:
End If
If level = 6 Then
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 / 135 * 3.141592) * 180) + 325
y = Int(Cos(s / 33.75 * 3.141592) * 180) + 225
GoSub drawing2:
If sec > 120 Then
sec = 0
GoTo sixdone:
End If
GoSub mouse:
GoSub shoot:
GoSub youshoot2:
GoTo six:
sixdone:
End If
If level = 7 Then level = 1
GoTo go:
'GOTO goes back to the start of the main loop.
'Draws enemy ship #1.
drawing:
x2 = x + xx: y2 = y + yy
If x2 > 775 Then x2 = 775
If x2 < 25 Then x2 = 25
For t = 15 To 20 Step .25
Circle (x2, y2), t, _RGB32(csaucer1, csaucer2, csaucer3), , , .5
Next t
c1 = c1 + 1: c2 = c2 + 1: c3 = c3 + 1
If c1 > 255 Then c1 = 80
If c2 > 255 Then c2 = 80
If c3 > 255 Then c3 = 80
For t = .25 To 8 Step .25
Circle (x2, y2), t, _RGB32(c1, c2, c3), , , .5
Next t
For t = .25 To 3 Step .25
Circle (x2 - 10, y2 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x2 + 10, y2 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x2, y2 + 10), t, _RGB32(255, 127, 0), , , .5
Next t
Return
'Draws the Boss Robot.
drawing2:
x2 = x + xx: y2 = y + yy
If x2 > 775 Then x2 = 775
If x2 < 25 Then x2 = 25
If mouth2 > 1.8 Then mo2 = 1
If mouth2 < .2 Then mo2 = 0
If mo2 = 0 Then mouth2 = mouth2 + .025
If mo2 = 1 Then mouth2 = mouth2 - .025
c4 = 75: c5 = 75: c6 = 75
For t = 15 To .25 Step -.25
c4 = c4 + t / 3: c5 = c5 + t / 3: c6 = c6 + t / 3
Circle (x2, y2), t, _RGB32(c4, c5, c6)
Line (x2 - 14, y2 + t + 15)-(x2 + 14, y2 + t + 15), _RGB32(c4, c5, c6), BF
Next t
For t = .25 To 2 Step .25
Circle (x2 - 10, y2 - 5), t, _RGB32(255, 0, 0)
Circle (x2 + 10, y2 - 5), t, _RGB32(255, 0, 0)
Next t
For t = .25 To 6 Step .25
Circle (x2, y2 + 5), t, _RGB32(255, 0, 0), _Pi, 0, mouth2
Next t
_Delay .004
Return
'Draws enemy ship #2.
drawing3:
x5 = x3 + xx2: y5 = y3 + yy2
If x5 > 775 Then x5 = 775
If x5 < 25 Then x5 = 25
For t = 15 To 20 Step .25
Circle (x5, y5), t, _RGB32(csaucer1, csaucer2, csaucer3), , , .5
Next t
For t = .25 To 8 Step .25
Circle (x5, y5), t, _RGB32(c1, c2, c3), , , .5
Next t
For t = .25 To 3 Step .25
Circle (x5 - 10, y5 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x5 + 10, y5 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x5, y5 + 10), t, _RGB32(255, 127, 0), , , .5
Next t
Return
'Draws enemy face.
drawing4:
x6 = x4 + xx3: y6 = y4 + yy3
If x6 > 775 Then x6 = 775
If x6 < 25 Then x6 = 25
If mouth > 1.8 Then mo = 1
If mouth < .2 Then mo = 0
If mo = 0 Then mouth = mouth + .025
If mo = 1 Then mouth = mouth - .025
For t = 15 To 20 Step .25
Circle (x6, y6), t, _RGB32(csaucer1, csaucer2, csaucer3), , , .5
Next t
For t = .25 To 15 Step .25
Circle (x6, y6), t, _RGB32(c1, c2, c3)
Next t
For t = .25 To 3 Step .25
Circle (x6 - 10, y6 - 5), t, _RGB32(0, 255, 255)
Circle (x6 + 10, y6 - 5), t, _RGB32(0, 255, 255)
Next t
For t = .25 To 6 Step .25
Circle (x6, y6 + 5), t, _RGB32(0, 255, 255), _Pi, 0, mouth
Next t
Return
'Draws enemy ship #3.
drawing5:
x7 = x3 + xx4: y7 = y3 + yy4
If x7 > 775 Then x7 = 775
If x7 < 25 Then x7 = 25
For t = 15 To 20 Step .25
Circle (x7, y7), t, _RGB32(csaucer1, csaucer2, csaucer3), , , .5
Next t
For t = .25 To 8 Step .25
Circle (x7, y7), t, _RGB32(c1, c2, c3), , , .5
Next t
For t = .25 To 3 Step .25
Circle (x7 - 10, y7 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x7 + 10, y7 - 5), t, _RGB32(255, 127, 0), , , .5
Circle (x7, y7 + 10), t, _RGB32(255, 127, 0), , , .5
Next t
Return
'Mouse control for your movement and shooting.
mouse:
_Limit 1000
_Display
Cls
If level = 6 And b > 0 Then
Locate 3, 3: Print "BOSS ROBOT:"
Line (150, 30)-(bx + 150, 50), _RGB32(227, 0, 0), BF
End If
Do While _MouseInput
xt = _MouseX
If _MouseButton(1) Then GoSub youshoot:
a$ = InKey$
If a$ = Chr$(27) Then End
Loop
For sz = .25 To 10 Step .25
Line (xt - 10 - sz, yt + 10)-(xt - sz, yt - 10), _RGB32(0, 255, 128)
Line (xt + 10 + sz, yt + 10)-(xt + sz, yt - 10), _RGB32(0, 255, 128)
Next sz
If xt > 780 Then xt = 780
'Line (xt + 8, yt - 7)-(xt + 12, yt - 15), _RGB(139, 249, 255), BF
If xt < 0 Then xt = 0
Return
'The start of your shot.
youshoot:
_Limit 1000
'sx2 and sy2 are your shot coordinates.
If ushoot = 0 Then
sx2 = xt
sy2 = yt - 20
ushoot = 1
Sound 400, .5
End If
Return
'The drawing and movement of your shot and if it reaches the enemy.
youshoot2:
_Limit 1000
If ushoot = 1 Then
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
sy2 = sy2 - 3
If sy2 < 0 Then ushoot = 0: Return
For szz = .25 To 5 Step .25
Circle (sx2, sy2), szz, _RGB32(255, 0, 0)
Next szz
If sx2 > x2 - 21 And sx2 < x2 + 41 And sy2 > y2 - 11 And sy2 < y2 + 21 And e1 = 0 And boss = 0 Then
enemy = 1
ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
GoSub redrawshooter:
points = points + 100
e1 = 1
If e1 = 1 And e2 = 1 And e3 = 1 And e4 = 1 Then
level = level + 1
level2 = level2 + 1
e1 = 0: e2 = 0: e3 = 0: e4 = 0
End If
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
ushoot = 0
GoTo go:
End If
If sx2 > x5 - 21 And sx2 < x5 + 41 And sy2 > y5 - 11 And sy2 < y5 + 21 And e2 = 0 And boss = 0 Then
enemy = 2
ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
GoSub redrawshooter:
points = points + 100
e2 = 1
If e1 = 1 And e2 = 1 And e3 = 1 And e4 = 1 Then
level = level + 1
level2 = level2 + 1
e1 = 0: e2 = 0: e3 = 0: e4 = 0
End If
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
ushoot = 0
GoTo go:
End If
If sx2 > x6 - 21 And sx2 < x6 + 41 And sy2 > y6 - 11 And sy2 < y6 + 21 And e3 = 0 And boss = 0 Then
enemy = 3
ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
GoSub redrawshooter:
points = points + 100
e3 = 1
If e1 = 1 And e2 = 1 And e3 = 1 And e4 = 1 Then
level = level + 1
level2 = level2 + 1
e1 = 0: e2 = 0: e3 = 0: e4 = 0
End If
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
ushoot = 0
GoTo go:
End If
If sx2 > x7 - 21 And sx2 < x7 + 41 And sy2 > y7 - 11 And sy2 < y7 + 21 And e4 = 0 And boss = 0 Then
enemy = 5
ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
GoSub redrawshooter:
points = points + 100
e4 = 1
If e1 = 1 And e2 = 1 And e3 = 1 And e4 = 1 Then
level = level + 1
level2 = level2 + 1
e1 = 0: e2 = 0: e3 = 0: e4 = 0
End If
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
ushoot = 0
GoTo go:
End If
'To see if you hit the Boss.
If sx2 > x2 - 21 And sx2 < x2 + 41 And sy2 > y2 - 11 And sy2 < y2 + 21 And e1 = 0 And boss = 1 Then
b = b + 1
BB = 10 - b
If bx = 0 Then GoTo bxx:
bxx:
bx = BB * 10
If bx < 0 Then GoTo bxx2:
bxx2:
Sound 100, 1
points = points + 100
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
For sz = .25 To 5 Step .25
Circle (sx2, sy2), sz, _RGB32(0, 0, 0)
Next sz
If b > 10 Then enemy = 4: ENEMYEXPLOSION sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy
If b < 11 Then ushoot = 0: Return
GoSub redrawshooter:
bx = 0
BB = 0
b = 0
boss = 0
points = points + 1000
level = level + 1
level2 = level2 + 1
e1 = 0: e2 = 0: e3 = 0
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 3 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
ushoot = 0
GoTo go:
End If
End If
Return
redrawshooter:
For sz = .25 To 10 Step .25
Line (xt - 10 - sz, yt + 10)-(xt - sz, yt - 10), _RGB32(0, 255, 128)
Line (xt + 10 + sz, yt + 10)-(xt + sz, yt - 10), _RGB32(0, 255, 128)
Next sz
Return
'The enemy's shot and if it reaches you.
shoot:
_Limit 1000
If shooting = 0 And e1 = 0 Then
GoSub checktoshoot:
sh = Int(Rnd * 10000) + 1
If sh < shh Then GoTo nexone:
'sx and sy are the first enemy shot coordinates.
sx = x2
sy = y2 + 10
shooting = 1
Sound 300, .5
End If
nexone:
If shooting2 = 0 And e2 = 0 Then
GoSub checktoshoot:
sh2 = Int(Rnd * 10000) + 1
If sh2 < shh Then GoTo nexone2:
'sx3 and sy3 are the second enemy shot coordinates.
sx3 = x5
sy3 = y5 + 10
shooting2 = 1
Sound 300, .5
End If
nexone2:
If shooting3 = 0 And e3 = 0 Then
GoSub checktoshoot:
sh3 = Int(Rnd * 10000) + 1
If sh3 < shh Then GoTo nextwo:
'sx4 and sy4 are the third enemy shot coordinates.
sx4 = x6
sy4 = y6 + 10
shooting3 = 1
Sound 300, .5
End If
nextwo:
If shooting4 = 0 And e4 = 0 Then
GoSub checktoshoot:
sh4 = Int(Rnd * 10000) + 1
If sh4 < shh Then GoTo nexone3:
'sx5 and sy5 are the fourth enemy shot coordinates.
sx5 = x7
sy5 = y7 + 10
shooting4 = 1
Sound 300, .5
End If
nexone3:
'To see if first enemy hit you.
If shooting = 1 And e1 = 0 Then
For sz2 = .25 To 5 Step .25
Circle (sx, sy), sz2, _RGB32(0, 0, 0)
Next sz2
sy = sy + 3
If sy > 620 Then shooting = 0: GoTo nex4:
For szz2 = .25 To 5 Step .25
Circle (sx, sy), szz2, _RGB32(255, 0, 0)
Next szz2
If sx > xt - 20 And sx < xt + 20 And sy > yt - 1 And sy < yt + 21 Then
For sz3 = .25 To 5 Step .25
Circle (sx, sy), sz3, _RGB32(0, 0, 0)
Next sz3
shooting = 0
GoSub explosion:
End If
End If
nex4:
'To see if second enemy hit you.
If shooting2 = 1 And e2 = 0 Then
For sz2 = .25 To 5 Step .25
Circle (sx3, sy3), sz2, _RGB32(0, 0, 0)
Next sz2
sy3 = sy3 + 3
If sy3 > 620 Then shooting2 = 0: GoTo nexx:
For szz2 = .25 To 5 Step .25
Circle (sx3, sy3), szz2, _RGB32(255, 0, 0)
Next szz2
If sx3 > xt - 20 And sx3 < xt + 20 And sy3 > yt - 1 And sy3 < yt + 21 Then
For sz3 = .25 To 5 Step .25
Circle (sx3, sy3), sz3, _RGB32(0, 0, 0)
Next sz3
shooting2 = 0
GoSub explosion:
End If
End If
nexx:
'To see if third enemy hit you.
If shooting3 = 1 And e3 = 0 Then
For sz2 = .25 To 5 Step .25
Circle (sx4, sy4), sz2, _RGB32(0, 0, 0)
Next sz2
sy4 = sy4 + 3
If sy4 > 620 Then shooting3 = 0: GoTo nexx2:
For szz2 = .25 To 5 Step .25
Circle (sx4, sy4), szz2, _RGB32(255, 0, 0)
Next szz2
If sx4 > xt - 20 And sx4 < xt + 20 And sy4 > yt - 1 And sy4 < yt + 21 Then
For sz3 = .25 To 5 Step .25
Circle (sx4, sy4), sz3, _RGB32(0, 0, 0)
Next sz3
shooting3 = 0
GoSub explosion:
End If
End If
nexx2:
If shooting4 = 1 And e4 = 0 And boss = 0 Then
For sz2 = .25 To 5 Step .25
Circle (sx5, sy5), sz2, _RGB32(0, 0, 0)
Next sz2
sy5 = sy5 + 3
If sy5 > 620 Then shooting4 = 0: Return
For szz2 = .25 To 5 Step .25
Circle (sx5, sy5), szz2, _RGB32(255, 0, 0)
Next szz2
If sx5 > xt - 20 And sx5 < xt + 20 And sy5 > yt - 1 And sy5 < yt + 21 Then
For sz3 = .25 To 5 Step .25
Circle (sx5, sy5), sz3, _RGB32(0, 0, 0)
Next sz3
shooting4 = 0
GoSub explosion:
End If
End If
Return
explosion:
Randomize Timer
dxx = (Rnd * 6) + -3
dyy = (Rnd * 6) + -3
dxx2 = (Rnd * 6) + -3
dyy2 = (Rnd * 6) + -3
dxx3 = (Rnd * 6) + -3
dyy3 = (Rnd * 6) + -3
dxx4 = (Rnd * 6) + -3
dyy4 = (Rnd * 6) + -3
dxx5 = (Rnd * 6) + -3
dyy5 = (Rnd * 6) + -3
dxx6 = (Rnd * 6) + -3
dyy6 = (Rnd * 6) + -3
Play "mbb8a8"
_AutoDisplay
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
_Delay .05
If DD > 20 Then GoTo goingback
GoTo yourexplosion:
goingback:
DD = 0
Line (xt - 21, yt - 21)-(xt + 41, yt + 41), _RGB32(0, 0, 0), BF
For sz = .25 To 30 Step .5
Circle (xt, yt), sz, _RGB32(0, 0, 0)
Next sz
Line (xt - 10, yt - 15)-(xt + 10, yt), _RGB(0, 0, 0), BF
DD = 0
lives = lives - 1
lives$ = Str$(lives)
points$ = Str$(points)
level$ = Str$(level2)
_Title "Tech Invaders 2 Lives: " + lives$ + " Level: " + level$ + " Score: " + points$
Line (xt - 22, yt - 42)-(xt + 42, yt + 42), _RGB32(0, 0, 0), BF
GoSub redrawshooter:
If lives = 0 Then
Locate 20, 40: Print "G A M E O V E R"
Locate 22, 40: Print "Score: "; points
Locate 23, 40: Print "Level: "; level2
Locate 25, 40: Input "Press Enter to go to Top Ten Scores.", tt$
'Top Ten Scores
scc = points
If _FileExists("toptentech.txt") Then
Else
Open "toptentech.txt" For Output As #1
Restore originaltopten
Do
Read toptenname$, toptenscore!
If toptenname$ = "EOF" Then Exit Do
Print #1, toptenname$
Print #1, toptenscore!
Loop
Close #1
End If
Open "toptentech.txt" For Input As #1
For n = 1 To 10
Input #1, name$(n)
Input #1, score(n)
If scc > score(n) And sct = 0 Then
NN = n
Print "You have made the Top Ten!"
typename:
Input "Type your name here (25 letters and spaces maximum.):", nm$(NN)
If Len(nm$(NN)) > 25 Then
Print "Name too long, try again."
GoTo typename:
End If
sccc(NN) = scc
sct = 1
End If
If n = 10 And sct = 0 Then Close #1: GoTo nex7:
Next n
Close #1
nex5:
Close #1
Open "toptentech.txt" For Output As #1
For n = 1 To NN
If n <> NN Then Print #1, name$(n): Print #1, score(n)
If n = NN Then
Print #1, nm$(n)
Print #1, sccc(n)
End If
Next n
nex6:
For n = NN To 10
Print #1, name$(n): Print #1, score(n)
Next n
Close #1
nex7:
Cls
Print: Print: Print
Print " T O P T E N "
Print: Print: Print
Open "toptentech.txt" For Input As #1
For n = 1 To 10
If EOF(1) Then GoTo nex8:
Input #1, name$(n)
Input #1, score(n)
Print " "; n; ". "; name$(n); score(n)
Next n
nex8:
Close #1
Locate 21: Print "Play Again (Y/N)?"
Do
ag$ = InKey$
If ag$ = "y" Or ag$ = "Y" Then Clear: GoTo begin:
If ag$ = "n" Or ag$ = "N" Then End
Loop
End If
OPENINGSOUND
Return
checktoshoot:
If level2 = 1 Then shh = 9950
If level2 = 2 Then shh = 9945
If level2 = 3 Then shh = 9940
If level2 = 4 Then shh = 9935
If level2 = 5 Then shh = 9930
If level2 = 6 Then shh = 9925
If level2 > 6 Then shh = 9920
Return
originaltopten:
Data Space Ace,7000
Data Suzy Swift,6000
Data Speedy Spencer,5000
Data Super Sam,4000
Data Battery Bob,3000
Data Karen Kryptonite,2750
Data Quick Ken,2500
Data Tiger Tessa,2250
Data Arcade Joe,2000
Data How Do U Play,1750
Data EOF,0
Sub OPENINGSOUND
snd = 300
snd2 = 800
For t = 1 To 50
If snd > 800 Then snd = 300
If snd2 < 300 Then snd2 = 800
snd = snd + 10
Sound snd, .25
Next t
End Sub
Sub ENEMYEXPLOSION (sx2, sy2, x2, y2, sx, sy, x5, y5, sx3, sy3, x6, y6, x7, y7, sx4, sy4, sx5, sy5, enemy)
For sz4 = .25 To 5 Step .25
Circle (sx2, sy2), sz4, _RGB32(0, 0, 0)
Next sz4
Play "mbd16c16b16"
Randomize Timer
dxx = (Rnd * 6) + -3
dyy = (Rnd * 6) + -3
dxx2 = (Rnd * 6) + -3
dyy2 = (Rnd * 6) + -3
dxx3 = (Rnd * 6) + -3
dyy3 = (Rnd * 6) + -3
dxx4 = (Rnd * 6) + -3
dyy4 = (Rnd * 6) + -3
dxx5 = (Rnd * 6) + -3
dyy5 = (Rnd * 6) + -3
dxx6 = (Rnd * 6) + -3
dyy6 = (Rnd * 6) + -3
_AutoDisplay
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
If enemy = 1 Or enemy = 4 Then
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
_Delay .02
If dd > 20 Then GoTo goingback
GoTo explosion1:
goingback:
dd = 0
Line (x2 - 21, y2 - 21)-(x2 + 41, y2 + 41), _RGB32(0, 0, 0), BF
For sz4 = .25 To 5 Step .25
Circle (sx2, sy2), sz4, _RGB32(0, 0, 0)
Next sz4
For sz4 = .25 To 5 Step .25
Circle (sx, sy), sz4, _RGB32(0, 0, 0)
Next sz4
End If
If enemy = 2 Then
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
_Delay .02
If dd > 20 Then GoTo goingback2:
GoTo explosion1:
goingback2:
dd = 0
Line (x5 - 21, y5 - 21)-(x5 + 41, y5 + 41), _RGB32(0, 0, 0), BF
For sz5 = .25 To 5 Step .25
Circle (sx2, sy2), sz5, _RGB32(0, 0, 0)
Next sz5
For sz5 = .25 To 5 Step .25
Circle (sx3, sy3), sz5, _RGB32(0, 0, 0)
Next sz5
End If
If enemy = 3 Then
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
_Delay .02
If dd > 20 Then GoTo goingback3:
GoTo explosion1:
goingback3:
dd = 0
Line (x6 - 21, y6 - 21)-(x6 + 41, y6 + 41), _RGB32(0, 0, 0), BF
For sz5 = .25 To 5 Step .25
Circle (sx2, sy2), sz5, _RGB32(0, 0, 0)
Next sz5
For sz5 = .25 To 5 Step .25
Circle (sx4, sy4), sz5, _RGB32(0, 0, 0)
Next sz5
End If
If enemy = 5 Then
Line (x7 + dxx, y7 + dyy)-(x7 + dxx + 2, y7 + dyy + 2), _RGB32(255, 0, 0), BF
Line (x7 + dxx2, y7 + dyy2)-(x7 + dxx2 + 2, y7 + dyy2 + 2), _RGB32(0, 255, 0), BF
Line (x7 + dxx3, y7 + dyy3)-(x7 + dxx3 + 2, y7 + dyy3 + 2), _RGB32(255, 0, 0), BF
Line (x7 + dxx4, y7 + dyy4)-(x7 + dxx4 + 2, y7 + dyy4 + 2), _RGB32(0, 255, 0), BF
Line (x7 + dxx5, y7 + dyy5)-(x7 + dxx5 + 2, y7 + dyy5 + 2), _RGB32(255, 0, 0), BF
Line (x7 + dxx6, y7 + dyy6)-(x7 + dxx6 + 2, y7 + dyy6 + 2), _RGB32(0, 255, 0), BF
_Delay .02
If dd > 20 Then GoTo goingback4:
GoTo explosion1:
goingback4:
dd = 0
Line (x7 - 21, y7 - 21)-(x7 + 41, y7 + 41), _RGB32(0, 0, 0), BF
For sz5 = .25 To 5 Step .25
Circle (sx2, sy2), sz5, _RGB32(0, 0, 0)
Next sz5
For sz5 = .25 To 5 Step .25
Circle (sx5, sy5), sz5, _RGB32(0, 0, 0)
Next sz5
End If
End Sub
Posts: 176
Threads: 13
Joined: Apr 2022
Reputation:
5
Cool game... Took me a couple of tries to get on the hi-score table...
J
May your journey be free of incident. Live long and prosper.
Posts: 415
Threads: 75
Joined: Apr 2022
Reputation:
22
(06-27-2022, 10:40 AM)johnno56 Wrote: Cool game... Took me a couple of tries to get on the hi-score table...
J
Thanks Johno!!! It's years in the making. I'm thinking about making a 4th version and what it could entail, but we'll see.
|