Player Movement Fundamentals


Basic Movement

Every game has to start somewhere, and for Cyberskate it made the most sense to start with the primary way the player will interact with the game: movement. Before any coding work was done, I needed some basic sprites to get a feel for the size of the player in the game world, and because moving an empty box around in a void just isn't very exciting. So I got to work making some idle poses and a basic skating animation...

Enter Robitmove.png!

Wow! Check out those awesome sprites! Get used to them, cause you're gonna be seeing a lot more of this funky little man.

Now that I had some sprites, it was time to start coding the movement. I'll spare you the nitty gritty, but long story short Rob (short for robot) has taken their first steps!


Currently the player moves by using WASD (really just ASD) with A accelerating Rob to the left and D accelerating to the right. Holding one direction will accelerate at a constant rate, but while Rob is moving friction is applied to slow them down by a percentage of their velocity. This results in a short acceleration period before reaching a 'terminal velocity' where the friction cancels out the acceleration and the velocity becomes stable. Now this all sounds a little complicated for just basic left and right movement, but it'll be important later ;)

At this point, Rob more or less controls like those ice levels you see all the time in platformers, just sliding around all over the shop, which is cool and all but it leads to the movement being a little hard to control as you can't turn around very quickly. To counteract this and make the movement feel more responsive, I added a transition state to Rob's movement when attempting to change directions above a certain velocity. This meant making a few more sprites:

(Feat. a falling sprite and a sprite of Rob getting knocked on their ass)

And a touch more coding, but now the movement feels more responsive and controllable at high speeds.


Breaking the sound barrier

So you remember those needlessly complicated movement quirks I mentioned two paragraphs or so ago? Well it was made that way in service of one thing: going faster. This is accomplished in through two mechanics, dashing and crouching.

Pressing shift gives Rob a short burst of speed, allowing them to temporarily exceed their normal maximum velocity on a short cooldown. Normally, this speed is quickly reduced by friction, however by holding S Rob will enter a crouch state where friction is entirely disabled, thus allowing you to maintain your speed. On a long enough stretch, you can maintain this speed until your dash is recharged allowing you to chain together dashes for theoretically unlimited speed!

The dash also allows you to cancel out of the transition state when turning, and if you do so you will transfer all of your velocity into your new direction, plus the bonus speed from the dash. This means once you've built up speed, you'll be able to maintain it better in actual levels. You can also dash while airborne to quickly change directions.


I also messed around with causing Rob to get knocked back and stunned for a short time when running into a wall at high speed, but this functionality has been scrapped for now as it discourages the player from moving too fast. Which is decidedly not what we want.


Leave a comment

Log in with itch.io to leave a comment.