Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mini Space Invaders
#7
Sometimes to better manage the time to code and run a new routine in an existing project, I'll, instead, just make a separate stand alone routine to test out the effects.

If line 2 works for your system to make the screen larger, you can unremark it. That's right, just like most of my routines, it's unremarkable.

So here's just the saucer part without player interaction. I think it's a nice effect for under 100 lines of code.

Code: (Select All)
Width 60, 20
Rem myfont& = _LoadFont(Environ$("SYSTEMROOT") + "\fonts\lucon.ttf", 21, "MONOSPACE"):_Font myfont&
Dim Obj As String: Obj = "-é-"
lm = 1: rm = _Width: spd = .05
ReDim sbomby(10), sbombx(10)
Locate 7, 20: Print "A A A A A A A A A A A A"
Locate 8, 20: Print "A A A A A A A A A A A A"
Locate 9, 20: Print "A A A A A A A A A A A A"
Locate _Height, _Width \ 2: Print Chr$(234);
Do
    If Abs(z4 - Timer) > .015 Then
        z4 = Timer: If SaucerAttack = 0 Then i = Int(Rnd * 20): If i = 7 Then SaucerAttack = 1
    End If
    If SaucerAttack Then
        If Abs(z - Timer) > spd Then
            saucer Obj, z, lm, rm, xsaucer, sbomb, sbomboff, sbomby(), sbombx(), OffScrn
        End If
        If OffScrn = 1 Then SaucerAttack = 0: xsaucer = -1: OffScrn = -1
    End If
    If sbomb Then SaucerBombs sbomb, sbomboff, sbomby(), sbombx()
Loop

Sub saucer (obj As String, z, lm, rm, xsaucer, sbomb, sbomboff, sbomby(), sbombx(), OffScrn)
    Static way, oldway, nodc
    If sbomboff = 0 And xsaucer = 0 Then ReDim sbomby(10), sbombx(10)
    If xsaucer < 0 Then way = 1: xsaucer = 0: nodc = 0
    If way < 0 Then rebound = 1 Else rebound = 0
    MarqueeLIB obj, lm, rm, way, 3, xsaucer, wrapper, rebound, 1, OffScrn: z = Timer
    Sound 1000, .1, .3, 1: Sound 300, .2, .1, 1, 7
    If nodc < 4 And xsaucer > lm + 5 And xsaucer <= rm - Len(obj) Then
        i = Int(Rnd * 30): If i = 1 Then way = -way
    End If
    If way <> oldway Then oldway = way: nodc = nodc + 1
    If Int(Rnd * 10) = 1 And sbomb < 10 Then
        If xsaucer - way * 2 >= lm And xsaucer - way * 2 <= rm Then
            sbomb = sbomb + 1: sbomboff = sbomboff + 1
            sbomby(sbomb) = 4: sbombx(sbomb) = xsaucer - way * 2
            Locate sbomby(sbomb), sbombx(sbomb)
        End If
    End If
End Sub

Sub SaucerBombs (sbomb, sbomboff, sbomby(), sbombx())
    Static z5
    If Abs(z5 - Timer) > .075 Then
        For i = 1 To sbomb
            If sbomby(i) Then
                If Screen(sbomby(i), sbombx(i)) = 249 Then Locate sbomby(i), sbombx(i): Print " ";
                If sbomby(i) < _Height Then
                    sbomby(i) = sbomby(i) + 1
                    If Screen(sbomby(i), sbombx(i)) = 32 Then Locate sbomby(i), sbombx(i): Print Chr$(249);
                Else
                    If Screen(sbomby(i), sbombx(i)) = 234 Then End
                    sbomboff = sbomboff - 1: sbomby(i) = 0: If sbomboff = 0 Then sbomb = 0
                End If
            End If
        Next
        z5 = Timer
    End If
End Sub

Sub MarqueeLIB (Object As String, LtMargin, RtMargin, way, y, x, wrapper, rebound, AllowOffScrn, OffScrn)
    Static j, k, oldway
    If wrapper Then AllowOffScrn = 0: rebound = 0
    Dim a As String
    If j = 0 Or OffScrn = -1 Then
        j = Len(Object): oldway = 0: oldwrapper = wrapper
        If way = 0 Then way = 1
        If way > 0 Then x = LtMargin Else x = RtMargin
    End If
    If oldway And way <> oldway Then
        If way < 0 Then If x = 1 Or x = 2 Then x = k - (2 - x) Else x = x - j - 1
        If way > 0 Then If x = k Or x = k - 1 Then x = 2 - (k - x) Else x = x + j + 1
    End If
    oldway = way: OffScrn = 0
    k = RtMargin + 1 - LtMargin
    a = Space$(RtMargin + 1 - LtMargin)
    If way > 0 Then
        i = x - j + 1: If i < 1 Then i = 1
        Mid$(a, i) = Mid$(Object, j + 1 - x)
        If wrapper Then If x > k Then Mid$(a, 1) = Mid$(Object, j - (x - 1 - k)) Else Mid$(a, k - Len(Object) + x + 1) = Mid$(Object, 1, Len(Object) - x)
    End If
    If way < 0 Then
        Mid$(a, x) = Mid$(Object, 1)
        If wrapper Then If x < 0 Then Mid$(a, k + x) = Mid$(Object, 1, -x + 1) Else Mid$(a, 1) = Mid$(Object, k + 2 - x)
    End If
    Locate y, LtMargin: Print a;
    If way > 0 Then
        x = x + 1: If x > k + j Then If wrapper Then x = j Else x = LtMargin
    Else
        x = x - 1: If j + x = 1 Then If wrapper Then x = k + 1 - j Else x = k
    End If
    If rebound Then If x = 0 Or x > k Then way = -way
    If AllowOffScrn Then If way > 0 And x = 1 Or way < 0 And x = k Then OffScrn = 1: Locate y, LtMargin: Print Space$(k);
End Sub
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 824 12-26-2024, 02:13 AM
Last Post: bplus
  The Space Globe NakedApe 4 1,079 09-04-2024, 10:49 PM
Last Post: bplus
  In the spirit of Terry's Tutorials - GUARDIAN Alien Space Ship Game Pete 24 4,329 10-18-2022, 05:16 PM
Last Post: Pete
  Space Lander james2464 22 4,222 10-01-2022, 01:23 AM
Last Post: TerryRitchie
  Space(d) Invaders! Cobalt 2 1,034 07-28-2022, 02:24 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)