heres a complete working example of a side scrolling game with a background and a foreground
use the arrowkeys to move around
no media needed
I only used images, you'll have to adjust it for sprite and I used 32x32 tiles, you'll need to adjust it for bigger tiles.
It's not ment to show you everything but you should be able to figure it out and expand on it real easy, it only took me about 30 minutes to make, so image what you can do with more time.
CTP
Rem Project: simple side scroller
Rem Created: 11/16/03 1:26:03 PM
rem by John Chase
rem ***** Main Source File *****
sync rate 30
sync on
rem set up some 32x32 blocks for the demo
rem 5 should be enough
for i = 1 to 5
ink rgb(rnd(255),rnd(255),rnd(255)),0
box 0,0,32,32
get image i,0,0,32,32
next i
paste image 3,0,0
circle 15,15,10
get image 3,0,0,31,31
rem image 1,2 background
rem image 3 character
rem image 4,5 foreground
global backgroundscrollrate : backgroundscrollrate = 1
global foregroundscrollrate : foregroundscrollrate = 2
global backgroundxoffset : backgroundxoffset = 0
global foregroundxoffset : foregroundxoffset = 0
global backgroundx : backgroundx = 0
global foregroundx : foregroundx = 0
global characterx : characterx = 10
global charactery : charactery = 5
global characterspeed : characterspeed = 3
rem build the map
rem a map editor is a must make thing
dim map(500,20,3)
for x=0 to 500
for y = 0 to 20
map(x,y,1) = rnd(1)+1
if rnd(100) > 95
map(x,y,2) = rnd(1)+4 : rem only 5 percent of the for ground will be there
else
map(x,y,2) = 0
endif
next y
next x
do
scroll_background()
scroll_foreground()
if foregroundx > 480 then end
move_character()
draw_background()
paste image 3, characterx, charactery
draw_foreground()
sync
loop
function move_character()
if upkey() then dec charactery, characterspeed : if charactery < 0 then charactery = 0
if downkey() then inc charactery, characterspeed : if charactery > 448 then charactery = 448
if rightkey() then inc characterx, characterspeed : if characterx > 608 then characterx = 608
if leftkey() then dec characterx, characterspeed : if characterx < 0 then characterx = 0
endfunction
function scroll_background()
inc backgroundxoffset, backgroundscrollrate
if backgroundxoffset > 31
backgroundxoffset = 0
inc backgroundx, 1
endif
endfunction
function scroll_foreground()
inc foregroundxoffset, foregroundscrollrate
if foregroundxoffset > 31
foregroundxoffset = 0
inc foregroundx, 1
endif
endfunction
function draw_background()
for x = 0 to 20
for y = 0 to 15
paste image map(x+backgroundx,y,1),x*32-backgroundxoffset,y*32
next y
next x
endfunction
function draw_foreground()
for x = 0 to 20
for y = 0 to 15
if map(x+foregroundx,y,2) > 0 then paste image map(x+foregroundx,y,2),x*32-foregroundxoffset,y*32
next y
next x
endfunction
Lifes short, try to enjoy it and not take it to seriously!