Here is Charlies cute scrolly ghosts from BAM:
https://basicanywheremachine.neocities.o...s.prod.bas
I modefied this ghost maker into 3subs for drawing ghosts
40 (with double parking) LOC QB64 Game:
I now have this:
The object is to go from bottom of screen to top or vice versa without running into a ghost, 100 points for every trek, see how many points you can rack up before 10 hits.
ie you don't want any ghosts knocking on your door! ;-))
https://basicanywheremachine.neocities.o...s.prod.bas
I modefied this ghost maker into 3subs for drawing ghosts
Code: (Select All)
ghostWidth% = 14
ghostHeight% = 14
ghostBod$ = _
".....XXXX....." + _
"...XXXXXXXX..." + _
"..XXXXXXXXXX.." + _
".XXXXXXXXXXXX." + _
".XXXXXXXXXXXX." + _
".XXXXXXXXXXXX." + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XX.XXX..XXX.XX" + _
"X...XX..XX...X"
ghostEyeballLeft$ = _
".............." + _
".............." + _
".............." + _
"..XX....XX...." + _
".XXXX..XXXX..." + _
"...XX....XX..." + _
"...XX....XX..." + _
"..XX....XX...." + STRING$(6*14,".")
ghostEyeballRight$ = _
".............." + _
".............." + _
".............." + _
"....XX....XX.." + _
"...XXXX..XXXX." + _
"...XX....XX..." + _
"...XX....XX..." + _
"....XX....XX.." + STRING$(6*14,".")
ghostIrisLeft$ = _
".............." + _
".............." + _
".............." + _
".............." + _
".............." + _
".XX....XX....." + _
".XX....XX....." + STRING$(7*14,".")
ghostIrisRight$ = _
".............." + _
".............." + _
".............." + _
".............." + _
".............." + _
".....XX....XX." + _
".....XX....XX." + STRING$(7*14,".")
'??? ??? Main Program ??? ???
SCREEN _NEWIMAGE(300,100,12)
_ALERT("Click/touch the screen to pause the program.")
loopCount% = 1
➔another_ghost:
IF loopCount% MOD 3 = 0 THEN _
?PrintGhost( _
INT(RND*(100)), _
INT(RND*(_HEIGHT-ghostHeight%)) )
_DELAY 0.025
IF _MOUSEBUTTON THEN WHILE _MOUSEBUTTON : WEND
SCROLL 1,0,FALSE
loopCount% += 1
GOTO ➔another_ghost
END
'??? Subroutines ???
SUB ?PrintGhost(x%,y%)
bodyColor% = INT(RND*14)+1
eyeDirection% = INT(RND*2)
ghostEyeball$ = IFF(eyeDirection%,ghostEyeballLeft$,ghostEyeballRight$)
ghostIris$ = IFF(eyeDirection%,ghostIrisLeft$,ghostIrisRight$)
irisColor% = IFF(INT(RND*2), 1, 6)
FOR thisY = 1 TO ghostHeight%
FOR thisX = 1 TO ghostWidth%
IF MID$(ghostBod$, (thisY-1) * ghostWidth% + thisX, 1) <> "." THEN PSET (x% + thisX - 1, y% + thisY - 1), bodyColor%
IF MID$(ghostEyeball$, (thisY-1) * ghostWidth% + thisX, 1) <> "." THEN PSET (x% + thisX - 1, y% + thisY - 1), 15
IF MID$(ghostIris$, (thisY-1) * ghostWidth% + thisX, 1) <> "." THEN PSET (x% + thisX - 1, y% + thisY - 1), irisColor%
NEXT thisX
NEXT thisY
END SUB
40 (with double parking) LOC QB64 Game:
Code: (Select All)
_Title "40 Line Game Revised" 'b+ mod of some game 2022-03-18 new way to score
Dim As Long sw, sh, goalR, hx, hy, i, hits, score, stars, nEnemies
sw = 640: sh = 480: nEnemies = 35: goalR = -1: hx = 10: hy = 400 ' hero stuff (you)
Dim EX(nEnemies), EY(nEnemies), EC(nEnemies) As _Unsigned Long ' enemy stuff
Screen _NewImage(sw, sh, 32): stars = _NewImage(sw, sh, 32)
For i = 1 To 1000
PSet (Int(Rnd * sw), Int(Rnd * sh)), _RGB32(55 + Rnd * 200, 55 + Rnd * 200, 55 + Rnd * 200)
Next
_PutImage , 0, stars
For i = 1 To nEnemies
EX(i) = Int(Rnd * (sw - 20) + 10): EY(i) = -2 * sh * Rnd + sh: EC(i) = _RGB32(55 + Rnd * 200, 55 + Rnd * 200, 55 + Rnd * 200)
Next
Do
Cls
_PutImage , stars, 0
Print "Hits:"; hits, "Score:"; score
Line (hx - 10, hy - 10)-Step(20, 20), &HFFFFFF00, BF
If hx >= sw - 13 And goalR Then score = score + 100: goalR = 0
If hx <= 13 And goalR = 0 Then score = score + 100: goalR = -1
For i = 1 To nEnemies ' the enemies
Circle (EX(i), EY(i)), 10, EC(i)
If Sqr((EX(i) - hx) ^ 2 + (EY(i) - hy) ^ 2) < 20 Then 'collision
Sound 2000, 3: hits = hits + 1
EX(i) = Int(Rnd * 600 + 20): EY(i) = -_Height * Rnd ' move that bad boy!
If hits = 10 Then Print "Too many hits, goodbye!": _Delay 10
End If
EY(i) = EY(i) + Int(Rnd * 5)
If EY(i) > 470 Then EX(i) = Int(Rnd * 600 + 20): EY(i) = -sh * Rnd
Next
If _KeyDown(20480) Then hy = hy + 3
If _KeyDown(18432) Then hy = hy - 3
If _KeyDown(19200) Then hx = hx - 3
If _KeyDown(19712) Then hx = hx + 3
If hx < 10 Then hx = 10
If hx > sw - 10 Then hx = sw - 10
If hy < 10 Then hy = 10
If hy > sh - 10 Then hy = sh - 10
_Display
_Limit 60
Loop Until _KeyDown(27)
I now have this:
Code: (Select All)
Option _Explicit
_Title "Charlies Ghost plus 40 LOC Game" ' bplus confab mod 2023-11-02
'_Title "40 Line Game Revised" 'b+ mod of some game 2022-03-18 new way to score
Dim Shared As Long SW, SH ' screen width and height
SW = 640: SH = 640
'for setup and drawing ghosts, run SetupGhost once
Dim Shared gWidth%, gHeight%, gBod$, ghostEyeballLeft$, ghostEyeballRight$, ghostIrisLeft$, ghostIrisRight$
SetupGhost
' for creating new ghosts x, y, color, eye direction, eye color
Dim Shared As Long NGhosts
NGhosts = 15
Dim Shared As Long GX(1 To NGhosts), GY(1 To NGhosts), GED(1 To NGhosts), GDIR(1 To NGhosts)
Dim Shared As _Unsigned Long GBC(1 To NGhosts), GIC(1 To NGhosts)
Dim As Long goalR, hx, hy, i, hits, score, stars
Dim rr
goalR = -1
hx = SW / 2 - 14: hy = 28 ' hero stuff (you)
For i = 1 To NGhosts
NewGhost (i), 0
Next
Screen _NewImage(SW, SH, 32): stars = _NewImage(SW, SH, 32)
Randomize Timer
' test debug drawing ghosts , way too small double width and triple height
'For i = 1 To NGhosts
' Cls
' DrawGhost 320 - 14, 240 - 28, GBC(i), GED(i), GIC(i) ' ghosts are 28 x 56
' Sleep
'Next
'End
'setup stars ?
For i = 1 To 1000
PSet (Int(Rnd * SW), Int(Rnd * SH)), _RGB32(55 + Rnd * 200, 55 + Rnd * 200, 55 + Rnd * 200)
Next
_PutImage , 0, stars
Do
Cls
_PutImage , stars, 0
Print "Hits:"; hits, "Score:"; score
Line (hx - 14, hy - 26)-Step(28, 52), &HFFFFAA77, BF
'door
Line (hx - 10, hy - 22)-(hx - 2, hy - 2), &HFFCC6633, BF
Line (hx + 2, hy - 22)-(hx + 10, hy - 2), &HFFCC6633, BF
Line (hx - 10, hy + 2)-(hx + 10, hy + 22), &HFFCC6633, BF
For rr = 0 To 2 Step .25
Circle (hx + 12, hy), rr, _RGB32(255 - rr * 125, 255 - rr * 125, 255 - rr * 125)
Next
'score the door
If hy >= SH - 28 And goalR Then score = score + 100: goalR = 0
If hy <= 28 And goalR = 0 Then score = score + 100: goalR = -1
For i = 1 To NGhosts ' the enemies
If Rnd < .025 Then
If GED(i) Then GED(i) = 0 Else GED(i) = 1
End If
DrawGhost GX(i) - 14, GY(i) - 26, GBC(i), GED(i), GIC(i)
If Abs(GX(i) - hx) < 28 And Abs(GY(i) - hy) < 56 Then 'collision
Sound 38, 5, , , 2
hits = hits + 1
NewGhost i, 1 ' move that bad boy!
If hits = 10 Then
Print "Too many hits, goodbye!"
_Display
_Delay 10
End
End If
End If
GX(i) = GX(i) + GDIR(i) * Int(Rnd * 5)
If (GX(i) > SW + 14 And GDIR(i) > 0) Or (GX(i) < -14 And GDIR(i) < 0) Then
NewGhost i, 1
End If
Next
If _KeyDown(20480) Then hy = hy + 3
If _KeyDown(18432) Then hy = hy - 3
If _KeyDown(19200) Then hx = hx - 3
If _KeyDown(19712) Then hx = hx + 3
If hx < 14 Then hx = 14
If hx > SW - 14 Then hx = SW - 14
If hy < 26 Then hy = 26
If hy > SH - 26 Then hy = SH - 26
_Display
_Limit 60
Loop Until _KeyDown(27)
Sub NewGhost (i As Long, beyondScreenTF As Long)
' a ghost needs a starting place leave safe zone on either edge
If Rnd < .5 Then GDIR(i) = -1 Else GDIR(i) = 1
If beyondScreenTF Then
If GDIR(i) > 0 Then
GX(i) = -SW * Rnd - 14
Else
GX(i) = SW + SW * Rnd + 14
End If
Else
GX(i) = SW * Rnd
End If
GY(i) = 56 + 28 + Int((SH - 3 * 56) * Rnd)
' a ghost needs a body color
GBC(i) = _RGB32(155 + Rnd * 100, 155 + Rnd * 100, 155 + Rnd * 100, 80)
' a ghost needs an eyedirection
GED(i) = Int(Rnd * 2)
' a ghost needs an iris color
If Int(Rnd * 2) Then GIC~&(i) = _RGB32(255, 0, 0) Else GIC~&(i) = _RGB32(0, 0, 255)
End Sub
Sub DrawGhost (x%, y%, ghostBodyC~&, EyeDir%, IrisC~&) ' make ghost 28 x 56
Dim gEyeBall$, gIris$
Dim As Long yy, xx
'gEyeball$ = IFF(EyeDir%,ghostEyeballLeft$,ghostEyeballRight$)
If EyeDir% Then gEyeBall$ = ghostEyeballLeft$ Else gEyeBall$ = ghostEyeballRight$
'gIris$ = IFF(EyeDir%,ghostIrisLeft$,ghostIrisRight$)
If EyeDir% Then gIris$ = ghostIrisLeft$ Else gIris$ = ghostIrisRight$
'irisC~& = IFF(Int(Rnd * 2), 1, 6)
For yy = 1 To gHeight%
For xx = 1 To gWidth%
If Mid$(gBod$, (yy - 1) * gWidth% + xx, 1) <> "." Then
'PSet (x% + XX - 1, y% + YY - 1), bodyC~&
Line (x% + (xx - 1) * 2, y% + (yy - 1) * 4)-Step(1, 3), ghostBodyC~&, BF
End If
If Mid$(gEyeBall$, (yy - 1) * gWidth% + xx, 1) <> "." Then
'PSet (x% + XX - 1, y% + YY - 1), _RGB32(255, 255, 255)
Line (x% + (xx - 1) * 2, y% + (yy - 1) * 3)-Step(1, 2), _RGB32(255, 255, 255), BF
End If
If Mid$(gIris$, (yy - 1) * gWidth% + xx, 1) <> "." Then
'PSet (x% + XX - 1, y% + YY - 1), IrisC~&
Line (x% + (xx - 1) * 2, y% + (yy - 1) * 3)-Step(1, 2), IrisC~&, BF
End If
Next xx
Next yy
End Sub
Sub SetupGhost
' setup shared variables in main, this sub sets the values for them
'dim shared gWidth%, gHeight%, gBod$, ghostEyeballLeft$, ghostEyeballRight$, ghostIrisLeft$, ghostIrisRight$
gWidth% = 14
gHeight% = 14
gBod$ = _
".....XXXX....." + _
"...XXXXXXXX..." + _
"..XXXXXXXXXX.." + _
".XXXXXXXXXXXX." + _
".XXXXXXXXXXXX." + _
".XXXXXXXXXXXX." + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XXXXXXXXXXXXXX" + _
"XX.XXX..XXX.XX" + _
"X...XX..XX...X"
ghostEyeballLeft$ = _
".............." + _
".............." + _
".............." + _
"..XX....XX...." + _
".XXXX..XXXX..." + _
"...XX....XX..." + _
"...XX....XX..." + _
"..XX....XX...." + STRING$(6*14,".")
ghostEyeballRight$ = _
".............." + _
".............." + _
".............." + _
"....XX....XX.." + _
"...XXXX..XXXX." + _
"...XX....XX..." + _
"...XX....XX..." + _
"....XX....XX.." + STRING$(6*14,".")
ghostIrisLeft$ = _
".............." + _
".............." + _
".............." + _
".............." + _
".............." + _
".XX....XX....." + _
".XX....XX....." + STRING$(7*14,".")
ghostIrisRight$ = _
".............." + _
".............." + _
".............." + _
".............." + _
".............." + _
".....XX....XX." + _
".....XX....XX." + STRING$(7*14,".")
End Sub
The object is to go from bottom of screen to top or vice versa without running into a ghost, 100 points for every trek, see how many points you can rack up before 10 hits.
ie you don't want any ghosts knocking on your door! ;-))
b = b + ...