Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mini Space Invaders
#9
+1 Man you really got into this! Hopefully your personal attention and interest is worth more than a point. 

There is a point where a graphics screen starts to make sense for making enhancements, maybe 150-200 LOC even for old dogs that dont like learning new tricks. Smile


Here take my spaceship out for a spin:
Code: (Select All)
Screen _NewImage(1024, 700, 32)
_Delay .25
_ScreenMove _Middle

Dim sc As _Unsigned Long ' ship color
sc = _RGB32(Rnd * 215 + 40, Rnd * 255, Rnd * 255)
_MouseHide
Do
    Cls
    lc = lc + 1 'loop counter
    If lc > 3 * 60 Then sc = _RGB32(Rnd * 215 + 40, Rnd * 255, Rnd * 255): lc = 0 'every 3 secs change ship color
    While _MouseInput: Wend
    drawShip _MouseX, _MouseY, sc ' here is how to call drawShip   easier than using circle
    'drawShip _WIDTH / 2, _HEIGHT / 2, sc
    _Display
    _Limit 60
Loop Until _KeyDown(27)

Sub drawShip (x, y, colr As _Unsigned Long) 'shipType     collisions same as circle x, y radius = 30
    Static ls
    Dim light As Long, r As Long, g As Long, b As Long
    r = _Red32(colr): g = _Green32(colr): b = _Blue32(colr)
    fellipse x, y, 6, 15, _RGB32(r, g - 120, b - 100)
    fellipse x, y, 18, 11, _RGB32(r, g - 60, b - 50)
    fellipse x, y, 30, 7, _RGB32(r, g, b)
    For light = 0 To 5
        fcirc x - 30 + 11 * light + ls, y, 1, _RGB32(ls * 50, ls * 50, ls * 50)
    Next
    ls = ls + 1
    If ls > 5 Then ls = 0
End Sub


' ======== helper subs for drawShip that you can use for other things specially fcirc = fill_circle  x, y, radius, color

Sub fellipse (CX As Long, CY As Long, xr As Long, yr As Long, C As _Unsigned Long)
    If xr = 0 Or yr = 0 Then Exit Sub
    Dim h2 As _Integer64, w2 As _Integer64, h2w2 As _Integer64
    Dim x As Long, y As Long
    w2 = xr * xr: h2 = yr * yr: h2w2 = h2 * w2
    Line (CX - xr, CY)-(CX + xr, CY), C, BF
    Do While y < yr
        y = y + 1
        x = Sqr((h2w2 - y * y * w2) \ h2)
        Line (CX - x, CY + y)-(CX + x, CY + y), C, BF
        Line (CX - x, CY - y)-(CX + x, CY - y), C, BF
    Loop
End Sub

Sub fcirc (x As Long, y As Long, R As Long, C As _Unsigned Long) 'vince version  fill circle x, y, radius, color
    Dim x0 As Long, y0 As Long, e As Long
    x0 = R: y0 = 0: e = 0
    Do While y0 < x0
        If e <= 0 Then
            y0 = y0 + 1
            Line (x - x0, y + y0)-(x + x0, y + y0), C, BF
            Line (x - x0, y - y0)-(x + x0, y - y0), C, BF
            e = e + 2 * y0
        Else
            Line (x - y0, y - x0)-(x + y0, y - x0), C, BF
            Line (x - y0, y + x0)-(x + y0, y + x0), C, BF
            x0 = x0 - 1: e = e - 2 * x0
        End If
    Loop
    Line (x - R, y)-(x + R, y), C, BF
End Sub
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
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 823 12-26-2024, 02:13 AM
Last Post: bplus
  The Space Globe NakedApe 4 1,078 09-04-2024, 10:49 PM
Last Post: bplus
  In the spirit of Terry's Tutorials - GUARDIAN Alien Space Ship Game Pete 24 4,304 10-18-2022, 05:16 PM
Last Post: Pete
  Space Lander james2464 22 4,196 10-01-2022, 01:23 AM
Last Post: TerryRitchie
  Space(d) Invaders! Cobalt 2 1,033 07-28-2022, 02:24 AM
Last Post: madscijr

Forum Jump:


Users browsing this thread: 1 Guest(s)