Jump to content
  • Advertisement

Gameplay Advice for Programming a Cinematic Platformer

Recommended Posts


Over the rest of winter break I'm hoping to create a cinematic platformer in the style of Abe's Oddysee or Another World/Out of this World, in order to practice writing, design, art, and programming in one project. If I can at least get a proof of concept or prototype done, I'll be happy. But to be honest, I'm not exactly sure where to start with the logic or system that the game would require. For reference, I'll be doing this in Game Maker Studio 2, since I'm very familiar with GML. I was hoping I could discuss it here with somebody before diving into it.

I have two ideas as to how I'd go about it, but they both seem like they'd be unnecessarily tricky to work with. Obviously, there'd be some kind of grid that the player's location would be set to. My first idea would be to set the player's speed depending on the input, then set it back to zero when the reach the appropriate grid location. This would be more in line with how I traditionally program a platformer. However, I'm not sure how I'd get it to only register input at one of the specified grid locations, at least not without a lot of testing. My other idea might be easier in that respect, that being I'd have different sprites for each type of movement, and when that sprite animation finishes, set the object's location to where it should be. I can see this working better with hit detection as well, but it would also mean precisely setting every single sprite's size, which might take to long given the time window I have.

I don't know, if either of these ideas sound viable enough, let me know, but I just think it be interesting to talk about, since I can literally find no information on the subject anywhere else on the internet.

Thank you for reading, and here's to hoping this account proves useful in the future, because at the moment I've only made it to talk about this.

Share this post

Link to post
Share on other sites

I have never written a cinematic platformer, but I do work full-time as a programmer and I have played those cinematic platformers a lot, so I thought I'd have a try at answering.

When programming your player, it think it will be important to start by programming what "state" they are in.
As a contrast, if you were programming Super Mario Bros (eg https://supermarioemulator.com/mario.php) you might start by programming your player's "physics", which are very simple approximations of real physics. The player would have variables for x velocity and y velocity, and you modify them every frame based on gravity, controls pressed, ground friction or air friction, etc.

But back to cinematic platformers: until they fall of a cliff, the player hardly has any "physics", because they always do every move the same way. The user can learn that pressing jump from standing still jumps two squares, and a running jump is three squares. So, the most important thing to program is the "state". State is what your player character is doing right now, and will dictate which animation is shown. Generally, the state will change when an animation finishes playing, and the state it changes to next will depend on what keys are being pressed at that time. Then, the character will be unresponsive again until they finish the next animation, and then at that time they will again check what keys are being pressed.

For instance, you might start by programming a player character who can only walk left and right. But remember, for a cinematic platformer, this also involves a turning around and standing still. So far you will need 3 animations:
1. A standing still animation. This might only be a single frame (so actually just an image, not an animation)
2. A walking animation that walks a single step.
3. A turning around animation eg, turning from left to right.
You will need to play these animations or their mirror images depending on the state of the player, see below:

Here is the state you need to store:
1. Which way is the player currently facing
2. Are they standing still, walking, or turning around
3. Which animation is currently playing, and how much of the animation has played

Then you would some code for the player that is run every frame. A lot of the time, this code would just continue to play the current animation. But, if the animation finishes, then it is time to do a state change! The state changes at this point are as follows:
1. If the turning around animation just finished playing, change which way the player is facing.
2. If the player is not pressing a button, set their state to "standing still" and start playing the standing still animation.
3. If the player is pressing a button that is the same as the way they are facing, set their state to "walking" and start playing the walking animation.
4. If the player is pressing a button that is the opposite of the way they are facing, set their state to "turning around" and start playing the turning around animation.

Having done the state change, the player will again become unresponsive until they finish that animation too.

Since (in my opinion) these state changes + animations are the most important place to start, you can start work on them before you even have a platform for the player to walk on, before collision detection, before you even make the player move. You can make the player stand, walk, and turn around, all on the spot. Once that's working, you can make them move some constant distance every time they play the walking animation once, so that they always stop aligned with the grid. But animated smoothly.

Eventually you will need more states - running, jumping, hanging from a ledge, climbing a ledge, etc. What state you end up in next will depend on a variety of factors - is the player in mid-air or on the ground, what state were they in last, is there a wall in the way, is there a ledge to grab, etc. It will be a lot more work than Super Mario.

Perhaps some states will eventually be interruptible. After deciding to walk one step forward, the player is committed to walking that step - they have no choice but to wait until the animation finishes - but, suppose someone shoots them in that time. They might not finish the step, but instead change state immediately to "taking a bullet". So, your code for the player that runs every frame would start by checking if the player's animation was interrupted by some powerful event, but if not, the animation will be allowed to play to the finish, and once it is finished, only then does the user have some control over the next state.

PS I just re-read your question, which I think describes two different possible ways of re-using existing GDL code that was more designed for other types of platformers. The second approach sounds more promising to me, but you should be aware that making "Another World" which is the simpler of the two games, will still probably require a very systematic approach, perhaps like the one I described above. If you start with code that is designed for other types of games and then just try and hack it a bit, you might not be able to get to the game you are picturing.

Share this post

Link to post
Share on other sites

Thank you so much for replying, I'd just started to think this post had gone under the radar. And thank you for the advice, a state machine definitely sounds exactly what I was asking for. I'm not planning on reusing any code, though; I was just sharing different approaches I thought I would have to take to start this. In fact, I've kind of started already, going with the second idea. But I could probably convert it quickly; this is more of a personal project, after all. I'd really like to start working with state machines, though, since I haven't practiced with the as much.

Again, thank you so much, you might have just saved me!

Share this post

Link to post
Share on other sites

Here are some links that might be useful to you, although none are very in depth with respect to design. But, even just the pictures may give you some insights. For no particular reason, all of them use the game Flashback as a template - which is quite similar to Another World.


Part 10 in this blog deals in particular with state changes, but a bit focused on implementation and results, less on design:

Type 1 in this blog post:

Share this post

Link to post
Share on other sites

No joke, you are the savior of this project. What I ended up doing was creating a new player object and creating the state machine from scratch. I was worried it would be a waste of time, but compared to what I had before, it's so much more efficient. And those links you gave me - that first one from gameanim.com especially - really helped me work out the logic better. Thank you so much, I'm hoping I can keep the ball rolling and maybe make something complete-ish, but we'll see. Again, I can't thank you enough.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!