09-11-2025, 08:40 PM
Inspired by Mark (bplus) I decided to come out of retirement to fiddle with this...
It's beatable, but it's not easy!
Tap lt/rt arrow keys repeatedly to move. Holding down keys is death!
Press space bar to fire. Another missile is ready when previous missile either hits a target or vanishes. Missiles vanish when they are past the uppermost line of ships.
It has some good points and bad point like it is scalable but if you messed a lot with the repeat rates, you'd see that the structure is dependent on the timing of events. It could be made better if events were totally independent. Also, for a bigger version, it would be better to have subroutines for the aliens, base, missiles, and scoring.
Pete
Code: (Select All)
_Title "Pete's Mini Space Invaders"
Width 40, 20: _Font 16: bit = 1: TopRow = 4: a$ = "A A A A A A A A A A A A": For i = 0 To 4: a$(i) = a$: Next
trail = _Width \ 2 - Len(a$) \ 2: ms = .05: lag = .35: xbase = _Width \ 2: RowHeight = 5: terminate = _Height
Do
Cls: Locate 1, 1: Print " Altitude ="; _Height * 1000 - (TopRow - 1 + RowHeight) * 1000; " Score ="; Score;
Locate _Height, xbase: Print Chr$(234);: z1 = Timer: zenith = 0
For i = 0 To RowHeight - 1
Locate TopRow + i, trail + l: Print RTrim$(Mid$(a$(i), l + 1));
If Len(LTrim$(a$(i))) And zenith = 0 Then zenith = TopRow + i
Next
Sound 500, .1
Do
If yfire Then
If Abs(z2 - Timer) > ms Then
z2 = Timer
If Screen(yfire, xfire) = 24 Then Locate yfire, xfire: Print " ";: yfire = yfire - 1
If Screen(yfire, xfire) = 65 Then
RowCheck = 0: l = 0: r = 0: Score = Score + 2500
Mid$(a$(yfire - TopRow), xfire - trail + 1, 1) = " ": Sound 1000, .5: yfire = 0
For i = 4 To 0 Step -1
If Len(LTrim$(a$(i))) And RowCheck = 0 Then RowHeight = i + 1: RowCheck = 1
If Len(RTrim$(a$(i))) > r Then r = Len(RTrim$(a$(i)))
If Len(LTrim$(a$(i))) > l Then l = Len(LTrim$(a$(i)))
Next
r = Len(a$) - r: l = Len(a$) - l
Else
If yfire < zenith Then yfire = 0 Else Locate yfire, xfire: Print Chr$(24);
End If
End If
End If
Select Case _KeyHit
Case 19200
If xbase > 1 And restrict = 0 Then xbase = xbase - 1: restrict = 1
Case 19712
If xbase < _Width And restrict = 0 Then xbase = xbase + 1: restrict = 1
Case -19200, -19712
restrict = 0: _KeyClear
Case 32
If yfire = 0 Then yfire = _Height: xfire = xbase
End Select
If Abs(z1 - Timer) > lag Then z1 = Timer: Exit Do
Loop
If LTrim$(a$(0) + a$(1) + a$(2) + a$(3) + a$(4)) = "" Then
View Print 1 To _Height - 1: Cls 2: Print " Altitude ="; _Height * 1000 - (TopRow - 1 + RowHeight) * 1000; " Score ="; Score;
Locate 3, 2: Print "GAME OVER - YOU WON!": _Delay 5: Exit Do
End If
If TopRow - 1 + RowHeight = terminate Then Locate 3, 2: Print "GAME OVER - YOU LOST!": _Delay 5: Exit Do
If trail + Len(a$) - r > _Width And bit = 1 Or trail = 1 - l And bit = -1 Then
bit = -bit: TopRow = TopRow + 1: lag = lag - .02
If lag < .1 Then lag = .1: ms = .025
Else
trail = trail + bit
End If
Loop
It's beatable, but it's not easy!
Tap lt/rt arrow keys repeatedly to move. Holding down keys is death!
Press space bar to fire. Another missile is ready when previous missile either hits a target or vanishes. Missiles vanish when they are past the uppermost line of ships.
It has some good points and bad point like it is scalable but if you messed a lot with the repeat rates, you'd see that the structure is dependent on the timing of events. It could be made better if events were totally independent. Also, for a bigger version, it would be better to have subroutines for the aliens, base, missiles, and scoring.
Pete

