Hi@all!
I´ve got two problems,that makes me crazy!
I want to create a 2D Sidescroll Game like Sonic,Mega Man,Super Mario etc.
Since 3 weeks i try to find a way,to scroll my background.
I founded some Tutorials and examples about scrolling here but they are always about scrolling a Text or scrolling like a spaceshooter(automatically).My problem is:
When the player has reached a certain position x on the screen the background (a textured plain) have to scroll so far like the player has gone from the position x.
I thought the command "scroll object texture" is a good method but it wasn´t.
The second problem is to mirror the player sprite,(The sprite is from a spritesheet)when he goes in the other direction.(From left to right and vice versa)
Can anybody show me a way in the right direction,please?
Here´s my Code so far:
`*************
`** 2D GAME **
`*************
gosub screen
gosub map
gosub player
#constant screenwidth = 800
#constant screenheight = 600
player_x# = 60
player_y# = 448
player_speed# = 5
do
sprite 1,player_x#,player_y#,2
gosub move_player
gosub move_background
sync
loop
screen:
set display mode screenwidth,screenheight,16
sync on : sync rate 50
backdrop off
set image colorkey 255,0,255
return
map:
plain = 77 : plain_sx = 800 : plain_sy = 400 :
plainpos_x = 1060 : plainpos_y = 40
img_map = 1
make object plain plain,plain_sx,plain_sy
position object plain,plainpos_x,plainpos_y,0
scale object plain,450,200,400
xrotate object plain,-9.45
load image "map.bmp",img_map
texture object plain,img_map
set ambient light 70
return
player:
img_hero = 2
load image "hero.bmp",img_hero
create animated sprite 1,"hero.bmp",16,1,2
set sprite 1,1,1
return
move_player:
If rightkey()=0 and leftkey()=0 then set sprite frame 1,1
if rightkey()=1 and leftkey()=0 then play sprite 1,3,11,50
if rightkey() then inc player_x#,player_speed#
if leftkey()=1 and rightkey()=0 then play sprite 1,3,11,50
if leftkey() then dec player_x#,player_speed#
return
move_background:
if player_x# > 500 then scroll object texture 77,0.001,0.0
if player_x# < 50 then scroll object texture 77,-0.001,0.0
return
Thanks for your help!