I'm making a somewhat simple platformer engine that I want to use for a game. I want the scrolling to be somewhat different though.
I already have it set up so that the x scrolling goes a little bit ahead of the character. Thats all fine and good, however its the vertical scrolling that gives me a headache.
Its a 320 x 240 game, so there isnt that much visible area. When the character jumps, he takes the window with him. So this creates the problem that you can see the ground when your at the peak of your jumps, and its especially worse when hes not near the bottom of the playfield.
So my question is, is there any way to make it so the vertical scroll only scrolls when its necessary? So that it will stay locked in place unless the character has changed height or is falling/jumping more than the screen size?
I've already been thinking about many ways to do this, but all of which I dont think will work. I dont think its going to be as simple as the y values of the frame and character..
And if it helps any, I'm using the platform extension object.
Easy solutions:
- Dont make your character jump so high.
- Make the window bigger.
Hard solutions:
- Invent some complicated algorithm which will scroll to the Y position of where the player will land, which you can't actually calculate, e.g. if they jump up on to a high platform.
You could make two active objects, and do something like:
Y("Player") < Y("High Scroll") --> Set Y Pos of High Scroll to Y("High Scroll") - (value)
Y("Player") > Y("Low Scroll") --> Set Y Pos of Low Scroll to Y("Low Scroll") + (value)
Thanks for the suggestions. I sort of combined all of them to make it work pretty good.
I made it so when the character is standing on the ground, he sets a value that is the current locked Y position for the camera. Then, when the character jumps or falls and is approaching the edge of the screen (I used values based off the locked Y, rather than screen edge.) then the camera follows the character.
I worked it out so it runs pretty smooth too, thanks ;D
Now if you dont mind answering another question...
I programmed water into the engine, but using an active transparent object slows the game down slightly, and of course the larger the object the more it lags. Is there any alternative to an active object that I could use that would still overlap the character and be semi-transparent?
a) have lots of 32x32 transparant water objects, but lots of little ones will probably slow it down as much as one big one.
b) have lots of little objects that are a mesh of transparent and blue pixels (like, every other pixel is transparent, the others are blue).
c) just have a water background behind. Depending on the graphic style, it's usually possible to have static background water that still looks pretty good.
There's another, more complex method involving changing the colour of just the player sprite as it enters water, but there's several ways of doing it and it's too involved for me to feel like explaining it.
The only things that can overlap non-backdrop objects are actives and counters and the like. You could try only putting actives where the player can go, and use backdrop water tiles for the rest, although you won't be able to animate them obviously. Also, the transparent effect will make the active water look lighter (or darker, depending on the background) than the rest, but you can counter this by taking a screenshot of transparent water over the background and using that as your tile instead.