Yes, everyone has done one of these.
I didn't want to post until I could show
collisions, explosions and bonuses.
At nearly 300 lines, it was almost too
much for me to keep track of it all.
Should have put a clever start title up.
Oh well . . .
open window 640,512
clear window
label main
rem game setup
bonus1=0
bonus2=0
score=0
fire=0
en=0
sbomb=0
bullet=-6
stars=100
dim xstar(stars),ystar(stars)
dim r(stars),g(stars),b(stars)
for a=1 to stars
xstar(a)=int(ran(540))+20
ystar(a)=int(ran(510))
r(a)=ran(156)+100
g(a)=ran(156)+100
b(a)=ran(156)+100
next a
bullets=6
dim bulletx(bullets),bullety(bullets),fire(bullets)
for a=1 to bullets
bulletx(a)=shipx
bullety(a)=shipy-15
fire(a)=0
next a
shipx=320
shipy=510
ships=10
enemy=10
dim enx(enemy),eny(enemy),enm(enemy)
dim blow(enemy),go1(enemy),explode(enemy)
dim explosionx(enemy),explosiony(enemy)
for b=1 to enemy
enx(b)=int(ran(27))*20+20
eny(b)=ran(512)-500
enm(b)=ran(.15)+.07
blow(b)=0
go1(b)=0
explode(b)=0
next b
enfire=2
enbullety=eny(enfire)
enbulletx=enx(enfire)
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,50,50,50
setrgb 2,50,50,50
setrgb 3,50,50,250
gtriangle 0,0 to 580,0 to 580,512
setrgb 2,50,50,250
gtriangle 0,0 to 580,512 to 0,512
for a=1 to stars
setrgb 1,r(a),g(a),b(a)
fill circle xstar(a),ystar(a),1.2
ystar(a)=ystar(a)+.25
if ystar(a)>512 ystar(a)=0
next a
c=peek("port1")
rem ship movement
if and(c,128)>0 shipx=shipx-5
if and(c,32)>0 shipx=shipx+5
if shipx<10 shipx=10
if shipx>570 shipx=570
rem ship remove after hit
shipy=shipy-1
if shipy<510 shipy=510
rem bullet fire and reset
go=go+1
if go>7 go=7
for a=1 to bullets
if and(c,16384)>0 and go=7 and fire(a)=0 then
go=0
shipy=518
fire(a)=1
endif
if fire(a)=1 bullety(a)=bullety(a)-10
if bullety(a)<0 bullet=bullet+1
if bullety(a)<0 and shipy=510 then
bonus1=0
fire(a)=0
bullety(a)=shipy-15
endif
if fire(a)=0 bulletx(a)=shipx
for b=1 to enemy
rem enemy fire
if enbullety>520 then
enfire=int(ran(b))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
endif
enbullety=enbullety+.03
rem suicide explosion
if eny(b)>509 and eny(b)<512 then
setrgb 1,250,250,250
fill circle enx(b),508,28
setrgb 1,250,0,0
fill circle enx(b),508,25
endif
rem ship/enemy collision
if abs(enx(b)-shipx)<38 and eny(b)>490 and eny(b)<492 then
eny(b)=0
ships=ships-1
shipy=600
fire(a)=1
setrgb 1,250,250,250
fill circle enx(b),508,30
setrgb 1,50,50,250
fill circle enx(b),508,27
endif
rem enemy reset
if eny(b)>512 then
eny(b)=0
enx(b)=int(ran(27))*20+20
endif
rem ship bullet/enemy collision
rem bonuses:
rem 10 sequential hits - extra ship
rem 3 of any 10 hits - one smart bomb
rem smart bomb takes out screen enemy
if bulletx(a)>enx(b)-8 and bulletx(a)<enx(b)+8 and bullety(a)>eny(b) and bullety(a)<eny(b)+22 then
en=en+1
bullet=bullet+1
score=score+int(100*enm(b))
rem extra ships
bonus1=bonus1+1
if bonus1>10 bonus1=0
if bonus1=10 ships=ships+1
if bonus1=10 bonus2=bonus2+1
rem enemy reset
eny(b)=0
enx(b)=int(ran(27))*20+20
rem bullet reset
fire(a)=0
bullety(a)=shipy-15
endif
rem enemy explosion
if bulletx(a)>enx(b)-8 and bulletx(a)<enx(b)+8 and bullety(a)>eny(b) and bullety(a)<eny(b)+30 blow(b)=1
if blow(b)=1 then
go1(b)=1
explode(b)=explode(b)+go1(b)
endif
if explode(b)>20 then
go1(b)=0
explode(b)=0
blow(b)=0
endif
if blow(b)=0 then
explosionx(b)=enx(b)
explosiony(b)=eny(b)+11
endif
setrgb 1,250,250,250
fill circle explosionx(b),explosiony(b),explode(b)+3
setrgb 1,0,256,0
fill circle explosionx(b),explosiony(b),explode(b)
rem enemy movement
eny(b)=eny(b)+enm(b)
flame=flame+.1
if flame>30 flame=6
rem enemy ships
setrgb 1,0,250,0
fill triangle enx(b)-8,eny(b) to enx(b)+8,eny(b) to enx(b),eny (b)+22
setrgb 1,250,125,20
fill triangle enx(b)-4,eny(b) to enx(b)+4,eny(b) to enx(b),eny (b)-flame
rem smart bomb
if bonus1=10 bonus2=bonus2+1
if bonus2=3 sbomb=sbomb+1
if and(c,4096)>0 and enx(b)>0 and bonus2=3 then
setrgb 1,256,256,256
fill circle enx(b),eny(b)+11,25
setrgb 1,0,256,0
fill circle enx(b),eny(b)+11,22
x(b)=int(ran(27))*20+20
y(b)=ran(510)-500
sbomb=sbomb-1
bonus2=0
endif
next b
next a
rem heads up display
setrgb 1,250,250,250
line 579,0 to 579,512
setrgb 1,200,200,0
fill rectangle 580,0 to 640,512
setrgb 1,0,0,0
text 580,20," GAME"
text 580,40,"SCORE:"
text 580,60,str$(score)
text 580,100,"SHIPS"
text 580,120,"LEFT:"
text 580,140,str$(ships)
text 580,180,"BONUS:"
text 580,200,"COUNT"
text 580,220,str$(bonus1)
text 610,220,str$(bonus2)
setrgb 1,256,0,0
text 580,230,"10"
text 610,230,"3"
setrgb 1,0,0,0
text 580,260,"ENEMYS"
text 580,280," SHOT:"
text 580,300,str$(en)
text 580,340,"SHOTS"
text 580,360," USED"
text 580,380,str$(bullet)
text 580,420,"SMART"
text 580,440,"BOMBS"
text 580,460,str$(sbomb)
rem game display
setrgb 1,250,250,250
rem ship bullet/enemy bullet collision
for a=1 to bullets
fill rectangle bulletx(a)-2,bullety(a)-5 to bulletx(a)+2,bullety(a)+5
if bulletx(a)>enbulletx-2 and bulletx(a)<enbulletx+2 and bullety(a)>enbullety-3 and bullety(a)<enbullety+3 then
ship=ship+1
setrgb 1,256,256,256
fill circle enbulletx,enbullety,15
setrgb 1,100,100,100
fill circle enbulletx,enbullety,12
bulletx(a)=shipx
bullety(a)=shipy-15
enfire=int(ran(a))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
endif
next a
fill rectangle enbulletx-2,enbullety-3 to enbulletx+2,enbullety +3
setrgb 1,256,130,0
fill triangle shipx-10,shipy to shipx+10,shipy to shipx,shipy-30
rem enemy bullet collision
if enbulletx>shipx-10 and enbulletx<shipx+10 and enbullety>shipy-30 then
ships=ships-1
enfire=int(ran(a))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
setrgb 1,250,250,250
fill circle shipx,shipy-15,40
setrgb 1,250,125,0
fill circle shipx,shipy-15,35
shipy=600
fire=1
endif
if ships=0 gosub gameend
until (1=0)
label gameend
open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,256,256,256
rectangle 200,200 to 440,312
text 220,260,"YOUR SCORE WAS "+str$(score)
setrgb 1,255,0,0
text 230,235," G A M E O V E R"
setrgb 1,0,255,0
text 230,285,"press X to restart"
c=peek("port1")
until (and(c,16384)>0)
gosub main
I think it needs some optimizing.
That's pretty cool Bikemadness :)
Nice that you have all that going on and I like the explosions.
Thanks.
It's the first time I've used notes.
Even the enemies bullets can be shot. Which gives an extra ship.
I had other ideas.
Like saving parachuting enemy men. Or not.
I have a line or two of program for that.
That's effin sweet, looks the bomb too.
Looks cool, can't wait to to get it typed on the PS3.
I've done YAPOKER and am 1/4 way through FREECELL.
YABASIC roolz!
Hehe, good to know that you are still typing in the listings!
I've done a bit more work.
There is now 400 lines.
Has a title screen.
And DON'T shoot the parachute.
open window 640,512
label main
pause.25
clear window
shoot=0
bullx=herox
bully=heroy-10
herox=190
heroy=300
'a$="PLAYTHEGAME!"
'a$="PRISONEROFWAR"
a$="SAVETHEHOSTAGES"
nos=len(a$)
gap=240/nos
dim x(nos),y(nos)
for a=1 to nos
x(a)=a*gap+185
y(a)=220
next a
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,256,256,256
rectangle 180,201 to 459,312
herox=herox+.5
if herox>450 herox=190
shoot=0
for a=1 to nos
text x(a),y(a),mid$(a$,a,1)
if herox>x(a)+5 and herox<x(a)+10 shoot=1
next a
heroy=heroy-1
if heroy<300 heroy=300
if shoot=1 then
heroy=304
bully=bully-8
endif
if shoot=0 then
bully=heroy-10
bullx=herox
endif
for a=1 to nos
y(a)=y(a)+.5
if y(a)>220 y(a)=220
if bullx>x(a) and bullx<x(a)+10 and bully<y(a)+10 then
setrgb 1,256,256,256
fill circle x(a)+5,y(a)-2,12
setrgb 1,256,0,0
fill circle x(a)+5,y(a)-2,10
endif
if herox>x(a)+5 and herox<x(a)+10 and bully<y(a) y(a)=160
next a
setrgb 1,0,0,0
fill rectangle 180,150 to 460,200
fill rectangle 180,312 to 460,362
fill rectangle 130,150 to 180,362
fill rectangle 460,150 to 510,362
setrgb 1,256,256,256
fill rectangle bullx-1,bully-2 to bullx+1,bully+2
setrgb 1,256,128,0
fill triangle herox-5,heroy to herox+5,heroy to herox,heroy-18
if hiscore>0 then
setrgb 1,256,256,0
text 230,335,"high score is "+str$(hiscore)
endif
setrgb 1,0,150,0
text 235,355,"press X to start"
setrgb 1,256,0,0
text 245,180,"H O S T A G E !"
c=peek("port1")
until (and(c,16384)>0)
rem game setup
score=0
bonus1=0
bonus2=0
fire=0
en=0
sbomb=0
bullet=-6
stars=100
dim xstar(stars),ystar(stars)
dim r(stars),g(stars),b(stars)
for a=1 to stars
xstar(a)=int(ran(540))+20
ystar(a)=int(ran(510))
r(a)=ran(156)+100
g(a)=ran(156)+100
b(a)=ran(156)+100
next a
bullets=6
dim bulletx(bullets),bullety(bullets),fire(bullets)
for a=1 to bullets
bulletx(a)=shipx
bullety(a)=shipy-15
fire(a)=0
next a
shipx=320
shipy=510
ships=10
enemy=10
dim enx(enemy),eny(enemy),enm(enemy)
dim blow(enemy),go1(enemy),explode(enemy)
dim explosionx(enemy),explosiony(enemy)
for b=1 to enemy
enx(b)=int(ran(27))*20+20
eny(b)=ran(512)-500
enm(b)=ran(.15)+.07
blow(b)=0
go1(b)=0
explode(b)=0
next b
enfire=2
enbullety=eny(enfire)
enbulletx=enx(enfire)
para=0
parachutex=enx(enfire)
parachutey=enx(enfire)
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,50,50,50
setrgb 2,50,50,50
setrgb 3,50,50,250
gtriangle 0,0 to 580,0 to 580,512
setrgb 2,50,50,250
gtriangle 0,0 to 580,512 to 0,512
for a=1 to stars
setrgb 1,r(a),g(a),b(a)
fill circle xstar(a),ystar(a),1.2
ystar(a)=ystar(a)+.25
if ystar(a)>512 ystar(a)=0
next a
c=peek("port1")
rem ship movement
if and(c,128)>0 shipx=shipx-5
if and(c,32)>0 shipx=shipx+5
if shipx<10 shipx=10
if shipx>570 shipx=570
rem ship remove after hit
shipy=shipy-1
if shipy<510 shipy=510
rem bullet fire and reset
go=go+1
if go>7 go=7
for a=1 to bullets
if and(c,16384)>0 and go=7 and fire(a)=0 then
go=0
shipy=518
fire(a)=1
endif
if fire(a)=1 bullety(a)=bullety(a)-10
if bullety(a)<0 bullet=bullet+1
if bullety(a)<0 and shipy=510 then
bonus1=0
fire(a)=0
bullety(a)=shipy-15
endif
if fire(a)=0 bulletx(a)=shipx
for b=1 to enemy
rem enemy fire
if enbullety>520 then
enfire=int(ran(b))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
endif
enbullety=enbullety+.03
if bulletx(a)>enx(enfire)-8 and bulletx(a)<enx(enfire)+8 and bullety(a)>eny(enfire) and bullety(a)<eny(enfire)+60 para=1
if para=1 then
setrgb 1,256,256,256
fill circle parachutex,parachutey,10
setrgb 1,0,0,parachutey/2
fill rectangle parachutex-10,parachutey to parachutex+10,parachutey+10
setrgb 1,256,256,256
fill rectangle parachutex-1,parachutey+15 to parachutex+1,parachutey+20
line parachutex,parachutey+15 to parachutex-10,parachutey
line parachutex,parachutey+15 to parachutex+10,parachutey
line parachutex,parachutey+15 to parachutex-4,parachutey
line parachutex,parachutey+15 to parachutex+4,parachutey
parachutey=parachutey+.05
endif
if parachutey>512 then
para=0
parachutex=enx(enfire)
chute=chute+1
endif
if para=0 parachutey=eny(enfire)+11
rem ship/parachute/bullet collision here
'if parachutex>shipx-10 and parachutex<shipx-2 and parachutey>shipy-20 and parachute<shipy-20 chute=chute+1
if bulletx(a)>parachutex-10 and bulletx(a)<parachutex+10 and bullety(a)>parachutey-10 and bullety(a)<parachutey then
setrgb 1,256,256,256
fill circle parachutex,parachutey,50
setrgb 1,128,128,256
fill circle parachutex,parachutey,45
setrgb 1,0,0,0
text 200,255,"DON'T SHOOT THE PARACHUTE"
gosub gameend
endif
rem suicide explosion
if eny(b)>509 and eny(b)<512 then
setrgb 1,250,250,250
fill circle enx(b),508,28
setrgb 1,250,0,0
fill circle enx(b),508,25
endif
rem ship/enemy collision
if abs(enx(b)-shipx)<38 and eny(b)>490 and eny(b)<492 then
eny(b)=0
ships=ships-1
shipy=600
'fire(a)=1
'bulletx(a)=shipx
'bullety(a)=shipy-15
setrgb 1,250,250,250
fill circle shipx,508,30
setrgb 1,50,50,250
fill circle shipx,508,27
endif
rem enemy reset
if eny(b)>512 then
eny(b)=0
enx(b)=int(ran(27))*20+20
endif
rem ship bullet/enemy collision
rem bonuses:
rem 10 sequential hits - extra ship
rem 3 of any 10 hits - one smart bomb
rem smart bomb takes out screen enemy
if bulletx(a)>enx(b)-8 and bulletx(a)<enx(b)+8 and bullety(a)>eny(b) and bullety(a)<eny(b)+22 then
en=en+1
bullet=bullet+1
score=score+int(100*enm(b))
rem extra ships
bonus1=bonus1+1
if bonus1>10 bonus1=0
if bonus1=10 ships=ships+1
if bonus1=10 bonus2=bonus2+1
rem enemy reset
eny(b)=0
enx(b)=int(ran(27))*20+20
rem bullet reset
fire(a)=0
bullety(a)=shipy-15
endif
rem enemy explosion
if bulletx(a)>enx(b)-8 and bulletx(a)<enx(b)+8 and bullety(a)>eny(b) and bullety(a)<eny(b)+30 blow(b)=1
if blow(b)=1 then
go1(b)=1
explode(b)=explode(b)+go1(b)
endif
if explode(b)>20 then
go1(b)=0
explode(b)=0
blow(b)=0
endif
if blow(b)=0 then
explosionx(b)=enx(b)
explosiony(b)=eny(b)+11
endif
setrgb 1,250,250,250
fill circle explosionx(b),explosiony(b),explode(b)+3
setrgb 1,0,256,0
fill circle explosionx(b),explosiony(b),explode(b)
rem parachute drop here?
rem enemy movement
eny(b)=eny(b)+enm(b)
flame=flame+.1
if flame>30 flame=6
rem enemy ships
setrgb 1,0,250,0
fill triangle enx(b)-8,eny(b) to enx(b)+8,eny(b) to enx(b),eny (b)+22
setrgb 1,250,125,20
fill triangle enx(b)-4,eny(b) to enx(b)+4,eny(b) to enx(b),eny (b)-flame
rem smart bomb
if bonus1>10 bonus2=bonus2+1
if bonus2=3 sbomb=sbomb+1
if bonus2=3 bonus2=0
if and(c,4096)>0 and eny(b)>0 and sbomb>0 then
score=score+int(100*enm(b))
setrgb 1,256,256,256
fill circle enx(b),eny(b)+11,25
setrgb 1,0,256,0
fill circle enx(b),eny(b)+11,22
enx(b)=int(ran(27))*20+20
eny(b)=ran(510)-500
bonus2=0
endif
if sbomb<0 sbomb=0
next b
next a
bmb=bmb+1
if bmb>10 bmb=10
if and(c,4096)>0 and bmb=10 then
sbomb=sbomb-1
bmb=0
endif
if sbomb<0 sbomb=0
if score>hiscore hiscore=score
if chute>hichute hichute=chute
rem heads up display
setrgb 1,250,250,250
line 579,0 to 579,512
setrgb 1,200,200,0
fill rectangle 580,0 to 640,512
setrgb 1,0,0,0
text 580,20," GAME"
text 580,35,"SCORE:"
text 580,50,str$(score)
text 580,80,"HIGH"
text 580,95,"SCORE:"
text 580,110,str$(hiscore)
text 580,140,"SHIPS"
text 580,155,"LEFT:"
text 580,170,str$(ships)
text 580,200,"BONUS"
text 580,215,"COUNT:"
text 580,230,str$(bonus1)
text 610,230,str$(bonus2)
setrgb 1,256,0,0
text 580,240,"10"
text 610,240,"3"
setrgb 1,0,0,0
text 580,280,"ENEMYS"
text 580,295," SHOT:"
text 580,310,str$(en)
text 580,350,"SHOTS"
text 580,365,"USED:"
text 580,380,str$(bullet)
text 580,420,"SMART"
text 580,435,"BOMBS"
text 580,450,str$(sbomb)
text 580,480,"PEOPLE"
text 580,495,"SAVED"
text 580,510,str$(chute)
rem game display
setrgb 1,250,250,250
rem ship bullet/enemy bullet collision
for a=1 to bullets
fill rectangle bulletx(a)-2,bullety(a)-5 to bulletx(a)+2,bullety(a)+5
if bulletx(a)>enbulletx-2 and bulletx(a)<enbulletx+2 and bullety(a)>enbullety-3 and bullety(a)<enbullety+3 then
ship=ship+1
setrgb 1,256,256,256
fill circle enbulletx,enbullety,15
setrgb 1,100,100,100
fill circle enbulletx,enbullety,12
bulletx(a)=shipx
bullety(a)=shipy-15
enfire=int(ran(a))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
endif
next a
fill rectangle enbulletx-2,enbullety-3 to enbulletx+2,enbullety +3
setrgb 1,256,130,0
fill triangle shipx-10,shipy to shipx+10,shipy to shipx,shipy-30
rem enemy bullet collision
if enbulletx>shipx-10 and enbulletx<shipx+10 and enbullety>shipy-30 then
ships=ships-1
enfire=int(ran(a))+1
enbullety=eny(enfire)
enbulletx=enx(enfire)
setrgb 1,250,250,250
fill circle shipx,shipy-15,40
setrgb 1,250,125,0
fill circle shipx,shipy-15,35
shipy=600
fire=1
endif
if ships=0 gosub gameend
until (1=0)
label gameend
open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,256,256,256
rectangle 200,185 to 440,312
text 220,230,"most men saved: "+str$(hichute)
text 220,245," HIGH SCORE IS "+str$(hiscore)
text 220,260,"YOUR SCORE WAS "+str$(score)
setrgb 1,255,0,0
text 230,215," G A M E O V E R"
setrgb 1,0,255,0
text 230,285,"press X to restart"
c=peek("port1")
until (and(c,16384)>0)
gosub main
I think I'm finished with it now.
Nice work! I have been mighty tempted to dust off the emulator and get stuck into something myself having watched this.
Fantastic! :clap: :clap: :clap:
Hello
I dont know why i receive message error with "vm" in this program?
for which version of Yabasic is made ?..maybe i have wrong one ??
on line 21 or 22
setdrawbuf vm