09-09-2025, 05:19 PM
Code: (Select All)
_Title "b+ Space Invaders" ' mod of one found at LB
Screen _NewImage(256, 320, 32) ' 32 x 20 chars
_ScreenMove 500, 150
Do
ReDim A$(4)
For i = 0 To 4
A$(i) = "A A A A A A A A " ' len = 16 so make field 32 wide 0 31
Next
sy = 19 'ship y
sx = 14 'ship x ship is 1 chars wide so mx starts at sx + 1, my sy - 1 sx max = 31
ax = 0 'left of alien hoard
ay = 0 'top left of alien hoard
adx = 1
by = ay + 6
bx = ax + Int(Rnd * 16)
my = -1
Do
Cls 'draw everything
For i = 0 To 4 'field of A's alien hoard
_PrintString (ax * 8, (ay + i) * 16), A$(i)
Next
_PrintString (bx * 8, by * 16), "o"
If my >= 0 Then _PrintString (mx * 8, my * 16), "*"
_PrintString (sx * 8, sy * 16), "/I\" 'the ship / cannon
For i = 0 To 4 'field of A's alien hoard
If i + ay = my Then
For j = 1 To Len(A$(i))
If ax + j - 1 = mx And Mid$(A$(i), j, 1) = "A" Then Mid$(A$(i), j, 1) = " ": my = -1
Next
End If
Next
If ((bx >= sx And bx <= sx + 2) And by = sy) Or (ay + 4 = 19) Then Beep: Exit Do ' blew up ship ' did bomb take out cannon or hoard reach ground
ax = ax + adx 'update hoard
If ax < 0 Then
ay = ay + 1: adx = 1: ax = 0
ElseIf ax + 16 > 31 Then 'run it back on same line to slow down the crush
adx = -1: ax = 15
End If
by = by + 1 'alien bomb
If by > 19 Then 'new bomb
by = ay + 5
bx = ax + Int(Rnd * 16)
End If
If my >= 0 Then my = my - 1 'update bullet ' missile
If my < ay Then my = -1 ' deactivate after passed horde
While _MouseInput: Wend
sx = Int((_MouseX - 8) / 8)
k$ = InKey$
If k$ = " " Then
If my < ay Then mx = sx + 1: my = sy - 1 ' fire cannon if last missile has past the hoard
End If
_Display
_Limit 5
Loop
Sleep
Loop Until _KeyDown(27)
' 2020-11-13 tiny space invaders b+ 2020-11-14
' ========================= Instructions ===================
' mouse to move ship/cannon left and right
' spacebar to fire cannon
'===========================================================It kinda works might be simplified a bit... Anti-Unseen Machine style no libraries and no special directories LOL!
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever

