Hey Devforum does anyone have any examples of a fully ObjectOrientedProgramming game?

I want to further understand ObjectOrientedProgramming(OOP). I already understand the basics as well as inheritance, encapsulations, etc. Now how could I make an entire game using OOP and what would an entire game look like using OOP? Would it be like 1 or 2 scripts and the rest is module scripts? Questions like that are what I’m trying to figure out overall I just wondered if anyone had an open-source game or something I could dissect I’m mainly looking for an EXAMPLE of what a full OOP-based game is.

Hmm, don’t remember if it uses OOP but Roblox Battle (2018 Edition) - Roblox is worth checking out
Roblox Battle (2018 Edition) - An Open Sourced 2018 Game


Check out some of the guns released by Roblox as part of their Battle Royale kit.

1 Like

Hey thanks for responding I do have a question is a game that uses module scripts in a OOP fashion but still has many normal scripts considered OOP or am I thinking of a single script hierarchy. Also that game was not OOP I checked it out they did use modules for data but not in a OOP fashion.

It’s normal to mix and match paradigms like OOP and functional programming, especially in a language like Lua/Luau that doesn’t enforce any one in particular. You can have most of your game laid out in classes and then tie it together with "glue " that isn’t especially OOP- like. As an example, in Unity 3D which uses C# which enforces OOP, you’d have a GameManager class for e.g. starting a round, keeping track of who’s left in the round and ending it when only 1 player is left. If I were making such a game and most things were handled by classes I probably wouldn’t make the GameManager a class and just avoid the boilerplate/complexity. I also like to write subsystems in an ugly, non-OOP way and then clean them up once I know I actually want them in the game. IMO it only makes sense to create classes when you know for sure that the benefits of inheritance and encapsulation will make a positive difference for you.

1 Like