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

2016/10/1

Jump 'n' Run scrolling camera

Tritos Tritos

2016/10/1

#
Hey, I have some problems with writing a basic scrolling camera in Greenfoot. I have understood the basics of "scrolling" in video games (The world moves not the character, it has to move when the player comes near the edge of the screen and so on). However I dont really know how to start. I know there are already some solutions in form of finished scenarios, but I dont want to use them, because I am here to learn and understand and not to copy code just to finish my project. The camera I want to programm is ment for a Jump 'n' Run and should only move Left and Right. (I need some kind of object as the camera because I later on want to to programm background that moves acording to the cameras position) I think I just need a little push in the right direction so please dont post a finished piece of code. Thanks for helping Tritos
danpost danpost

2016/10/1

#
There are many different scrolling techniques. What will best suit you depend on what limitations you are placing on the scrolling. Obviously, one limitation is that you are only wanting a side-scroller. Other questions would answer whether scrolling will be limited or infinite; a large image could be used to limit the scrolling area or the background image could wrap; as well as other thing. Knowing more about what you really want would help us to help you better.
Tritos Tritos

2016/10/1

#
Well I am trying to programm a side-scrolling Jump 'n' Run with different levels, so I want the scrolling to be limited. I will generat my levels with a two dimensional array and a method that goes through the array and generates objects in the world acording to the content of the "array cell" (dont know if that is important). I like the idea to realize the limitations with a large background image, but I could imagine that this might become a problem if I have many differently sized levels because I would need to create pictures for every level.
danpost danpost

2016/10/1

#
Okay -- so we are talking about a limited side-scroller. The fact that there are different levels with different sizes is not that important. Each world will scroll to its own limits. First, let me say that you do not need some kind of object for the camera; but, you need something to control the scrolling. This can be a superclass of your worlds or it can be an object that is given the limitations and player to make the adjustments as needed to your world. Basically, what will happen is that the location of the player will be assessed. If the player is too close to an edge, then the distances required to put the player back within its normal area along both x and y axis is determined. This is then checked to see if scrolling can be accomplished those distances and those distances adjusted if there is a difference. Then the background image is redrawn and the actors are moved the final distances to perform the scrolling. Things to note: the larger the viewport, the more chance of lag due to scrolling; and a flat background color does not need scrolling. You will find that I have several scrolling support classes in my Support Classes by danpost collection. They are documented with comments throughout, so even though it is complete code, you could still just look at them to get an idea of what you will be working towards.
Tritos Tritos

2016/10/1

#
Thanks very much. It really helps me. I will try to get it to work for me tomorrow.
You need to login to post a reply.