Celeste shares its movement code for all to peer at

Share this:

The makers of Celeste have shared a big slab of the platformer’s code, letting everyone dig down into the intricacies of its movement. “Maybe it’ll interest you if you’re curious how some part of that works!” game director Matt Thorson said. Given how secretive the games industry can be, it’s nice to see a game with such great-feeling movement spill its guts for all to inspect.

“We just posted our 5400-line Player class (C#) from Celeste in all its messy, mostly-undocumented glory,” Thorson explained on Thursday. “This is the code that handles Player input/movement/states.”

If you’re curious, have a nose over on GitHub. I’m no programmer so what I can glean from it is limited, but I’m sure many will enjoy it. I’d also be curious to see if this level of insight helps speedrunners hone techniques and master quirks.

I have no practical or intellectual use for this myself but I shall certainly memorise a few lines so I can barge into discussions of Celeste spouting such wisdom as “Ah yes well but what else would you expect given that ClimbUpCost = 100 / 2.2f?” You are all encouraged to throw drinks in my face when I try to pull this nonsense.

The game is good, by the way. Check Adam’s Celeste review for our official word.

There is also something to be said for having everything related in one place instead of smearing a state machine into a 45 file jigsaw puzzle. It makes it harder for new people to get on board but that probably isn’t a problem for a small indie team.

From glancing over the code, it seems really readable despite its size.

“Here’s the thing though: • They knew the code wasn’t perfect but had the guts to release it anyway. • They successfully released a game, which is 10x harder than writing nice code.”

“Watching r/gamedev cry foul about the coding style in Celeste’s open-sourced Player class is kind of like listening to a bunch of freshman culinary students making fun of Alton Brown’s recipes because they think he ties his shoes wrong”

I seem to remember the programmer of Super Meat Boy also describing his code as being “held together by duct tape” and that’s a pretty good game, you guys…

It’s certainly possible to get a good end product with messy code, just much harder. And even that, I guess is reduced by how much mentally tough you are, but I wouldn’t say there’s absolutely no correlation.

I’m not a “real programmer” (more of an artist/animator with excursions into light coding) but I definitely find a preoccupation with the ‘correct’ way of doing things gets in the way of actually getting stuff done and working. While smartly constructed and readable code no doubt helps create better software (especially in a team) there is a time and place for simpler solutions and there is definitely some overlap in the venn diagram of people who are snobs about perfect code (or art for that matter) and people who never finish anything. (see also: writing your own engine)

Worth noting too that for novices, learning as you go by building things is greatly preferable to waiting until you’ve learned *the proper way* before attempting any project. Better to learn by doing and gradually improve.

I haven’t looked at it, but from a pure technical standpoint. If that class does all it needs to do, and none if it is required elsewhere… There’s no need to split it up.
I’ve read much worse code that kept getting needlessly split in classes calling classes calling classes, which does not improve readability either.
If the class is self-contained, and will not need to be reused elsewhere (and doesn’t need to return values), it’s perfectly fine no matter what the size is.

Anyway, I’m ambivalent about the “messiness” of the code. We’ve certainly got plenty of ways to make things more readable and maintainable (and comments really wouldn’t change much here), but I can certainly see the appeal of not having to constantly refactor and organize things in particular design patterns. It’s a bit excessive here, but if it works for them, it works.

And really, it’s far from the most ungainly class I’ve seen. (Though many of the worst offenders were generated, rather than written by humans.)

This is pretty awesome. Tutorials to make basic platformers are quite common, but most of them don’t go much farther than arrow keys to move and jump. Celeste has deceptively complex movement mechanics, with a dash, wall jumps, swimming, sliding, and limited grab and climb abilities. The game also has unusual momentum mechanics, where some movements like walking and jump preserve your momentum, while others such as the dash do not. So this code is honestly pretty cool to see.

However, it would definitely be at least 10,000% more useful if it was well commented. But then again, all code would be.