Stunt Jumper - mnrvovrfc - 07-17-2023
Here's yet another silly game that I remembered from one of David L. Heiserman's books. But it's "customized" to my taste and knowledge of BASIC programming LOL. In this game you play a stunt paratrooper jumping out of a plane trying to evade buildings. The game should be straightforward, giving instructions on the screen. Either you jump or you don't, and if you jump don't go "splat" into a building and don't go off a side of the screen! The plane does a "loop" back to the beginning so it could wrap around the screen but the stunt paratrooper can't!
There is a peculiar RANDOMIZE statement, allowing a player to "practice" this program.
I should allocate some time for sound effects for this program. The original program had a quirk about the protagonist but didn't care how he/she was called. In fact I programmed another quirk before deciding to submit this, heh heh.
Code: (Select All)
'by mnrvovrfc 17-July-2023
option _explicit
dim nm$(1 to 7), histogram(1 to 80) as integer
dim as integer i, j, h, v, w, z, numtiles, numthalf, thresh
dim as integer x, y, px, py, fuel, recede, planecolor
dim ke$, handl$, jumped as _bit, die as integer
nm$(1) = "murderflower"
nm$(2) = "jumpdaplain"
nm$(3) = "sinusister"
nm$(4) = "quakefear"
nm$(5) = "adrenald"
nm$(6) = "houston"
nm$(7) = "rebare"
print "Welcome to Stunt Paratrooper!"
print: print "Please choose who do you want to be. Press any number key from [1] to [7]."
for i = 1 to 7
print "("; _trim$(str$(i)); ") "; nm$(i)
next
do
do : ke$ = inkey$ : loop while ke$ = ""
if ke$ = chr$(27) then end
v = val(ke$)
loop until v > 0 and v < 8
handl$ = nm$(v)
v = ubound(nm$) - v + 4
randomize v + 100
numtiles = 200
numthalf = numtiles \ 2
thresh = 5
cls
for i = 1 to numthalf
j = Random1(80)
histogram(j) = histogram(j) + 1
next
h = 0
for i = 1 to 80
if histogram(i) > h then h = histogram(i)
next
for i = 1 to numthalf
do
j = Random1(80)
loop until abs(histogram(j) - h) <= thresh
histogram(j) = histogram(j) + 1
next
h = 0
for i = 1 to 80
if histogram(i) > h then
h = histogram(i)
w = i
end if
if histogram(i) = 0 then histogram(i) = 1
next
if w = 80 then
z = 80
w = 78
else
z = w + 2
end if
histogram(w + 1) = 0
color 6
locate 25, 1 : print string$(79, 46);
locate 24, 1 : print string$(80, 46);
color 8
for i = 1 to 80
y = 24
for j = histogram(i) to 1 step -1
locate y, i
print chr$(177);
y = y - 1
if y < 10 then exit for
next
next
color 4
locate 1, 1 : print handl$;
color 3
print " you have to hit the grass between those buildings! Good luck!"
color 5
locate 2, 1 : print "Press [ESC] to quit. Press spacebar to jump out of plane."
fuel = 6
recede = fuel - 1
jumped = 0
x = 1
y = 5
planecolor = 7
do : ke$ = inkey$ : loop until ke$ = ""
do
color planecolor
locate y, x : print "|_^";
for i = 1 to 10
_delay 0.05
ke$ = inkey$
if ke$ <> "" then
if ke$ = chr$(27) then system
if ke$ = chr$(32) then
jumped = 1
exit for
end if
end if
next
locate y, x : print space$(3);
x = x + 1
if x > 78 then
x = 1
if y < 8 then y = y + 1
fuel = fuel - 1
if fuel < 1 then exit do
if fuel < 3 then
color 4
locate 1, 1 : print space$(80);
locate 1, 1 : print handl$; " you need to jump now, I'm running out of fuel!"
end if
end if
if fuel < 3 then
if planecolor = 7 then planecolor = 8 else planecolor = 7
end if
loop until jumped
if jumped then
color 4
locate 1, 1 : print space$(80);
locate 2, 1 : print space$(80);
locate 1, 1
if fuel = recede then
print "BE CAREFUL "; handl$; "!!!"
else
print handl$; " has jumped!"
end if
px = x + 1
py = y
do while v
py = py + 1
if fuel = recede then
px = px - 1
if px < 1 then
die = 2
exit do
end if
else
px = px + 1
if px > 80 then
die = 2
exit do
end if
end if
color 12
locate py, px : print chr$(2);
x = x + 1
if x > 78 then x = 1
color 7
locate y, x : print "|_^";
v = v - 1
_delay 0.5
locate py, px : print " ";
locate y, x : print space$(3);
loop
if die = 0 then
do
'this should not need screen bounds checking
py = py + 1
h = screen(py, px)
if h = 46 then die = 0 : exit do
if h = 177 then die = 1 : exit do
color 12
locate py, px : print chr$(2);
x = x + 1
if x > 78 then x = 1
color 7
locate y, x : print "|_^";
_delay 0.5
locate py, px : print " ";
locate y, x : print space$(3);
loop
end if
color 5
locate 2, 1
select case die
case 0
print "GOOD JOB "; handl$; "!!! You have landed on the grass."
case 1
print "You crashed into a building! OUCH!!!"
case 2
print "Sorry but you went out of bounds which is not the purpose of this game. "
end select
end
else
color 4
locate 1, 1 : print space$(80);
locate 1, 1 : print "Sorry but you have lost.";
color 7
do until y > 23
locate y, x : print space$(3);
y = y + 1
locate y, x : print "|_^";
_delay 0.25
loop
color 4
for i = 1 to 10
locate y, x : print "#*#";
_delay 0.125
locate y, x
if i > 7 then
print ".+.";
else
print "*#*";
end if
_delay 0.125
next
locate y, x : print space$(3);
_delay 1
end if
system
FUNCTION Random1& (maxvaluu&)
DIM sg AS INTEGER
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION
RE: Stunt Jumper - bplus - 07-17-2023
Jump between the and grass:
I just noticed in screenshot the buildings have windows!
I am wondering if this can't be done in 100 LOC or less without double parking?
RE: Stunt Jumper - mnrvovrfc - 07-17-2023
Out of boredom I changed the program. Maybe this needs a new set of stunt jumpers so they jump the other way LOL. Otherwise I was forced to remove that part of the code. In its place now there are "helping birds". Notice the birds flying in the distance. Then use that information so a giant bird suddenly swoops just above the buildings able to carry the jumper in horizontal direction for a short time.
Maybe I should convert this game into some kind of tournament mode in which there are 10 paratroopers all waiting to die vying to see who could get on the bird and make the landing successfully. Then use that meme on him which had that ugly guy being an Olympic medalist next to that blonde who brought him the awards... ROFL.
EDIT: made a change to the program but delayed posting it here.
Code: (Select All)
'by mnrvovrfc 17-July-2023
OPTION _EXPLICIT
DIM SHARED sp3 AS STRING
DIM nm$(1 TO 7), histogram(1 TO 80) AS INTEGER
DIM AS INTEGER i, j, h, v, w, z, numtiles, numthalf, thresh
DIM AS INTEGER x, y, px, py, fuel, recede, planecolor
DIM AS INTEGER birds, bx, by, bh, kount
DIM ke$, handl$, jumped AS _BYTE, die AS INTEGER, carrybird AS _BYTE, carry AS _BYTE
DIM sp10 AS STRING
nm$(1) = "murderflower"
nm$(2) = "jumpdaplain"
nm$(3) = "sinusister"
nm$(4) = "quakefear"
nm$(5) = "adrenald"
nm$(6) = "houston"
nm$(7) = "rebare"
sp3 = SPACE$(3)
sp10 = SPACE$(10)
PRINT "Welcome to Stunt Paratrooper!"
PRINT: PRINT "Please choose who do you want to be. Press any number key from [1] to [7]."
FOR i = 1 TO 7
PRINT "("; _TRIM$(STR$(i)); ") "; nm$(i)
NEXT
DO
DO: ke$ = INKEY$: LOOP WHILE ke$ = ""
IF ke$ = CHR$(27) THEN END
v = VAL(ke$)
LOOP UNTIL v > 0 AND v < 8
handl$ = nm$(v)
v = UBOUND(nm$) - v + 4
RANDOMIZE v + 100
numtiles = 400
numthalf = numtiles \ 2
thresh = 5
CLS
DO
FOR i = 1 TO 80
histogram(i) = 0
NEXT
FOR i = 1 TO numthalf
j = Random1(80)
histogram(j) = histogram(j) + 1
NEXT
h = 0
FOR i = 1 TO 80
IF histogram(i) > h THEN h = histogram(i)
NEXT
FOR i = 1 TO numthalf
kount = 0
DO
j = Random1(80)
kount = kount + 1
LOOP UNTIL ABS(histogram(j) - h) <= thresh OR kount > 1000
histogram(j) = histogram(j) + 1
NEXT
h = 0
FOR i = 1 TO 80
IF histogram(i) > h THEN
h = histogram(i)
w = i
END IF
IF histogram(i) = 0 THEN histogram(i) = 1
NEXT
IF w = 80 THEN
z = 80
w = 78
ELSE
z = w + 2
END IF
LOOP UNTIL w > 25
histogram(w + 1) = 0
COLOR 6
LOCATE 25, 1: PRINT STRING$(79, 46);
LOCATE 24, 1: PRINT STRING$(80, 46);
COLOR 8
FOR i = 1 TO 80
y = 24
FOR j = histogram(i) TO 1 STEP -1
LOCATE y, i
PRINT CHR$(177);
y = y - 1
IF y < 11 THEN EXIT FOR
NEXT
NEXT
COLOR 4
LOCATE 1, 1: PRINT handl$;
COLOR 3
PRINT " you have to hit the grass between those buildings! Good luck!"
COLOR 5
LOCATE 2, 1: PRINT "Press [ESC] to quit. Press spacebar to jump out of plane."
fuel = 6
recede = fuel - 1
jumped = 0
carrybird = 0
carry = 0
x = 1
y = 5
planecolor = 7
birds = Random1(5) + 4
DO: ke$ = INKEY$: LOOP UNTIL ke$ = ""
DO
COLOR planecolor
LOCATE y, x: PRINT "|_^";
IF x MOD 4 = 0 THEN
displaybirds birds, 1
END IF
FOR i = 1 TO 10
_DELAY 0.05
ke$ = INKEY$
IF ke$ <> "" THEN
IF ke$ = CHR$(27) THEN SYSTEM
IF ke$ = CHR$(32) THEN
jumped = 1
EXIT FOR
END IF
END IF
NEXT
LOCATE y, x: PRINT sp3;
IF x MOD 4 = 0 THEN
displaybirds birds, 0
END IF
x = x + 1
IF x > 78 THEN
x = 1
IF y < 8 THEN y = y + 1
fuel = fuel - 1
IF fuel < 1 THEN EXIT DO
IF fuel < 3 THEN
COLOR 4
LOCATE 1, 1: PRINT SPACE$(80);
LOCATE 1, 1: PRINT handl$; " you need to jump now, I'm running out of fuel!"
END IF
END IF
IF fuel < 3 THEN
IF planecolor = 7 THEN planecolor = 8 ELSE planecolor = 7
END IF
LOOP UNTIL jumped
IF jumped THEN
COLOR 4
LOCATE 1, 1: PRINT SPACE$(80);
LOCATE 2, 1: PRINT SPACE$(80);
LOCATE 1, 1
PRINT handl$; " has jumped!"
px = x + 1
py = y
bx = 1
by = x
bh = fuel + v - 2
DO WHILE v
IF carrybird THEN
carrybird = carrybird - 1
IF carrybird < 1 THEN EXIT DO
ELSE
py = py + 1
END IF
px = px + 1
IF px > 80 THEN
die = 2
EXIT DO
END IF
IF bx > 0 THEN
IF carrybird THEN bx = bx + 1 ELSE bx = bx + 5
IF bx > 71 THEN bx = -1
IF bh > 0 THEN
bh = bh - 1
by = by + 1
IF by > 10 THEN by = 10
END IF
IF (py = by) AND (px >= bx) AND (px < bx + 10) AND carry = 0 THEN
carry = 1
carrybird = birds
END IF
END IF
x = x + 1
IF x > 78 THEN x = 1
COLOR 7
LOCATE y, x: PRINT "|_^";
IF bx > 0 THEN
COLOR 6
LOCATE by, bx: PRINT "}===|\==:>"
END IF
COLOR 12
LOCATE py, px: PRINT CHR$(2);
IF carry = 0 THEN v = v - 1
IF (py = by) AND (px >= bx) AND (px < bx + 10) AND carry = 0 THEN
carry = 1
carrybird = birds
END IF
_DELAY 0.5
COLOR 7
LOCATE py, px: PRINT " ";
LOCATE y, x: PRINT sp3;
IF bx > 0 THEN
LOCATE by, bx: PRINT sp10;
END IF
LOOP
IF die = 0 THEN
DO
'this should not need screen bounds checking
py = py + 1
h = SCREEN(py, px)
IF h = 46 THEN die = 0: EXIT DO
IF h = 177 THEN die = 1: EXIT DO
x = x + 1
IF x > 78 THEN x = 1
IF bx > 0 THEN
bx = bx + 5
IF bx > 71 THEN bx = -1
IF bh > 0 THEN
bh = bh - 1
by = by + 1
IF by > 10 THEN by = 10
END IF
END IF
IF bx > 0 THEN
COLOR 6
LOCATE by, bx: PRINT "}===|\==:>"
END IF
COLOR 7
LOCATE y, x: PRINT "|_^";
COLOR 12
LOCATE py, px: PRINT CHR$(2);
_DELAY 0.5
LOCATE py, px: PRINT " ";
LOCATE y, x: PRINT sp3;
IF bx > 0 THEN
LOCATE by, bx: PRINT sp10;
END IF
LOOP
END IF
COLOR 5
LOCATE 2, 1
SELECT CASE die
CASE 0
PRINT "GOOD JOB "; handl$; "!!! You have landed on the grass."
CASE 1
PRINT "You crashed into a building! OUCH!!!"
CASE 2
PRINT "Sorry but you went out of bounds which is not the purpose of this game. "
END SELECT
END
ELSE
COLOR 4
LOCATE 1, 1: PRINT SPACE$(80);
LOCATE 1, 1: PRINT "Sorry but you have lost.";
COLOR 7
DO UNTIL y > 23
LOCATE y, x: PRINT sp3;
y = y + 1
LOCATE y, x: PRINT "|_^";
_DELAY 0.25
LOOP
COLOR 4
FOR i = 1 TO 10
LOCATE y, x: PRINT "#*#";
_DELAY 0.125
LOCATE y, x
IF i > 7 THEN
PRINT ".+.";
ELSE
PRINT "*#*";
END IF
_DELAY 0.125
NEXT
LOCATE y, x: PRINT sp3;
_DELAY 1
END IF
SYSTEM
SUB displaybirds (howmany AS INTEGER, moad AS _BYTE)
DIM i AS INTEGER, ch AS STRING * 1
COLOR 6
IF moad THEN ch = "^" ELSE ch = " "
SELECT CASE howmany
CASE 5
LOCATE 3, 72: PRINT ch; sp3; ch;
LOCATE 4, 70: PRINT ch; sp3; ch; sp3; ch;
CASE 6
LOCATE 2, 75: PRINT ch; " "; ch;
LOCATE 3, 74: PRINT ch; sp3; ch;
LOCATE 4, 75: PRINT ch; " "; ch;
CASE 7
LOCATE 1, 80: PRINT ch;
LOCATE 2, 79: PRINT ch;
LOCATE 3, 78: PRINT ch;
LOCATE 4, 77: PRINT ch;
LOCATE 5, 78: PRINT ch;
LOCATE 6, 79: PRINT ch;
LOCATE 7, 80: PRINT ch;
CASE 8
LOCATE 2, 73: PRINT ch; " "; ch; " "; ch;
LOCATE 3, 72: PRINT ch; sp3; sp3; ch;
LOCATE 4, 75: PRINT ch; " "; ch; " "; ch;
CASE 9
LOCATE 3, 64: PRINT ch; sp3; ch; sp3; ch; sp3; ch;
LOCATE 4, 62: PRINT ch; sp3; ch; sp3; ch; sp3; ch; sp3; ch;
END SELECT
END SUB
FUNCTION Random1& (maxvaluu&)
DIM sg AS INTEGER
sg% = SGN(maxvaluu&)
IF sg% = 0 THEN
Random1& = 0
ELSE
IF sg% = -1 THEN maxvaluu& = maxvaluu& * -1
Random1& = INT(RND * maxvaluu& + 1) * sg%
END IF
END FUNCTION
RE: Stunt Jumper - bplus - 07-18-2023
@mnrvovrfc did you try names above number 3? For some reason the code blanks out for me for any name above 3.
Here is the essence of this game in < 25 LOC, plenty of double parking though (use of colons for multiple statements on one line of code).
Code: (Select All)
_Title "Drop Bomb into hole, pressing spacebar" ' b+ 2023-07-18
restart: ' 80 X 25 Ascii screen
targetC = Int(Rnd * 51) + 15 'set target between 15 and 65 inclusive
shipC = 1: shipR = 2: bombR = 1: dropBomb = 0: done$ = ""
Do
Cls
For row = 24 To 25 ' draw ground
For col = 1 To 80
If col <> targetC Then Locate row, col: Print Chr$(178);
Next
Next
shipC = shipC + 1
Locate shipR, shipC: Print "< O >";
If InKey$ = " " And dropBomb = 0 Then dropBomb = 1: bombC = shipC + 1
If dropBomb Then bombC = bombC + 1: bombR = bombR * 2
If bombR > 16 Then
bombR = 24
If bombC = targetC Then done$ = "Hit!" Else done$ = "Miss"
End If
If dropBomb Then Locate bombR + 1, bombC: Print "o";
_Limit 5
Loop While done$ = ""
Locate 10, 38: Print done$; " ZZZ...": Sleep: _KeyClear
If done$ <> "Hit!" Then GoTo restart Else Locate 12, 37: Print "Finally ;-))": End
Here is miss:
Here is what we are aiming for, a hit!
RE: Stunt Jumper - mnrvovrfc - 07-18-2023
I think the histogram has to be redone, another way to draw the buildings. Because now they might look weird, more like concrete and steel cigarettes that don't smoke.
bplus be glad we're still not in the days of Texas Instruments or Timex Sinclair BASIC: the colon wasn't allowed at all with those two! I think the guy who did that "Snake" game for an Atari computer was a true genius even if he did it in assembly language. Aurel's Micro(A) is sort of a cross between BASIC and assembly language and therefore the important thing is to get it done anyway.
|