You want the aliens to shoot back. Okay, here you go...
Edit: Made two small optimizations and added red color to ship that drops a bomb.
Code: (Select All)
_Title "Pete's Mini Space Invaders"
Width 40, 20: _Font 16
Type invaders
Direction As Integer
TopRow As Integer
RowHeight As Integer
BaseLine As Integer
TrailColumn As Integer
MissileSpeed As Single
AlienSpeed As Single
HomeBase As Integer
BaseAction As Integer
TrailRow As Integer
LtColReduce As Integer
RtColReduce As Integer
z1 As Single
z2 As Single
z3 As Single
yfire As Integer
xfire As Integer
ybomb As Integer
xbomb As Integer
Outcome As Integer
Score As _Integer64
Array As String
End Type
Dim si As invaders
si.Array = "A A A A A A A A A A A A": For i = 0 To 4: a$(i) = si.Array: Next
si.Direction = 1
si.TopRow = 4
si.RowHeight = 5
si.BaseLine = _Height
si.TrailColumn = _Width \ 2 - Len(si.Array) \ 2
si.MissileSpeed = .04
si.AlienSpeed = .375
si.HomeBase = _Width \ 2
Refresh si, a$(): _Delay 1
Do
ScoreKeeper si
If si.yfire <> 0 And Abs(si.z2 - Timer) > si.MissileSpeed Then MissileAction si, a$()
If si.Outcome = 0 Then
KeyBoard si
If Abs(si.z1 - Timer) > si.AlienSpeed Then MoveAliens si, a$()
If Abs(si.z3 - Timer) > 1 Or si.ybomb And Abs(si.z3 - Timer) > .15 Then AlienBomb si, a$()
If si.BaseAction Then BaseAction si
Else
Finish si, a$()
End If
Loop
Sub ScoreKeeper (si As invaders)
info$ = Space$(_Width)
x$ = " Altitude:" + Str$(_Height * 1000 - (si.TopRow - 1 + si.RowHeight) * 1000) + " Ft Score:" + Str$(si.Score)
i = _Width / 2 - Len(x$) / 2
Mid$(info$, i) = x$
Locate 1, 1: Print info$;
End Sub
Sub KeyBoard (si As invaders)
Static restrict
Select Case _KeyHit
Case 19200: If si.HomeBase > 1 And restrict = 0 Then si.HomeBase = si.HomeBase - 1: restrict = 1: si.BaseAction = -1
Case 19712: If si.HomeBase < _Width And restrict = 0 Then si.HomeBase = si.HomeBase + 1: restrict = 1: si.BaseAction = -1
Case -19200, -19712: restrict = 0: _KeyClear: si.BaseAction = 0
Case 32: If si.yfire = 0 Then si.BaseAction = 1
End Select
End Sub
Sub MissileAction (si As invaders, a$())
si.z2 = Timer
If Screen(si.yfire, si.xfire) = 24 Then Locate si.yfire, si.xfire: Print " ";
si.yfire = si.yfire - 1
If Screen(si.yfire, si.xfire) = 65 Then
RowCheck = 0: si.LtColReduce = 0: si.RtColReduce = 0: si.Score = si.Score + 2500
Locate si.yfire, si.xfire: Print Chr$(15);: _Delay .1: Locate si.yfire, si.xfire: Print " ";
Mid$(a$(si.yfire - si.TopRow), si.xfire - si.TrailColumn + 1, 1) = " ": si.yfire = 0: Sound 1000, .5
For i = 4 To 0 Step -1
If Len(LTrim$(a$(i))) And RowCheck = 0 Then si.RowHeight = i + 1: RowCheck = 1
If Len(RTrim$(a$(i))) > si.RtColReduce Then si.RtColReduce = Len(RTrim$(a$(i)))
If Len(LTrim$(a$(i))) > si.LtColReduce Then si.LtColReduce = Len(LTrim$(a$(i)))
Next
si.RtColReduce = Len(si.Array) - si.RtColReduce: si.LtColReduce = Len(si.Array) - si.LtColReduce
If LTrim$(a$(0) + a$(1) + a$(2) + a$(3) + a$(4)) = "" Then si.Outcome = 1 Else Refresh si, a$()
Else
If si.yfire < si.TrailRow Then si.yfire = 0 Else Locate si.yfire, si.xfire: Print Chr$(24);
End If
End Sub
Sub MoveAliens (si As invaders, a$())
si.z1 = Timer
If si.TopRow - 1 + si.RowHeight = si.BaseLine Then
si.Outcome = -1: si.HomeBase = 0
Else
If si.TrailColumn + Len(si.Array) - si.RtColReduce > _Width And si.Direction = 1 Or si.TrailColumn = 1 - si.LtColReduce And si.Direction = -1 Then
si.Direction = -si.Direction: si.TopRow = si.TopRow + 1: si.AlienSpeed = si.AlienSpeed - .0225
If si.AlienSpeed < .1 Then si.AlienSpeed = .1: si.MissileSpeed = .025
Else
si.TrailColumn = si.TrailColumn + si.Direction
End If
End If
Refresh si, a$()
Sound 500, .1
End Sub
Sub AlienBomb (si As invaders, a$())
si.z3 = Timer
If si.TopRow + si.RowHeight < _Height - 3 Then
If si.ybomb = 0 Then ' Designate alien ship.
i = si.RowHeight - 1
k = Int(Rnd * (Len(si.Array) \ 2 + 1)) * 2 + 1
Do
For j = 1 To Len(si.Array)
If Mid$(a$(i), k, 1) = "A" Then
g = k: row = i: Exit Do
Else
For h = i To 0 Step -1
If Mid$(a$(h), k, 1) = "A" Then g = k: row = h: Exit Do
Next
End If
k = k + 2: If k > Len(a$(i)) Then k = 1
Next
Exit Do
Loop
si.ybomb = row + si.TopRow + 1
si.xbomb = si.TrailColumn - 1 + g
Locate si.ybomb - 1, si.xbomb: Color 4: Print "A";: Color 7: Sound 200, 1
Else
Locate si.ybomb, si.xbomb: Print " ";
If si.ybomb = _Height Then
si.ybomb = 0
Else
si.ybomb = si.ybomb + 1
If Screen(si.ybomb, si.xbomb) = 234 Then
Locate si.ybomb, si.xbomb: Color 4, 0: Print Chr$(236);: _Delay .15: Color 7, 0
Locate si.ybomb, si.xbomb
si.Outcome = -2
Else
Locate si.ybomb, si.xbomb: Print Chr$(249);
End If
End If
End If
End If
End Sub
Sub Refresh (si As invaders, a$())
View Print si.TopRow - 1 To si.TopRow + si.RowHeight - 1: si.TrailRow = 0: Cls 2
For i = 0 To si.RowHeight - 1
Locate si.TopRow + i, si.TrailColumn + si.LtColReduce
Print RTrim$(Mid$(a$(i), si.LtColReduce + 1));
If Len(LTrim$(a$(i))) And si.TrailRow = 0 Then si.TrailRow = si.TopRow + i
Next
View Print
If si.HomeBase Then Locate _Height, si.HomeBase: Print Chr$(234);
End Sub
Sub BaseAction (si As invaders)
Select Case si.BaseAction
Case -1
Locate _Height, 1: Print Space$(_Width);
Locate _Height, si.HomeBase: Print Chr$(234);
Case 1
si.yfire = _Height: si.xfire = si.HomeBase
End Select
si.BaseAction = 0
End Sub
Sub AlienBlitz (si As invaders, a$())
Cls: si.HomeBase = 0
ScoreKeeper si
Do
si.TopRow = si.TopRow + 1
Refresh si, a$()
Sound 500, .1: _Delay .1
Loop Until si.TopRow + si.RowHeight > _Height
Sound 200, 1
End Sub
Sub Finish (si As invaders, a$())
ScoreKeeper si
x$ = "GAME OVER - "
Select Case si.Outcome
Case -1: x$ = x$ + "YOU LOST!"
Case -2: x$ = x$ + "YOU LOST!": AlienBlitz si, a$()
Case 1: x$ = "YOU WON!"
End Select
Locate 3, _Width / 2 - Len(x$) / 2: Print x$;
x$ = "Replay? Y/N": Locate 5, _Width / 2 - Len(x$) / 2: Print x$;
Do
_Limit 10
b$ = InKey$
Select Case UCase$(b$)
Case "Y", Chr$(13): Cls: Run
Case "N", Chr$(27)
_Delay .5: x$ = "Bye!"
Locate 7, _Width / 2 - Len(x$) / 2
Print x$;: _Delay 1.5: System
End Select
Loop
End Sub
Edit: Made two small optimizations and added red color to ship that drops a bomb.

