Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Side-Scroller walking
- ArcherFuse
-
8 posts
Side-Scroller walking
Hello, everyone!
I'm going to make a side-scroller and need some help! I have the game planned out, and have the prototype artwork; all that's left is the scripts.
I'm not a novice to scratch (second account), but I have never made a side-scroller before and need some help with the movement.
As most of you can notice, in a professional side-scroller like Mario or Sonic the character doesn't stay in one place the whole time, it accelerates and deccelerates with the background. What I mean is that the character doesn't stay at x: 0 y: 0 the whole time, it ends up at like x: 35.
I've been trying for the past 2 weeks to recreate this, but to no avail. I am wondering if anyone out there can show me the script and calculations, and briefly explain them to me, so I can reuse it? All help and input is appreciated!
Thanks in advance, Archerfuse.
I'm going to make a side-scroller and need some help! I have the game planned out, and have the prototype artwork; all that's left is the scripts.
I'm not a novice to scratch (second account), but I have never made a side-scroller before and need some help with the movement.
As most of you can notice, in a professional side-scroller like Mario or Sonic the character doesn't stay in one place the whole time, it accelerates and deccelerates with the background. What I mean is that the character doesn't stay at x: 0 y: 0 the whole time, it ends up at like x: 35.
I've been trying for the past 2 weeks to recreate this, but to no avail. I am wondering if anyone out there can show me the script and calculations, and briefly explain them to me, so I can reuse it? All help and input is appreciated!
Thanks in advance, Archerfuse.
Last edited by ArcherFuse (May 23, 2016 03:46:27)
- mstone326
-
1000+ posts
Side-Scroller walking
Enemy placement and movement is also quite different on side scrollers. Here is a small project I made that has a few scrolling enemy types that have their own local (this sprite only) variables. Their code moves them within the world.
The types are enemies until hitting the user, user terminating the enemy, off screen (example types from Super Mario Brothers)
move back and forth (ex: super mario bros goomba stuck between pipes or a platform)
Move from right to left at a speed (ex: bullet bill, goomba walking left)
Bouncing when touching the ground moving right to left ( flying koopa)
moving up and down (the koopas that float or a platform)
stationary sprite but that hammers arc out of with velocity and gravity (ex: hammer brothers)
Note:
I haven't added gravity to any of the above except for the bouncing koopa. I'm planning on adding to every enemy local gravity so if you jump over them and then run into a hole they will fall in and be gone, only the bouncing koopa does that.
I will also add actual platforms back and forth and up and down with the scripts needed so your controllable sprite can stay on them. Hope this helps. Good luck. I assume your not this far yet. But hold this post for when you get there and start placing enemies. But Griffpatch's tutorials are the way to follow. Each are excellent.
https://scratch.mit.edu/projects/108361157/
The types are enemies until hitting the user, user terminating the enemy, off screen (example types from Super Mario Brothers)
move back and forth (ex: super mario bros goomba stuck between pipes or a platform)
Move from right to left at a speed (ex: bullet bill, goomba walking left)
Bouncing when touching the ground moving right to left ( flying koopa)
moving up and down (the koopas that float or a platform)
stationary sprite but that hammers arc out of with velocity and gravity (ex: hammer brothers)
Note:
I haven't added gravity to any of the above except for the bouncing koopa. I'm planning on adding to every enemy local gravity so if you jump over them and then run into a hole they will fall in and be gone, only the bouncing koopa does that.
I will also add actual platforms back and forth and up and down with the scripts needed so your controllable sprite can stay on them. Hope this helps. Good luck. I assume your not this far yet. But hold this post for when you get there and start placing enemies. But Griffpatch's tutorials are the way to follow. Each are excellent.
https://scratch.mit.edu/projects/108361157/
Last edited by mstone326 (May 23, 2016 02:56:57)
- ArcherFuse
-
8 posts
Side-Scroller walking
I don't think I explained well, so let me elaborate! What I meant is that if you look at sonic, mario, or even kenney https://scratch.mit.edu/projects/104297197/
you can see that the player doesn't stay at x: 0 y: 0 the whole time, the player sprite accelerates across the screen. I'm just not sure how to make it look nice and smooth! Thanks for the replies, though
you can see that the player doesn't stay at x: 0 y: 0 the whole time, the player sprite accelerates across the screen. I'm just not sure how to make it look nice and smooth! Thanks for the replies, though

- deck26
-
1000+ posts
Side-Scroller walking
Presumably you have a scrollX variable though so the backdrops can be positioned. The normal trick is to add or subtract scrollX from a fixed multiple of 480 (screen widtth).
What that means is that a particular backdrop has fixed ‘world’ coordinates and scrollX is used to decide whether the backdrop is in view. Anything other than your player uses the same system but either has fixed world coordinates (ie doesn't move in the world system, only in the view of the world) or has variable world coordinates so it is moving in the world and may also be moving in the view of the world.
Essentially you work out where the object is in world coordinates and all movement is controlled using those but you use scrollX together with the world coordinates to decide how it appears on screen.
What that means is that a particular backdrop has fixed ‘world’ coordinates and scrollX is used to decide whether the backdrop is in view. Anything other than your player uses the same system but either has fixed world coordinates (ie doesn't move in the world system, only in the view of the world) or has variable world coordinates so it is moving in the world and may also be moving in the view of the world.
Essentially you work out where the object is in world coordinates and all movement is controlled using those but you use scrollX together with the world coordinates to decide how it appears on screen.
- Discussion Forums
- » Help with Scripts
-
» Side-Scroller walking