i'm trying to make a doodle jump game, but i do not want to keep making sprites (platforms) for my character to jump on. do you know how to make an infinte scroller that reuses sprites?
Offline
The key is using "modulus". The actual block name is < () mod () > and it is in the operators. Basically, it tells you the remainder of a division problem. For example, 5%2=1, because 2 goes into 5 twice, with one left over (2*2+1=5). The key to snapping a sprite to the opposite side of the screen is to set their x-position using the modulus block. There isn't a concrete formula really, but the forumla should look something like this:
set x to ( (x + (some number) ) mod 360 ) + some number )
As a sort of disclaimer, I've never done this before, but if I were to do this, that is how I would do so.
Last edited by MoreGamesNow (2011-11-02 19:17:48)
Offline
thank you will try . however, will this work for y scrolling too?
Offline
What you might want to do, is create a set of them, and then set it to when it reaches the bottom, go to the top. Just program it so that when it hits a specific color, it reacts, and reuse the blocks like that.
Hope this helps!
Offline
@ARANDOMACCOUNT:
Great idea! I was about to suggest that. You could also make the new blocks pop up in random y places.
@wildwildcat:
Yes, it will.
Here are some projects to get you started on how some people do this:
http://scratch.mit.edu/projects/blizzari/1647212
http://scratch.mit.edu/projects/Mrpsau/2042558
http://scratch.mit.edu/projects/TheSaint/788200
Last edited by Greatdane (2011-11-02 20:16:56)
Offline
thank you! will try!
Offline
Sorry, my previous post had a mistake. It should have said "mod 480", mot "mod 360". "mod 360" should work for y though. Additionally, you should understand that the platform would just cycle through the screen with the same x and y, changing the x and y positions of the platforms in regards to "real x" would be trickier with script. I'd recommend just changing the costume centers.
Offline
cananyone show with blocks, i might get a slight better understanding, thanks!
Offline