Okay I'm working on a scrolling game of sorts, and have never done any scrollers before, in fact im prettty enw to scratch. Thing is when i reasearched scrollers it seems like i can eaither mvoe the sprite OR the background, and as I'm trying to make a Zelda-themed game neitehr works real well, or rather has limits. I've heard rumors of a way to make it so the main sprite(Link in my case) can move from like 1 half to the otehr without moving teh background but when he gets close enough to the edge of the screen, the background starts scrolling along with him. Anybody know where I could get some help for that?
Offline
Here's what I think the code for that should look like. I assume you want to scroll like in the original mario game.
if (left key pressed)
move sprite to the left
if (right key pressed)
if (sprite's X position>0)
scroll to the right
else
move sprite to the right
That should cover all of your moving & scrolling needs.
Last edited by archmage (2008-11-03 21:54:28)
Offline
I think archmage means this:
Have a variable called scrollx and one called sprite<( <>> )>
Then do this script
[blocks]<when green flag clicked>
<forever>
<if><key[ left arrow ]pressed?>
<move(-10 )steps>
<end>
<if><key[ right arrow ]pressed?>
<if><(<{sprite }> <>> 0 )>
<change{ scrollx }by( -1
<else>
<move( 10 )steps>
<end>
<end>
<end>[/blocks]
For Sprite variable we do this.
[blocks]<when green flag clicked>
<forever>
<set{ sprite }to( <x position>
<end>
Now for jumping we can do this. Have a variable called yVelocity.
This is the script you can put in.
<when green flag clicked>
<set{ yVelocity }to( 0
<forever>
<if><touching[ ground
<set{ yVelocity }to( 0 )
<else>
<change{ yVelocity }by( -1
<change y by( <{ yVelocity }>
<end>
<end>
Offline
yea, my RPG demo has that type of scrolling in X as well as Y if you want to have a look
Offline