I'd always wanted to emulate the ship/man on 'Robotron' (old arcade game)
D-pad to move, symbol pad to fire.
open window 640,512
x=320
y=256
ammo=5
dim xb(ammo),yb(ammo),fire(ammo),m(ammo)
for a=1 to ammo
xb(a)=x
yb(a)=y
m(a)=0
fire(a)=0
next a
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window
setrgb 1,200,200,0
c=peek("port1")
if and(c,16)>0 y=y-5
if and(c,32)>0 x=x+5
if and(c,64)>0 y=y+5
if and(c,128)>0 x=x-5
if x<0 x=0
if x>640 x=640
if y<0 y=0
if y>512 y=512
fill rectangle 0,0 to 640,512
setrgb 1,150,150,150
fill rectangle x-5,y-5 to x+5,y+5
setrgb 1,0,0,0
rectangle x-5,y-5 to x+5,y+5
go=go+1
if go>5 go=5
for a=1 to ammo
if fire(a)=0 then
m(a)=0
else
m(a)=15
endif
if go=5 and fire(a)=0 and and(c,8192)>0 then
fire(a)=1
go=0
endif
if go=5 and fire(a)=0 and and(c,16384)>0 then
fire(a)=2
go=0
endif
if go=5 and fire(a)=0 and and(c,32768)>0 then
fire(a)=3
go=0
endif
if go=5 and fire(a)=0 and and(c,4096)>0 then
fire(a)=4
go=0
endif
if fire(a)=1 xb(a)=xb(a)+m(a)
if fire(a)=2 yb(a)=yb(a)+m(a)
if fire(a)=3 xb(a)=xb(a)-m(a)
if fire(a)=4 yb(a)=yb(a)-m(a)
if xb(a)<-20 or xb(a)>660 fire(a)=0
if yb(a)<-20 or yb(a)>532 fire(a)=0
if fire(a)=0 then
xb(a)=x
yb(a)=y
endif
setrgb 1,0,256,0
fill rectangle xb(a)-3,yb(a)-3 to xb(a)+3,yb(a)+3
setrgb 1,0,0,0
rectangle xb(a)-3,yb(a)-3 to xb(a)+3,yb(a)+3
next a
until (1=0)
I've already emulated the enemy... got the code somewhere.



