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

2014/2/12

Last attempt on making this scroll... probably... :)

askgriff askgriff

2014/2/12

#
Okay, so I have this platformer which is driving me crazy because I want it to scroll. Jacob and I had it partially scrolling in an early version, though the blocks were just piling up along the edge of the screen. Here's the early "scrolling" version: http://www.greenfoot.org/scenarios/10638 Now we have added a lot of features and made a cooler "level" system and such, but I don't know how to make it scroll any more... even badly. :) Here's the new one that I need help with: http://www.greenfoot.org/scenarios/10593 I have had a couple suggestions of things to try, but it really involves completely rewriting the front-end code -- which would normally be fine, but we're doing this as a tutorial in my class and my students are following along. Any help is greatly appreciated.
danpost danpost

2014/2/12

#
Because you are using maps, you would first have to map out the entire scrolling area for each level. Next, because you do not want your Floaters to change where they turn around at after scrolling has taken effect, you will need to place Platform2 objects on either side of them (or adjust the turn-around code to compensate for the scrolling area instead of the world window). To reduce lag, it would be probably wise to have a flat color background instead of patterned (that way you do not have to deal with the scrolling of the background image as well. You can just alter the flat color for each level. Once that is done, implementing the scrolling code should not be too taxing. BTW, the Level class I created for you was a pre-cursor to my latest support class -- a superclass for a level world changing scenario. You may want to check it out (not for replacing what you have now, though).
danpost danpost

2014/2/12

#
It appears there are more adjustments that need done as well. All moving actors will need to check for scrolling edge instead of world edge. Also, if monsters are to stay on their platforms, the code will need adjusted there also (the code for the monsters should probably be re-written anyway). There may be other issues I have not come across yet.
jimboweb jimboweb

2014/2/13

#
I just happened to make a demo of a scrolling platform game; no enemies or anything, just the scrolling. The way I made it work is to have each platform (and any other scrolling actor) be part of an ArrayList, and then when I create them I pass each of them a coordinate in a larger map. I created the map from a GIF black-and-white image using get color at pixel. When it's time to scroll I made a method that goes through the ArrayList of platforms and check to see if the platform belongs on the screen. If it does and it isn't, put it on, if it does and it is, move it to where it goes, and if it doesn't and it is, take it off. You can see the code here: http://www.greenfoot.org/scenarios/10770 . It's very well commented so you can see how it works. I am also in the middle of making a multi-part video tutorial about how to make it, starting here: http://youtu.be/u0jkOdjFA28 .
You need to login to post a reply.