Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mini Space Invaders
#1
Inspired by Mark (bplus) I decided to come out of retirement to fiddle with this...

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
Reply


Messages In This Thread
Mini Space Invaders - by Pete - 09-11-2025, 08:40 PM
RE: Mini Space Invaders - by Pete - 09-12-2025, 02:03 AM
RE: Mini Space Invaders - by Pete - 09-12-2025, 06:38 AM
RE: Mini Space Invaders - by Pete - 09-12-2025, 09:17 AM
RE: Mini Space Invaders - by Pete - 09-12-2025, 11:20 PM
RE: Mini Space Invaders - by Pete - 09-13-2025, 09:39 PM
RE: Mini Space Invaders - by Pete - 09-18-2025, 07:13 PM
RE: Mini Space Invaders - by Pete - 09-19-2025, 12:01 AM
RE: Mini Space Invaders - by bplus - 09-20-2025, 12:01 AM
RE: Mini Space Invaders - by NakedApe - 09-20-2025, 12:31 AM
RE: Mini Space Invaders - by Pete - 09-20-2025, 07:06 AM
RE: Mini Space Invaders - by bplus - 09-20-2025, 01:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Space Ship Game aadityap0901 4 783 12-26-2024, 02:13 AM
Last Post: bplus
  The Space Globe NakedApe 4 1,052 09-04-2024, 10:49 PM
Last Post: bplus
  In the spirit of Terry's Tutorials - GUARDIAN Alien Space Ship Game Pete 24 4,213 10-18-2022, 05:16 PM
Last Post: Pete
  Space Lander james2464 22 4,122 10-01-2022, 01:23 AM
Last Post: TerryRitchie
  Space(d) Invaders! Cobalt 2 1,017 07-28-2022, 02:24 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)