These could be classed as exercises, answers to which you make up a question to.
See if can guess what is going to happen by looking at the code first.
...............
left/right to move, X to action.
open window 640,512
m=0
b=0
yb=200
y=200
ma=20
repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
setrgb 1,200,200,0
fill rectangle 0,0 to 640,512
c=peek("port1")
if and(c,128)>0 and m=0 m=-1
if and(c,32)>0 and m=0 m=1
if and(c,16384)>0 and y=200 go=1
if go=1 y=y-10
if y<99 y=99
if y=99 go=0
if go=0 y=y+2
if y>200 y=200
ma=ma+m
if ma<20 ma=20
if ma>600 ma=600
setrgb 1,100,100,100
text 10,20,"position="+str$(int(ma/20))
if m=0 text 130,20,"pointer=stop"
if m<>0 text 130,20,"pointer=go"
text 270,20,"bars="+str$((a-20)/20)
text 370,20,"fire height="+str$(yb-y)+"%"
if go=0 and y<200 text 550,20,"loading"
if go=1 text 550,20,"firing"
if y=200 text 550,20,"loaded"
setrgb 1,256,0,0
fill rectangle ma-8,205 to ma+8,215
setrgb 1,0,0,0
rectangle ma-8,205 to ma+8,215
for a=20 to 600 step 20
if ma=a then
m=0
setrgb 1,0,156,0
fill rectangle a-8,yb to a+8,y
endif
setrgb 1,0,0,0
rectangle a-8,100 to a+8,200
next a
until (1=0)
..................
this took me lots of versions.
open window 640,512
blocks=10
dim blx(blocks),bly(blocks),sqx(blocks),sqy(blocks)
for a=1 to blocks
blx(a)=20
bly(a)=20
sqx(a)=int(ran(5)+1)*120-40
sqy(a)=int(ran(4)+1)*120-40
next a
xb=400
yb=200
xm=2
ym=2
ra=15
repeat
setdispbuf vm
vm=1-vm
setdrawbuf vm
clear window
setrgb 1,200,200,0
fill rectangle 0,0 to 640,512
if sqx<0+blx sqx=0+blx
if sqx>640-blx sqx=640-blx
if sqy<0+bly sqy=0+bly
if sqy>510-bly sqy=510-bly
xb=xb+xm
yb=yb+ym
if xb<0+ra or xb>640-ra xm=-xm
if yb<0+ra or yb>510-ra ym=-ym
for a=1 to blocks
if xb>sqx(a)+blx(a)+ra and xb<sqx(a)+blx(a)+5+ra and yb>sqy(a)-bly(a)-ra and yb<sqy(a)+bly(a)+ra xm=-xm
if xb>sqx(a)-blx(a)-5-ra and xb<sqx(a)-blx(a)-ra and yb>sqy(a)-bly(a)-ra and yb<sqy(a)+bly(a)+ra xm=-xm
if yb>sqy(a)+bly(a)+ra and yb<sqy(a)+bly(a)+5+ra and xb>sqx(a)-blx(a)-ra and xb<sqx(a)+blx(a)+ra ym=-ym
if yb>sqy(a)-bly(a)-5-ra and yb<sqy(a)-bly(a)-ra and xb>sqx(a)-blx(a)-ra and xb<sqx(a)+blx(a)+ra ym=-ym
setrgb 1,0,256,0
fill rectangle sqx(a)-blx(a),sqy(a)-bly(a) to sqx(a)+blx(a),sqy(a)+bly(a)
next a
setrgb 1,200,0,0
fill rectangle xb-ra,yb-ra to xb+ra,yb+ra
setrgb 1,0,0,0
if xm=2 then
text xb-10,yb-5,"+"+str$(xm)
else
text xb-10,yb-5,str$(xm)
endif
if ym=2 then
text xb-10,yb+10,"+"+str$(ym)
else
text xb-10,yb+10,str$(ym)
endif
until (1=0)
Have a Yahappy day.