|
Post by Rod on Apr 19, 2018 10:47:18 GMT -5
Your a gorilla in the jungle defending Jane as she trudges about meaninglessly. You must protect her from the crabs but watch you keep an eye on what direction she takes. There are only three keys to press left right and up to fire. Rem out the playmidi statement for a faster quieter start. Gorilla Defender
|
|
|
Post by Alyce Watson on Apr 19, 2018 10:52:05 GMT -5
I know that Rod's games are fantastic, so I wanted to play it immediately. Very cute! Will you be adding scoring and other features? I found that I hit hapless Jane more often than I hit the enemies.
|
|
|
Post by Rod on Apr 19, 2018 11:00:12 GMT -5
I'm going to get the heroine to nag and shout at the gorilla when hurt or annoyed, then it will feel more like home! (Joking).
|
|
|
Post by Alyce Watson on Apr 19, 2018 13:31:45 GMT -5
I played with the code a little. It's very crude, but I added a scoring system and scoreboard. Each crab killed increments the score. Each hit on the heroine decrements the score. (Not realistic in the slightest, I know!) A score of 10 (or more) wins. A score of -10 (or less) loses. I didn't add a score check until the end of the loop, so it's possible to see a score greater than 10 or less than negative 10 briefly on the scoreboard.
Thanks for sharing, Rod!
Code below requires Rod's resources from the zip linked in his post.
'additions by aw:
' hitting crab increments score
' hitting Jane decrements score
' score=10 - win
' score=-10 - lose. Jane explodes.
' changed underlying graphic window height
' to accomodate score display
'playmidi "jungle.mid",howlong
nomainwin
WindowWidth = 800
WindowHeight = 700
UpperLeftX = (DisplayWidth-WindowWidth)/2
UpperLeftY = (DisplayHeight-WindowHeight)/2
graphicbox #w.g, 0,0,800,600
open "Gorilla" for graphics_nf_nsb as #w
#w "trapclose [quit]"
[initialise]
bx=1 'banana x index
by=2 'banana y index
bxd=3 'banana x delta index
byd=4 'banana y delta index
dim banana(6,4) 'x,y,xdelta,ydelta
dim explosion(6,3) 'x,y,count
dim crab(6,3) 'x,y,xdelta
gravity=1 'pull of gravity on banana
gx=300 'gorilla x
gy=430 'gorilla y ground level for now
gdelta=12 'gorilla speed
gdir=-12 'gorilla direction
hx=360 'heroine x
hy=415 'heroine y
hd=4 'heroine direction, really background scroll
bakx=0 'background x scroll position
score=0 'score: hit crab=+1, hit Jane=-1
'crabs walking
loadbmp "c1","crab1.bmp"
loadbmp "c2","crab2.bmp"
loadbmp "c3","crab3.bmp"
for n= 0 to 6
#w.g "addsprite c";str$(n);" c1 c2 c3"
#w.g "cyclesprite c";str$(n);" 1"
#w.g "spritexy c";str$(n);" -101 460"
crab(n,bx)=-101
crab(n,by)=460
next
'gorilla walking and throwing
for n=0 to 6
loadbmp "g"+str$(n),"g"+str$(n)+".bmp"
next
#w.g "addsprite g g0 g1 g2 g3 "
#w.g "spritescale g 200"
#w.g "cyclesprite g 1"
#w.g "spritexy g 300 430"
#w.g "addsprite t g4 g5 g6 g5 g4 "
#w.g "spritescale t 200"
#w.g "cyclesprite t 1"
#w.g "spritevisible t off"
'7 bananas tumbling
for n=0 to 6
loadbmp "b"+str$(n),"b"+str$(n)+".bmp"
next
for n=0 to 6
#w.g "addsprite b";str$(n);" b0 b1 b2 b3 b4 b5 b6"
#w.g "cyclesprite b";str$(n);" 1"
banana(n,bx)=-40 'hold off screen
banana(n,by)=430
#w.g "spritexy b";str$(n);" ";banana(n,bx);" ";banana(n,by)
next
'explosion and fire
for n= 0 to 7
loadbmp "e";str$(n),"e";str$(n);".bmp"
next
for n=1 to 4
loadbmp "f";str$(n),"f";str$(n);".bmp"
next
for n= 0 to 6
#w.g "addsprite e";str$(n);" e0 e1 e2 e3 e4 e5 e6 e7 f1 f2 f3 f4 f3 f4 f3 f2 f3 f3 f3 f1 f2 f1 f2 f1"
#w.g "spritexy e";str$(n);" -40 445"
#w.g "cyclesprite e";str$(n);" 1"
next
'heroine
for n=0 to 7
loadbmp "h"+str$(n),"h"+str$(n)+".bmp"
next
#w.g "addsprite h h0 h1 h2 h3 h4 h5 h6 h7"
#w.g "cyclesprite h 1"
#w.g "spritexy h 360 415"
loadbmp "bak", "bak.bmp"
#w.g "background bak";
'start the keyboard checking event
#w.g "when characterInput [key]"
#w.g "setfocus"
#w "down;fill yellow; backcolor yellow; color black; place 300 640"
#w "font arial 18"
#w "\SCORE: ";score;" "
' now start the timer to repeatedly call the drawing loop
timer 66, [drawingloop]
'now sit and wait
wait
[drawingloop]
'move gorilla if not throwing
if throw = 0 then gx=gx-hd+gdir
if gx>800 then gx=800
if gx<-80 then gx=-80
#w.g "spritexy g ";gx;" ";gy
#w.g "spritexy t ";gx;" ";gy
'throwing? change image for five frames
if throw=5 then
#w.g "spritevisible g off"
#w.g "spritevisible t on"
end if
throw=throw-(throw>0)
if throw=0 then
#w.g "spritevisible g on"
#w.g "spritevisible t off"
end if
'move crabs
for n= 0 to 6
if crab(n,bx)<-100 or crab(n,bx)>900 then
crab(n,bxd)=4-int(rnd(0)*9)
if crab(n,bxd)<0 then
crab(n,bx)=900
#w.g "spriteorient c";str$(n);" normal"
else
crab(n,bx)=-100
#w.g "spriteorient c";str$(n);" mirror"
end if
else
'if rnd(0)>.5 then
crab(n,bx)=crab(n,bx)+crab(n,bxd)-hd
'end if
end if
#w.g "spritexy c";str$(n);" ";crab(n,bx);" ";crab(n,by)
next
'move banana
for n= 0 to 6
if banana(n,bx)<>-40 then
banana(n,bx)=banana(n,bx)+banana(n,bxd)
banana(n,by)=banana(n,by)+banana(n,byd)
banana(n,byd)=banana(n,byd)+gravity
#w.g "spritexy b";str$(n);" ";banana(n,bx);" ";banana(n,by)
if banana(n,by)>445 then 'explode banana
explosion(n,bx)=banana(n,bx)
explosion(n,by)=banana(n,by)
explosion(n,3)=24 'set explosion counter
#w.g "spriteimage e";str$(n);" e0" 'show explosion
#w.g "spritexy e";str$(n);" ";explosion(n,bx);" 445"
banana(n,bx)=-40 'remove banana
playwave "smallbang.wav",async
#w.g "spritexy b";str$(n);" ";banana(n,bx);" ";banana(n,by)
#w.g "spritecollides e";str$(n);" list$"
if instr(list$,"c0",1) then crab(0,bx)=-101:score=score+1
if instr(list$,"c1",1) then crab(1,bx)=-101:score=score+1
if instr(list$,"c2",1) then crab(2,bx)=-101:score=score+1
if instr(list$,"c3",1) then crab(3,bx)=-101:score=score+1
if instr(list$,"c4",1) then crab(4,bx)=-101:score=score+1
if instr(list$,"c5",1) then crab(5,bx)=-101:score=score+1
if instr(list$,"c6",1) then crab(6,bx)=-101:score=score+1
if instr(list$,"h",1) then score=score-1
end if
end if
next
'stop explosions
for n= 0 to 6
if explosion(n,3)>0 then
explosion(n,3)=explosion(n,3)-1
if explosion(n,3)=0 then
#w.g "spritexy e";str$(n);" -40 445"
else
explosion(n,bx)=explosion(n,bx)-hd
#w.g "spritexy e";str$(n);" ";explosion(n,bx);" 445"
end if
end if
next
'change heroine direction randomly
if rnd(0)>.99 then
if hd=4 then
#w.g "spriteorient h mirror"
hd=-4
else
hd=4
#w.g "spriteorient h normal"
end if
end if
'move background
bakx=bakx+hd
if bakx>1600 then bakx=bakx-1600
if bakx<0 then bakx=bakx+1600
#w.g "backgroundxy ";bakx;" 0"
#w.g "drawsprites"
#w "place 300 640;\SCORE: ";score;" "
'************************
'added: check score
'if won or lost, end game
'************************
if score>=10 then
notice "You won!"
goto [quit]
end if
if score<=-10 then
notice "You lost! Your heroine has perished!"
goto [quit]
end if
wait
[key]
'this gets called every time a key is pressed
'set the movement depending on key pressed
key=asc(right$(Inkey$,1))
select case key
case _VK_LEFT 'left
gdir=gdelta*-1
#w.g "spriteorient g normal"
#w.g "spriteorient t normal"
case _VK_RIGHT 'right
gdir=gdelta
#w.g "spriteorient g mirror"
#w.g "spriteorient t mirror"
case 53 'stop
gdir=0
case _VK_UP 'fire
'find first free banana and launch it
for n=0 to 6
if banana(n,bx)=-40 then 'free banana
banana(n,bx)=gx
banana(n,by)=gy
#w.g "spritexy b";str$(n);" ";gx;" ";gy
#w.g "spriteimage b";str$(n);" b";str$(int(rnd(0)*7))
banana(n,bxd)=2*gdir
banana(n,byd)=int(rnd(0)*3+1)*-1
throw=5 '5 frames of throwing gorilla
exit for
end if
next
end select
'if we are standing still stop the gorilla
if gdir=0 then
#w.g "cyclesprite g 0"
else
#w.g "cyclesprite g 1"
end if
wait
[quit]
#w.g "when characterInput ]"
timer 0
' stopmidi
close #w
|
|
|
Post by Alyce Watson on Apr 19, 2018 14:37:15 GMT -5
Thought I'd mention that this is just a little fork off of Rod's code and not meant to be taken seriously. It anybody finds it interesting, please use it. I can't wait to see if Rod takes the "real" version further.
|
|
GWS
New Member
Posts: 18
|
Post by GWS on Apr 23, 2018 0:06:53 GMT -5
That's an excellent bit of creative coding Rod - I can learn a lot from that. Thank you. I managed to get a Gorilla version going in another language (IBasicPro) some years ago - but that had a Sprite to Buffer statement by which you could change the whole 'CityScape' sprite to reflect each banana explosion and consequent fires - even put the lights out on the affected floor. Maybe there's a way of doing that in LB. Anyway, your jungle game is much better .. Graham Attachments:
|
|
|
Post by Alyce Watson on Apr 23, 2018 10:20:55 GMT -5
Just curious if you intend to develop this further, Rod. I'm hoping the answer is "yes." Two of your games are some of my favorite LB programs! Everybody loves the Macaroni doing the Macarena. (I see your avatar is holding a macaroni noodle!) I also like the Jet Ski game. It's amazing. Anybody interested in games or graphics should visit the Liberty BASIC Game Bin
|
|
|
Post by Alyce Watson on Apr 23, 2018 10:24:10 GMT -5
GWS, have you looked at Mayhem that ships with Liberty BASIC? It is almost identical to the old Gorillas game, but with hills and artillery rather than gorillas and skyscrapers. There's no need to use sprites at all. You can certainly put out lights and show fires with drawing commands. It would be a little more challenging if you used sprites.
|
|
GWS
New Member
Posts: 18
|
Post by GWS on Apr 23, 2018 11:19:37 GMT -5
Hi Alyce, No I haven't looked yet - short on time. I'm preparing my shed to receive an Eddystone receiver, which I'm looking forward to doing up (if it needs it) - it's 70 years old . I certainly will investigate Mayhem. Handling graphics on a computer is a wonderful thing, as Rod's game shows. all the best, Graham
|
|
|
Post by Rod on Apr 23, 2018 14:32:03 GMT -5
Does anyone still broadcast? I thought we had all moved on to iphones, ipads and tablets. If you ever do get time to look at the sprite commands and sprite engine you will find it fully functional. That Gorilla game was a distraction that filled probably four afternoons work. So give it a go.
You can capture the background with sprite damage and redisplay so it should be easy to demolish those buildings.
|
|
GWS
New Member
Posts: 18
|
Post by GWS on Apr 23, 2018 22:15:51 GMT -5
Rod .. Well I still transmit from my G4EVW 10 watt station (attachment) Not very far though. Do I take it (from the presence of the pspbrwse.jbf file) that you use Paint Shop for your artworks - you're very good at it. I've only started to investigate LB, but it seems sprite rotation is limited to 90 degree rotations. That could be difficult to get a clock hand to turn smoothly through 360 degrees. Capturing a background with sprite damage and re displaying sounds good - I might need a bit of guidance on how to do that. A minimal test program would be great if you have time. Best wishes, Graham Attachments:
|
|