REM Start of BASIC! Program
Wakelock 3
dim xc[10]
dim yc[10]
dim Rc[10],r[10],g[10],b[10],a[10]
dim xa[10],ya[10],xb[10],yb[10]
choc =1
dim s[3]
gravity =0.3
radius =50
GR.OPEN 255, 0, 0,0
GR.ORIENTATION 1
GR.SCREEN sx, sy
ARRAY.LOAD Pattern[],100,10
sensors.open 1
GR.BITMAP.LOAD ptr_ball, "billet.png"
gR.BITMAP.LOAD ptr_wood, "wood.jpg"
AUDIO.LOAD whee, "flip-on3.ogg.mp3"
AUDIO.LOAD boing, "boing.mp3"
AUDIO.LOAD wall0,"wall0.ogg.mp3"
AUDIO.LOAD goal,"goal.mp3"
AUDIO.LOAD music,"1.ogg.mp3"
dim ball[1],WOOD[1]
begin:
score = 0
alpha =255
x=rnd()*sx
y=450
vx=15
vy=20
KX=KY=0
k =1
dt=0
vmin =15
n=3
xc[1]=sx/2:yc[1]= 300:Rc[1]=60
r[1]=255:g[1]=0:b[1]=0:a[1]=255
xc[2]=sx/2-200:yc[2]= 600:Rc[2]=40
r[2]=0:g[2]=255:b[2]=0:a[2]=255
xc[3]=sx/2+200:yc[3]= 600:Rc[3]=40
r[3]=0:g[3]=0:b[3]=255:a[3]=255
xc[4]=sx/2:yc[4]= 900:Rc[4]=60
r[4]=255:g[4]=0:b[4]=255:a[4]=255
xb= sx/2:yb=sy-70
lx=100:ly=25
do
!start =time()
!sensors.read 1, s[1],s[2],s[3]
!gr.rotate.start s[1],sx/2,0
!gr.rotate.end
x+= vx
y+= vy
if x<radius then
AUDIO.STOP
AUDIO.PLAY wall0
vx=-k*vx
!if abs(vx)> vmin then vibrate Pattern[],-1
x=radius
endif
if x>sx-radius then
AUDIO.STOP
AUDIO.PLAY wall0
!if abs(vx)>vmin then vibrate Pattern[],-1
vx=-k*vx
x= sx-radius
endif
if y<radius then
AUDIO.STOP
AUDIO.PLAY wall0
!if abs(vy)>vmin then vibrate Pattern[],-1
vy=-k*vy
y=radius
endif
!if y>sy-radius then
!if abs(vy)>vmin then vibrate Pattern[],-1
!vy=-k*vy
!y= sy-radius
!endif
gr.touch touched, xt, yt
if touched & abs(xt-xb)<=lx & abs(yt-yb)<=ly+50 then
xb= xt:yb=yt
endif
gosub collision
!xb+=-8*s[1]
if xb+lx>sx then xb=sx-lx
if xb-lx<0 then xb=lx
if (x>=xb-lx-20) & (x<=xb+lx+20) & (abs(y+radius-yb+ly)<=40) & (vy>=0) then
vy=-vy+0.1*(yt-ytp)
vx+=0.1*(xt-xtp)
y= yb-ly-radius
!vibrate Pattern[],-1
endif
if y>=sy then
gr.cls
GR.TEXT.SIZE 100
GR.TEXT.DRAW nc,100,600,"YOU LOSE"
gr.render
AUDIO.STOP
AUDIO.PLAY goal
pause 2000
goto begin
endif
if touched=0 then
KX=KY=0
endif
xtp=xt:ytp=yt
!dt=(time()-start)/1000
xtp=xt:ytp=yt
gosub render
!gr.render
until 0
exit:
END
collision:
for i=1 to n
tx = x-xc[i]
ty = y-yc[i]
t = (tx*tx+ty*ty)^0.5
tx=tx/t
ty=ty/t
nx=-ty
ny=tx
vt = vx*tx+vy*ty
vn = vx*nx+vy*ny
if (t<=radius+Rc[i]) & (vt<0) & (a[i]>30) then
gr.color 255,255,255,255
gr.circle nc,xc[i],yc[i],Rc[i]
gr.render
AUDIO.STOP
AUDIO.PLAY whee
vx = 1.0*(-vt*tx+vn*nx)
vy= 1.0*(-vt*ty+vn*ny)
score+=10
if (a[i]>30) then a[i]=a[i]-20.
w =(a[1]<=30) & (a[2]<=30) & (a[3]<=30) & (a[4]<=30)
if w then
AUDIO.STOP
AUDIO.PLAY music
gr.cls
gr.color 255,255,255,255
GR.TEXT.SIZE 100
GR.TEXT.DRAW nc,100,600,"YOU WIN"
gr.render
pause 1000*60
goto begin
endif
!vibrate Pattern[],-1
endif
next i
return
render:
gr.color 255,0,0,0
gr.cls
gr.bitmap.draw WOOD[1],PTR_wood,0,0
gr.bitmap.draw ball[1],ptr_ball,x-radius,y-radius
gr.color 255,255,255,0,1
gr.rect nc, xb-lx, yb-ly, xb+lx, yb+ly
for i=1 to n
gr.color a[i],r[i],g[i],b[i]
gr.circle nc,xc[i],yc[i],Rc[i]
next i
gr.color 255,255,255,1
GR.TEXT.SIZE 50
GR.TEXT.DRAW nc,10,50,"SCORE="
GR.TEXT.DRAW nc,200,50,str$(score)
gr.render
return
line:
for k=1 to nl
tx = xa[k]-xb[k]
ty= ya[k]-yb[k]
t = sqrt(tx*tx+ty*ty)
tx=tx/t:ty=ty/t
nx = -ty: ny= tx
return
Wakelock 3
dim xc[10]
dim yc[10]
dim Rc[10],r[10],g[10],b[10],a[10]
dim xa[10],ya[10],xb[10],yb[10]
choc =1
dim s[3]
gravity =0.3
radius =50
GR.OPEN 255, 0, 0,0
GR.ORIENTATION 1
GR.SCREEN sx, sy
ARRAY.LOAD Pattern[],100,10
sensors.open 1
GR.BITMAP.LOAD ptr_ball, "billet.png"
gR.BITMAP.LOAD ptr_wood, "wood.jpg"
AUDIO.LOAD whee, "flip-on3.ogg.mp3"
AUDIO.LOAD boing, "boing.mp3"
AUDIO.LOAD wall0,"wall0.ogg.mp3"
AUDIO.LOAD goal,"goal.mp3"
AUDIO.LOAD music,"1.ogg.mp3"
dim ball[1],WOOD[1]
begin:
score = 0
alpha =255
x=rnd()*sx
y=450
vx=15
vy=20
KX=KY=0
k =1
dt=0
vmin =15
n=3
xc[1]=sx/2:yc[1]= 300:Rc[1]=60
r[1]=255:g[1]=0:b[1]=0:a[1]=255
xc[2]=sx/2-200:yc[2]= 600:Rc[2]=40
r[2]=0:g[2]=255:b[2]=0:a[2]=255
xc[3]=sx/2+200:yc[3]= 600:Rc[3]=40
r[3]=0:g[3]=0:b[3]=255:a[3]=255
xc[4]=sx/2:yc[4]= 900:Rc[4]=60
r[4]=255:g[4]=0:b[4]=255:a[4]=255
xb= sx/2:yb=sy-70
lx=100:ly=25
do
!start =time()
!sensors.read 1, s[1],s[2],s[3]
!gr.rotate.start s[1],sx/2,0
!gr.rotate.end
x+= vx
y+= vy
if x<radius then
AUDIO.STOP
AUDIO.PLAY wall0
vx=-k*vx
!if abs(vx)> vmin then vibrate Pattern[],-1
x=radius
endif
if x>sx-radius then
AUDIO.STOP
AUDIO.PLAY wall0
!if abs(vx)>vmin then vibrate Pattern[],-1
vx=-k*vx
x= sx-radius
endif
if y<radius then
AUDIO.STOP
AUDIO.PLAY wall0
!if abs(vy)>vmin then vibrate Pattern[],-1
vy=-k*vy
y=radius
endif
!if y>sy-radius then
!if abs(vy)>vmin then vibrate Pattern[],-1
!vy=-k*vy
!y= sy-radius
!endif
gr.touch touched, xt, yt
if touched & abs(xt-xb)<=lx & abs(yt-yb)<=ly+50 then
xb= xt:yb=yt
endif
gosub collision
!xb+=-8*s[1]
if xb+lx>sx then xb=sx-lx
if xb-lx<0 then xb=lx
if (x>=xb-lx-20) & (x<=xb+lx+20) & (abs(y+radius-yb+ly)<=40) & (vy>=0) then
vy=-vy+0.1*(yt-ytp)
vx+=0.1*(xt-xtp)
y= yb-ly-radius
!vibrate Pattern[],-1
endif
if y>=sy then
gr.cls
GR.TEXT.SIZE 100
GR.TEXT.DRAW nc,100,600,"YOU LOSE"
gr.render
AUDIO.STOP
AUDIO.PLAY goal
pause 2000
goto begin
endif
if touched=0 then
KX=KY=0
endif
xtp=xt:ytp=yt
!dt=(time()-start)/1000
xtp=xt:ytp=yt
gosub render
!gr.render
until 0
exit:
END
collision:
for i=1 to n
tx = x-xc[i]
ty = y-yc[i]
t = (tx*tx+ty*ty)^0.5
tx=tx/t
ty=ty/t
nx=-ty
ny=tx
vt = vx*tx+vy*ty
vn = vx*nx+vy*ny
if (t<=radius+Rc[i]) & (vt<0) & (a[i]>30) then
gr.color 255,255,255,255
gr.circle nc,xc[i],yc[i],Rc[i]
gr.render
AUDIO.STOP
AUDIO.PLAY whee
vx = 1.0*(-vt*tx+vn*nx)
vy= 1.0*(-vt*ty+vn*ny)
score+=10
if (a[i]>30) then a[i]=a[i]-20.
w =(a[1]<=30) & (a[2]<=30) & (a[3]<=30) & (a[4]<=30)
if w then
AUDIO.STOP
AUDIO.PLAY music
gr.cls
gr.color 255,255,255,255
GR.TEXT.SIZE 100
GR.TEXT.DRAW nc,100,600,"YOU WIN"
gr.render
pause 1000*60
goto begin
endif
!vibrate Pattern[],-1
endif
next i
return
render:
gr.color 255,0,0,0
gr.cls
gr.bitmap.draw WOOD[1],PTR_wood,0,0
gr.bitmap.draw ball[1],ptr_ball,x-radius,y-radius
gr.color 255,255,255,0,1
gr.rect nc, xb-lx, yb-ly, xb+lx, yb+ly
for i=1 to n
gr.color a[i],r[i],g[i],b[i]
gr.circle nc,xc[i],yc[i],Rc[i]
next i
gr.color 255,255,255,1
GR.TEXT.SIZE 50
GR.TEXT.DRAW nc,10,50,"SCORE="
GR.TEXT.DRAW nc,200,50,str$(score)
gr.render
return
line:
for k=1 to nl
tx = xa[k]-xb[k]
ty= ya[k]-yb[k]
t = sqrt(tx*tx+ty*ty)
tx=tx/t:ty=ty/t
nx = -ty: ny= tx
return
Aucun commentaire:
Enregistrer un commentaire
Remarque : Seul un membre de ce blog est autorisé à enregistrer un commentaire.