Graphics On
Sensors On
CLS
'Orientation 2
Global px,py,ps,Rtch,wc,bc,Rbx,Rby,Lbx,Lby
Global Bbx,Bby,Tbx,Tby,pspx, pspy,fd, send
Global FpsTimer
send = 0
pspx = 300
pspy = 500
px = pspx
py = pspy
wc = 100
ps = 50
bc = 0
fd = 0
rem the controles setup
Rbx = 600
Rby = 1000
Lbx = 480
Lby = 1000
Tbx = (600+480)/2
Tby = 880
Bbx = (600+480)/2
Bby = 1120
rem accelerometer setup
Dim a(5)
a(0) = 1
a(1) = 1
a(2) = 1
a(3) = 1
a(4) = 1
width = 100
height = 100
bitmap = CreateBitmap(width/4, height/4)
' Make the bitmap a green box with two diagonal lines.
SetDrawingSurface bitmap
Color 0,100,0
CLS
ex = GetBitmapWidth(bitmap) - 1
ey = GetBitmapHeight(bitmap) - 1
Color 0,0,0
Line 0,0,ex,ey
Line ex,0,0,ey
Color 100,0,0
Rect 0,0,ex,ey
SetDrawingSurface Off
DrawBitmap bitmap, width/2, height/2
global pmy, pmx, gtchx,gtchy
pmy = pspy
pmx = pspx
do
Rem update screen
syncscreen()
Rem get fps sync
GetFps = sync()
' letter("c",10,20,10)
'letter("a",25,20,10)
'letter("b",40,20,10)
'text(10,40,"cab")
Rem draw player
drawplayer()
fr = Button(100,1000,80,80)
if fr = 1 and fd > -1 then
fire = 1
fr = 0
endif
life = 50
bsize = 50
if lifec >= life then
lifec = 0
pmx = px
pmy = py
fire = 0
else
if fire = 1 then
if fd = 0 then pmy = dec(pmy,5)
if fd = 1 then pmy = inc(pmy,5)
if fd = 0 then line pmx,pmy,pmx, pmy-bsize
if fd = 1 then line pmx,pmy +(bsize*2) ,pmx, pmy+(bsize*3)
lifec=lifec+1
if fd = 2 then pmx = dec(pmx,5)
if fd = 2 then line pmx-bsize,pmy,pmx,pmy
if fd = 3 then pmx = inc(pmx,5)
if fd = 3 then line pmx,pmy,pmx+bsize,pmy
endif
endif
Rem update p controles
playercontroler()
Loop
rem increment value
sub inc(value,amt)
value = value + amt
Return value
end sub
rem decrement value
sub dec(value,amt)
value = value - amt
Return value
end sub
rem update value
sub sync()
FpsTimer = FpsTimer + 1
If FpsTimer = 0 then flip = 1
If FpsTimer = 0 then FpsTimer = 1 : flip = 1 : Endif
If FpsTimer = 1 and flip = 0 Then FpsTimer =0
return FpsTimer
end sub
rem native text control
sub letter(letter$,x,y,ls)
rem here is a library of letter made by me
lw = ls
lh = ls
Select letter$
Case "a"
line x,y+(lh/3),x+(lw/2),y-lh 'left
line x+(lw/2),y-lh,x+lw,y+(lh/2) 'right
line x,y-(lh/2),x+lh,y-(lh/2) 'middle
Case "b"
line x,y+(lh/4),x,y-lh 'back
line x,y-lh,x+lw,y-lh 'top
line x,y-(lh/2),x+lh,y-(lh/2) 'middle
line x,y+(lh/4),x+lw,y+(lh/4) 'botton
line x+lw,y-lh,x+lw,y+(lh/4) 'right
Case "c"
Line x,y,x+lw,y-lh
Line x,y,x+lw,y+(lh/2)
end select
end sub
rem line of text
sub text(x,y,text$)
ssz = len(text$)
for n = 1 to ssz
lettr$ = mid$(text$,n,1)
letter(lettr$,x+(n*15),y,10)
next n
end sub
Rem update player controller
sub playercontroler()
s = gtchx
d = gtchy
Rem update button to screen
' rect Rbx ,Rby,Rbx+100,Rby+100
'rect Lbx ,Lby,Lbx+100,Lby+100
'rect Tbx ,Tby,Tbx+100,Tby+100
'rect Bbx ,Bby,Bbx+100,Bby+100
Rem pause get input
Rem use input values to detect buttons
Rb = Button(Rbx,Rby,100,100) 'right button
Lb = Button(Lbx,Lby,100,100) 'left button
Tb = Button(Tbx,Tby,100,100) 'top button
Bb = Button(Bbx,Bby,100,100) 'bottom button
Rem handle buttons updates
Rem right button update
If Rb = 1 or getacx() < -1 Then
px = px + 1
Rb = 0
fd = 3
Endif
Rem left button update
If Lb = 1 or getacx() > 1Then
px = px - 1
fd = 2
Lb = 0
Endif
Rem top button update
If Tb = 1 or getacy() < 6 Then
py = py - 1
fd = 0
Tb = 0
Endif
Rem bottom button update
If Bb = 1 or getacy() > 8 Then
py = py + 1
fd = 1
Bb = 0
Endif
Touch gtchx,gtchy,10
end sub
Rem draw / update player
sub drawplayer()
Rem draw player
Select fd
Case 0
Rem triangle facing up
Triangle px,py,px+ps,py+ps,px-ps,py+ps
Case 1
Rem triangle facing down
Triangle px,py+(ps*2),px+ps,py+ps,px-ps,py+ps
Case 2
Rem triangle facing left
Triangle px-ps,py+ps,px,py+(ps*2),px,py
Case 3
Rem triangle facing left
Triangle px+ps,py+ps,px,py+(ps*2),px,py
End select
end sub
Rem update accelerometrr input
'a(0) = Acceleration minus Gx on the x-axis.
'a(1) = Acceleration minus Gy on the y-axis.
'a(2) = Acceleration minus Gz on the z-axis
sub getacx()
Rem update the acceleromerter input
a() = GetAccelerometer()
send = a(0)
return send
end sub
sub getacy()
a() = GetAccelerometer()
send = a(1)
return send
end sub
sub getacz()
a() = GetAccelerometer()
send = a(2)
return send
end sub
Rem update screen and re color
sub syncscreen()
Rem update bg white and sync
ubc(wc,1)
Rem change def 2d color to black
ubc(bc,0)
end sub
rem update backscreen
sub ubc(col,ud)
color col,col,col
if ud = 1 then cls
end sub
rem some stuff
sub Button(x,y,w,h)
s = gtchx
d = gtchy
rect x ,y,x+w,y+h
If s <> -1 then
If d <> -1 then
If s > x and s < x + w and d > y and d < y + h then
Rtch =1
Else
Rtch =0
Endif
endif
endif
Return Rtch
End sub