In a scrolling game the person doesn't move, but rather, the multiple "terrain" sprites are sliding, creating the illusion of movement.
When you make a scroller, an important script is this. (This is one method of scrolling that I use)
(Terrain 0)
[blocks]
<when green flag clicked>
<forever>
<go to x ((scrollx<+>((480 <*>0 )) )) )y 0
<end>
[/blocks]
(note y is 0, since this is a side/horizontal scroller.)
(scrollx is a variable you have to make)
The next terrain you make will have a similar script, but instead of x:(scrollx)+(480)*(0)
it becomes x:(scrollx)+(480)*(1). For the next terrain the factor is manually changed up by one again to x:(scrollx)+(480)*(2), then *(3), and so on.
If the blocks didn't come out clear enough, here is a wiki article that might help: http://wiki.scratch.mit.edu/wiki/Scrolling
Offline
When having a scrolling game, it helps to try and think of everything in relativity. That is, when you're moving, the backgrounds are moving relative to you. If you want an enemy to move independent from your movements, you'll have to make it move relatively to you and the background.
For example: You, the car, are racing at a good 300km/h. You're an awesome racer that's barelling past the other drivers. You decide that that's a little fast for scratch, so you scale it down to 15 steps. At that speed you'd race outta the screen and be gone forever so you decide to make the ground move instead. You look like you aren't moving, but since you're moving at 15 steps, the ground will move at -15 steps relative to you. That's the basic idea of a scrolling game.
You want to have the opponent moving right? Well okay. So there's some guy in front of you that you have to pass, He's a ways ahead, a good 240 steps ahead of you, but he's not moving as quickly as you. He's Moving at 240km/h, compared to your awesome 300km/h. Well down to scale, he's moving 12 steps.
Relative to your 15 steps, he's going 3 steps slower than you. Since you're the one who isn't moving, he'll be going his speed minus yours. which is to say, 12 - 15 = -3 So that racer you're passing will move -3 steps, though his speed relative to himself is 12.
This fits in with Einstein's theory of general relativity, which you will end up learning in school, it's a helpful concept to understand depending on what you want to do later in life.
I hope this helped.
Offline
scratchU8, are you saying you want two players in the game? each controlling a different sprite?
Offline
Simplified. The you get multiple sprites, or terrains, to stick together as a large level. Then each will have a script similar to this:
When flag clicked
forever
set x to scrollx + (360 * 0)
And you change the 0 to how far the terrain should be. Last but not least is your character. It never actually moves, it just controls how the terrains move to create an illusion of movement. So a basic movement (just movement) script would look like this:
when flag clicked
forever
if left arrow clicked
change ScrollX by 5
if right arrow clicked
chnage ScrollX by -5
The numbers are mean't to be the opisite way round. You can do all the sensing and stuff yourself but thats the basics of scrolling.
Offline
Well, you see you guys, this is exactly what I want:
So, let's say it's a normal scrolling platformer game. So you're walking, la di da. BUT. You're racing someone else on foot. So, like, it's a normal scrolling game. But, like, the guy that goes foward constantly. So, like, meh. it's hard to explain, but. I want the second player to move along the scrolling terrian that has the same contorls or something like Player 1, except the guy you're racing is a computer, and moves ahead automaticaly. I don't want two screens, I want the CPU to move on the same screen as yours.
Sorry if that was confusing.
Offline
Well, for the other guy, choose a terrain for the other guy to start from, then give him is script:
When flag clicked
Forever
Set x to scrollX + 480 * 0 + MyX
Then change MyX when your character moves. Also, change the 0 to wherever you want they guy to start from. I haven't tested it out yet but it's worth a try.
Offline
@Above You will get Scratcher status when you become more active on both the forums and the main website. Once you get the status, you can get a signature. Also, you can check your status when you have a look at a post you made, at the left is your username and your status underneath. You can also check when you first started and how many posts you have made in your time on the Scratch forums.
Offline
Improving Neil Wests script, instead of adding Myx to the whole thing you replace 0 with Myx like so
When green flag clicked
set Myx to (where you want it to go)
forever start
set x to scroll x + 480 * Myx
forever end
then you could do this to make it move
when green flag clicked
forever start
repeat 5
change Myx by 0.075
repeat end
repeat 5
change Myx by 0.075
repeat end
forever end
that will make it so it moves back and forth along the terrain pretty quickly.
Offline
Just like to say that i got a new method i recently tested (and succeeded) which puts the player on the slant of and bumps in the hill they are on. A link is here, hope it helps. http://scratch.mit.edu/projects/plobnob/2317212
Offline