Here's a very basic tiling system with a sprite positioned at the centre of the screen. Movement is via the cursor keys, and the sprite switches images depending on which way it is moving.
Have a quick look through and try to understand it. If you have any questions, just come back and ask
flush video memory
sync on
sync rate 0
hide mouse
BuildBackgroundTile()
BuildSpriteImages()
dim map(19,19) as integer
for x=0 to 19
for y=0 to 19
map(x,y)=1
next y
next x
x=0
y=0
sprite 1,320,240,2
offset sprite 1,31,31
do
if leftkey()=1 and x<0 then inc x,4 : set sprite image 1,4
if rightkey()=1 and x>(-64*9) then dec x,4 : set sprite image 1,5
if upkey()=1 and y<0 then inc y,4 : set sprite image 1,2
if downkey()=1 and y>(-64*9) then dec y,4 : set sprite image 1,3
DrawMap(x,y)
sync
loop
wait key
function DrawMap(bx as integer, by as integer)
local sx as integer
local sy as integer
local x as integer
local y as integer
for x=0 to 19
sx=bx+(x*64)
if sx > -64 and sx < bitmap width()
for y=0 to 19
sy=by+(y*64)
if sy > -64 and sy < bitmap height()
paste image map(x,y), sx, sy
text sx, sy, str$(x) + "/" + str$(y)
endif
next y
endif
next x
endfunction
function BuildBackgroundTile()
box 0,0,64,64,rgb(255,0,0),rgb(0,0,255),rgb(0,255,0),rgb(127,0,127)
get image 1,0,0,64,64,1
endfunction
function BuildSpriteImages()
` Just triangles to give the effect
cls : for x=0 to 63 : line 31,0,x,63 : next x : get image 2,0,0,64,64,1
cls : for x=0 to 63 : line 31,63,x,0 : next x : get image 3,0,0,64,64,1
cls : for x=0 to 63 : line 0,31,63,x : next x : get image 4,0,0,64,64,1
cls : for x=0 to 63 : line 63,31,0,x : next x : get image 5,0,0,64,64,1
endfunction