I have just been playing around with multiple tile scrolling
I'm still yet to try scrolling with the uv commands but I thought ide share
I have 20 random coloured tiles which the following code manipulates
around the screen with the arrow keys. I hope this will help people
its not well documented but should be easy enuff to follow
I posted here as its not completed but I see many posts asking for
scrolling help etc
SetVirtualResolution(1024,768)
GLOBAL Block as integer[5,4]
for y= 1 to 4
for x = 1 to 5
Block[x,y] = createSprite(0)
setSpriteSize(Block[x,y],300,300)
setSpritePosition(Block[x,y],(x-1)*300,(y-1) * 300)
setSpriteColor(Block[x,y],random(1,255),random(1,255),random(1,255),255)
next x
next y
do
speed#=10
if GetRawKeyState(37) //left arrow pressed
ScrollRight(speed#)
endif
if GetRawKeyState(39) //right arrow pressed
ScrollLeft(-speed#)
endif
if GetRawKeyState(38) //up arrow key pressed
ScrollDown(speed#)
endif
if GetRawKeyState(40) //Down arrow pressed
ScrollUp(-speed#)
endif
Sync ()
loop
function ScrollUp(y# as integer)
for y=1 to 4
for x = 1 to 5
SetSpritePosition (Block[x,y], getSpritex(Block[x,y]), GetSpriteY (Block[x,y]) + y#)
next x
for x = 1 to 5
if getSpriteY(Block[x,y])<-300
SetSpritePosition (Block[x,y], getSpritex(Block[x,y]), GetSpriteY (Block[x,y]) + 1200)
endif
next x
next y
endfunction
function ScrollDown(y# as integer)
for y=1 to 4
for x = 1 to 5
SetSpritePosition (Block[x,y], getSpritex(Block[x,y]), GetSpriteY (Block[x,y]) + y#)
next x
for x = 1 to 5
if getSpriteY(Block[x,y]) > GetVirtualHeight()
SetSpritePosition (Block[x,y], getSpriteX(Block[x,y]), GetSpriteY (Block[x,y]) - 1200)
endif
next x
next y
EndFunction
function ScrollLeft(x# as integer)
for y=1 to 4
for x = 1 to 5
SetSpritePosition (Block[x,y], GetSpriteX (Block[x,y]) + x#, GetSpriteY (Block[x,y]) )
next x
for x = 1 to 5
if getSpriteX(Block[x,y])<-300
SetSpritePosition (Block[x,y], GetSpriteX (Block[x,y]) + 1500, GetSpriteY (Block[x,y]))
endif
next x
next y
endfunction
function ScrollRight(x# as integer)
for y=1 to 4
for x = 1 to 5
SetSpritePosition (Block[x,y], GetSpriteX (Block[x,y]) + x#, GetSpriteY (Block[x,y]) )
next x
for x = 1 to 5
if getSpriteX(Block[x,y])> getVirtualWidth()
SetSpritePosition (Block[x,y], GetSpriteX (Block[x,y]) - 1500, GetSpriteY (Block[x,y]))
endif
next x
next y
endfunction
fubar