I think ive got something very similar to the above piece of code working now
function createRobot()
loadBuildSprites()
SetSpriteVisible(500,0)
SetSpriteVisible(501,0)
SetSpriteVisible(502,0)
SetSpriteVisible(503,0)
SetSpriteVisible(504,0)
SetSpriteVisible(505,0)
xspd as float `X speed of tiles
xpos as float `X position of tiles
cpx as float `Current Pointer X `(from this frame)
lpx as float `Last Pointer X `(from last frame)
vw=GetVirtualWidth():vh=GetVirtualHeight():iw=GetImageWidth(100):ih=GetImageHeight(100)
xpos=0
xspd=0
cpx=0
lpx=0
rollingMenu=1
do
lpx=cpx
cpx=GetPointerX()
`
if GetPointerState()
xspd=cpx-lpx
endif
//friction
for k=1 to 3
if xspd<-friction*k*2
xspd=xspd+friction
elseif xspd>friction*k*2
xspd=xspd-friction
else
xspd=0
endif
next
//limits
if xpos>5
xspd=xspd/2
if GetPointerState()=0
xspd=xspd-1.5
endif
endif
if xpos<-(128*(11-4))
xspd=xspd/2
if GetPointerState()=0
xspd=xspd+1.5
endif
endif
xpos=xpos+xspd
count=0
for t = 100 to 111
SetSpritePositionByOffset(t,xpos+(count*128),vh-ih)
if GetPointerReleased()
exit
endif
inc count
next t
if GetPointerReleased()
num=GetSpriteHit(GetPointerX(),GetPointerY())
print("hello")
if num>=100 and num <=111
id=CloneSprite( num )
SetSpriteOffset(id,64,64)
rollingMenu=0
endif
endif
if rollingMenu=0
SetSpritePositionByOffset(id,GetPointerX(),GetPointerY())
if GetPointerPressed()
rollingMenu=1
magneticSprite(id)
endif
endif
sync()
loop
endfunction
function magneticSprite(id as integer)
xx=GetSpriteXByOffset(id)
yy=GetSpriteYByOffset(id)
newx=0:newy=0
for y = 0 to 2
if yy > (y*128) and yy < (y+1)*128
newy=(y*128)+64
exit
endif
next y
for x = 0 to 4
if xx> (x*128) and xx < (x+1)*128
newx=(x*128)+64
exit
endif
next x
if newx=0 or newy=0
DeleteSprite(id)
sync()
else
SetSpritePositionByOffset(id,newx,newy)
endif
endfunction
The project is a very simple and cut down version of a robots style game
where you build a robot with and gates and or gates
where you have very limited options to building your robot
Move Forward
Move backward
Turn clockwise 15
Turn counterclockwise 15
scan left
Scan right
scan forward
scan backward
Shoot
combined with some and and or logic I'm planning on
using an array to control how the robot handles the logic.
Once you've figured out the layout and design of the internal workings
of the robot. You will be able to put it against others. The designing of the
robot has a rolling menu where you select the parts and place them
magnetically on the grid above. Which is basically how it will be stored in an
array. While building the robots you will have to solder the parts to connect
them haven't worked out all the workings yet but have a good idea how I want it
fubar