This site requires JavaScript, please enable it in your browser!
Greenfoot back
woodkami
woodkami wrote ...

2012/4/3

Side Scroller

woodkami woodkami

2012/4/3

#
Hello, I was planning on trying to make a side-scroller, but I have no idea on how to start.
davmac davmac

2012/4/3

#
Hi. That's kind of vague. If you give some detail and make a start, people here may be willing to help you.
woodkami woodkami

2012/4/3

#
davmac wrote...
Hi. That's kind of vague. If you give some detail and make a start, people here may be willing to help you.
Well, I just need to know the concept on how a side scrolling map works.
sp33dy sp33dy

2012/4/3

#
There are quite a few tutorials on youtube; however, a highlevel view is this: Create an (x,y) array for the tiles. Each tile being a type (for both showing and for interaction with character, i.e. can character step on it?) Then have an x/y position in the map for the character. As the character moves X or Y, you then have a routine to draw all the tiles in X and Y direction that should fill the screen. Further to this, think of a strategy for then smoothly scrolling the pixels. I.E. one method is to create on Image that will hold all the tiles, but at one tile width/height around the entire border. Then draw all tiles including the border. When the user moves for all pixels that are in width/height of the tile size (say 16 pixels), just shift the image by that position. When the movement takes the image over the 16th pixel position, you then redraw the next position of the tiles and reposition the image back. This is a very simplified answer, as I'm just going to bed. ..and have a look at my scrolling landscape that I recently uploaded with source. This isn't using a tile map, but does show basic scrolling concepts.
davmac davmac

2012/4/4

#
Well, I just need to know the concept on how a side scrolling map works.
Ok; you implement "scrolling" by moving everything to the left (or right). In Greenfoot this could be as simple as getting all the objects (World's getObjects() method) and then looping through them and adjusting their position. You should use an unbounded world so that objects can move out of the world bounds. It's a bit more complicated if you need the background to scroll as well, but to start with you could use a plain background to avoid that problem. This technique isn't particularly efficient, but you can worry about that once you have it working.
You need to login to post a reply.