// Project: enginetest
// Created: 2014-11-03
SetDisplayAspect( 800.0 / 600.0 )
#constant KEY_Q = 81
#constant KEY_J = 74
global cursorsprite = 5000
global cursorimage = 2
global swidth = 4
global sheight = 4
global level = 1
global quit = 0
global bricklimit = 4999
global playersprite=5000
global keyboard = 0
global ballSpr=0
type tobjects
xpos# as float
ypos# as float
spritenumber as integer
physicstype as integer
spriteshape as integer
sizex as integer
sizey as integer
imagenum as integer
sprgroup as integer
sprdepth as integer
spriteangle as integer
spritetype as integer
spritelayer as integer
endtype
dim object[5000] as tobjects
dim image_bank[800]
type TMouse
x1#
y1#
x2#
y2#
x3
y3
endtype
global Mouse as TMouse
init()
load_level(level)
CreateText(1,"")
repeat
if getrawkeypressed(KEY_Q)
quit = 1
endif
x# = GetVirtualJoystickX(1)
y# = GetVirtualJoystickY(1)
Print(str(x#,1)+"/"+str(y#,1))
if x# > 0.2
SetSpritePhysicsForce(ballSpr, GetSpriteXByOffset(ballSpr), GetSpriteYByOffset(ballSpr), 20000.0, 0)
endif
if x# < -0.2
SetSpritePhysicsForce(ballSpr, GetSpriteXByOffset(ballSpr), GetSpriteYByOffset(ballSpr), -20000.0, 0)
endif
if y# < -0.2
SetSpritePhysicsForce(ballSpr, GetSpriteXByOffset(ballSpr), GetSpriteYByOffset(ballSpr), 0, -20000)
endif
Print( ScreenFPS() )
SetTextPosition(1,0,5)
Sync()
until quit=1
function init()
for n=1 to 100
f$=str(n) + ".png"
if getfileexists(f$)
loadimage (n,f$)
endif
next
SetClearColor(0,0,0)
ClearScreen()
keyboard = getKeyboardExists()
if keyboard=0
rem create a virtual joystick
AddVirtualJoystick(1,10,88,12)
rem create a jump button
AddVirtualButton(1,90,88,8)
endif
endfunction
function load_level(level)
clear_level()
f$=""
f$="level"
f$=f$+str(level)
f$=f$+".lev"
if getfileexists(f$) =0
print (" level file doesn't exist ")
sync()
sleep (3000)
found3=1
endif
if found3=0
myfile = OpenToread(f$)
for n=1 to bricklimit
xp#=readfloat(myfile)
yp#=readfloat(myfile)
sprnum=readinteger(myfile)
phytype=readinteger(myfile)
sprshape=readinteger(myfile)
sx=readinteger(myfile)
sy=readinteger(myfile)
imgnum=readinteger(myfile)
sprgroup=readinteger(myfile)
sprdepth=readinteger(myfile)
sprangle=readinteger(myfile)
sprtype=readinteger(myfile)
sprlayer=readinteger(myfile)
object[n].xpos#=xp#
object[n].ypos#=yp#
object[n].spritenumber=sprnum
object[n].physicstype=phytype
object[n].spriteshape=sprshape
object[n].sizex = sx
object[n].sizey = sy
object[n].imagenum=imgnum
object[n].sprgroup=sprgroup
object[n].sprdepth=sprdepth
object[n].spriteangle=sprangle
object[n].spritetype=sprtype
object[n].spritelayer=sprlayer
if object[n].spritenumber>0 and object[n].sprgroup = 0
createsprite(sprnum,imgnum)
setspritesize(sprnum,sx,sy)
setspriteposition(sprnum,xp#,yp#)
setSpritePhysicsOn(sprnum,1)
endif
if object[n].spritenumber>0 and object[n].sprgroup = 1
make_player(object[n].xpos#,object[n].ypos#,object[n].sizex,object[n].sizey)
endif
next n
endif
closefile(myfile)
endfunction
function clear_level()
for n=1 to bricklimit
object[n].xpos#=0
object[n].ypos#=0
object[n].spritenumber=0
object[n].physicstype=0
object[n].spriteshape=0
object[n].sizex = 0
object[n].sizey = 0
object[n].imagenum=0
object[n].sprgroup=0
object[n].sprdepth=0
object[n].spriteangle=0
object[n].spritetype=0
object[n].spritelayer=0
deletesprite(n)
next n
endfunction
function make_player(x#,y#,sx,sy)
ballImg = LoadImage("JoystickInner.png")
ballSpr = CreateSprite(1)
SetSpritePosition(ballSpr, x#,y#)
setspritesize(ballSpr,sx,sy)
SetSpriteOffset(ballSpr, GetSpriteWidth(ballSpr)/2, GetSpriteHeight(ballSpr)/2)
SetSpriteColor(ballSpr, 255, 255, 100, 255)
SetSpriteShape(ballSpr, 2)
SetSpritePhysicsOn(ballSpr, 2)
SetSpritePhysicsRestitution(ballSpr, 0.5)
SetSpritePhysicsFriction(ballSpr, 10.0)
endfunction
Tablet screen shot
Windows screen shot
kinda that problem to simulate how it looks on the tablet with less hassle!
Hail to the king, baby!
http://davidjohnwheeler.blogspot.co.uk