Osmose

I make websites and chiptunes!

  • he/him

AKAs:
Lapsed Neurotypical
JavaScript's Strongest Warrior
Fake Podcast Host
Thotleader
Vertically Integrated Boyfriend
Your Fave's Mutual
Certified 5x Severals by the RIAA
Inconsistently Medicated
The Source That Views Back
Carnally Known
The Alternative


Homepage
osmose.ceo/

Pretty much all my gamedev is hobby Phaser stuff and I've settled on a very specific state-machine-based pattern for logic in my games. I'm curious what game logic (e.g. player movement) looks like in other systems, esp since I've never had more than a cursory look at engines like Godot where behavior is more split between raw code and systems configured from the UI. Phaser is entirely a code library so I'm used to not having a GUI of any kind.

Anyone wanna share their own or know of any open source games that I could look at?


You must log in to comment.

in reply to @Osmose's post:

Personally haaaaate state machines for game logic. During production you end up either having to write a bunch of hyper specific states or have to layer a bunch of non state stuff on top of your states in way that can make the state machine paradigm really muddy. Because however well designed your state design is before production, you WILL have to change it in the future. Also I can tell you it's extremely normal to have >5000 line player classes. Programming dogma rarely applies 100% correctly to games. Sometimes you just have 30 different overlapping game mechanics centered on your player character, and a really long file with a bunch of extremely specific logic checks built over the course of years, is in fact the best way to do it.

Yeah, I get that. Most of my Phaser games are cloning NES-era games so there's not that many features that need to be accounted for and I haven't really gone over, say, 15 states for any one entity. I can easily imagine a more complex game needing way more than that.

I will say that having a bunch of hyper specific states is actually a benefit in how I use them; on one hand it is tedious to have to repeat logic or handling across a ton of states, but on the other hand doing so makes it much easier to reason about a state in isolation.

For example, I often have a check for "if the player is not standing on solid ground, transition to the falling state" that feels like something general enough that I'd want to put it outside of any state's update logic, but more often than not it's better to just repeat it on every state it applies to. Every game I've done that check in I've had at least one or two states where I dont want the player to be able to fall during, like a throwing animation, and being able to just leave that check out of those states ends up being easier than building some sort of canFall flag or something, even if the initial task of copy pasting the check in many states is tedious.

That explicitness is what I like about them. Well, that and some JavaScript-specific ergonomics related to async/await.

My instinct (though I'm far from a game developer) would be to make "start falling" an overridable method, and just override it with a dummy method when in those states. Less copy-paste, still mutable as needed. But I trust the compiler, so if it's genuinely easier for you to read and reason about the copy-paste, then more power to you. It's always cleverer and cleaner on the machine code side, the source is for you to work with.

I know of some Game Maker 1 projects that have/had their source available.

Most of Daniel Remar's games (at least going from the site, the old versions should also come with the source code?):
http://www.remar.se/daniel/resources.php

Spelunky classic:
https://github.com/yancharkin/SpelunkyClassicHD

Also if you buy "Death Ray Manta" on Steam, you can find its original project file in the game folder as well.

All of these require you to own Game Maker Studio, so I don't know how much help they are. You can also open them in Game Maker Studio 2, but the conversion might break some things, depending on how much each project used a mixture of GML and Game Makers visual coding tools. You should still be able to look at the code though.

Here are two non-game maker games that I know have released their source code.

VVVVVV:
https://github.com/TerryCavanagh/VVVVVV

Anodyne:
https://github.com/analgesicproductions/Anodyne-1-Repo