Hi guys! Scrolling can make a whole game feel stiff, flimsy, dynamic ect... I feel it's important anyway, but getting scrolling perfect for your game isn't the easiest thing to pull off.
Here, say what you think the best style of scrolling is for specific game types, or what you prefer? Some games will have the camera lag behind a character to make you feel like the game is fast paced and the screen just can't keep up, while some will have the camera ahead of the direction your faceing, while switching back and forth depending on the level design, what do YOU like when it comes to scrolling?
I basically have a couple of scrolling engines, but i still feel like they arent dynamic enough, any idea's or source code will be greatly appreciated, thanks guys. Mainly trying to get idea's
dont make me divide by zero...
Assault Andy Administrator
I make other people create vaporware
8th March, 2011 at 9:46:53 AM -
It depends a fair on the type of game you have. For a shooter or platformer I would often choose a "look ahead" camera which centers on the player + some distance in the direction that the player is moving in - with smoothing. With a top down shooter I might make the camera center between the player and the aim cursor. If I do have that "camera lag" effect it has to be extremely subtle. If you over do it, it just becomes incredibly annoying and limits gameplay. Just my two cents.
To be honest Ricky the underside is excatly what i was thinking of. The underside was very much inspired by Cave Story, and the scrolling on Cave Story is just amazing. I find the main problem (with me) is having trouble with decimal points... Like moveing the camera at 0.3 or something.. because it never ends up excatly where i want it.. Does anyone have any ideas on the "proper" way to move objects at decimal places?
@Assault Andy yeah I think your spot on with that, and yeah the camera lag should deffinately just be subtle or you end up almost running off the screen into enemies you can't see yet!
Since I use a level editor my level frame is much bigger than the size of any of the levels. I use an X and Y scrolling barrier.
The actual scrolling is basically centered to player unless at the edge of the boundries.
The code looks something like this
Always --- center horizontal position --- Min(X( "1mask" ), X( "xedgeobject" )-160)
Always --- center vertical position --- Min(Y( "1mask" ), Y( "yedgeobject" )-120)
Where '1mask' is the player's collision mask, and '160' and '120' is half the game windows resolution.
The scroll engine I'm using in my current project is inspired by cave story and the ilk. It's not finished yet though, but it is fully functional, wan't to make it more efficient. It currently uses many large actives, a big no-no. I know how to counter that, just haven't come to that point yet since it's only a blueprint/sketch.
Anyways, have a look, I believe it uses the same principal idea as The Underside does, gives similar results anyways.
EE thats exactly the idea i'm looking for! I made a level editor that puts them kind of active objects on the screen, yknow, the ones that are the same size as the screen and tell it to change the camera type. I have got mine working to a certain extent but still arent happy with it, im going to take a look at your code now. The only problem i see atm is when you run in the same direction and get the furthest away from the camera it kind of jumps repeatedly. Il take a look now, thanks again.
Box collision my young padawan. (untick fine detection on the u-d/l-r etc.)
About the jerky camera:
I assume you mean a situation like what occurs when running in the bottom corridor, a slight jerk when the distance between the SDOT and CAM is at it's maximum.
That's because of the "follow code" for the CAM (i.e the CAMpos+(SDOTpos-CAMpos) bit)
The jerk occurs because the CAM accelerates when at it's percieved maximum, "jumping" forth towards the SDOT causing the jerk. I'm sure there are work-arounds for it, perhaps matching the CAM's max speed to the player's max speed. Only problem with that at the moment is that the CAM doesn't have a "speed", it repositions based on "Ratio" and distance.
Perhaps one could conjur up some sort of vector movement for the CAM?
Anywho, it's probably do-able. (interesting note since everyone uses Cave Story as inspiration anyways: CS's camera also jerks)
The thing I'm gonna do next is getting rid of the hugh actives. The way to do that would be to change the overlap/position code from:
+ If the player is overlapping
+ the player is within the borders of the screen scrolling object
+ If player is within (a screen's distance originating from scrolling object XY)
--> set scrolling variables
Only thing to manage is putting the code so object selection is correct i.e using the proper scrolling objects XY as origin. Then the scrolling objects can be just 1x1 sized dots as long as they are placed in the correct XY. And for the level editor you can have big boxes show just for clarity.
I think it's called magic.
EDIT: It's great! I help you with this and you help me implent external animations!
Oh my goodness, ive used clickteam products since i was like 1 years old and i never knew that about unticking the fine collision detection lol!!
I = dumbass
Yeah i see what your saying about the camera catching up, i'm sure it can be easily delt with.
Yeah i would deffo keep the screen sized actives when using them in the level editor, but i see what you meen you want to keep big actives down to a minimum when the actual game is running. I wonder how the podunkian does it with the underside... anyone know? He may use a similar engine to the one you say about having a 1x1 pixel object.
The camera centers perfectly on the camera target XY, I wonder why mine doesn't since we use the same code..? :/
Very well organized and clear, are you going to implent the scroll restrictors too? They are the shit when you don't want the camera to scroll past a wall i.e doing it metroid-style!
I'll take a crack at minimizing the actives later tonight when I get a chance to sit by the computer.
Yeah i noticed that!? When I did it i expected it to get the same problem (not aligning for left or top) but it just worked! Which was a bonus but just causing confusion! I'm gonna have a go at making the L R U D restricters now, ive got a feeling theres gotta be a better way though :s the other thing ive done is made it so there is only one active object that changes the scrolling, but it has a text variable telling it what type it is like "fixed" or "left-right", but thats done on my level editor game, you can add parameters to objects. anywho, let me know how you get on!