Crossing the Gap from Beginner to Intermediate - how are games structured?

Does anyone have a tutorial, or book that helped them get beyond
the beginner stages?

I can do single - tiny things… draw sprites, move them, get input etc.
I’ve done many tutorials like that. I’ve made pong again and again in
various game engines.

I’m having trouble learning how a large game actually comes together.

If it helps… take Stardew for example… you have a GAME which
has MAPS which has TILES and NPC’S and a PLAYER and MOBS etc.
that all have behavious, triggered events, etc.

But I am having trouble learning to structure all of this within
the provided game loop many engines have in common.

Is there any advice, article, book or anything I can look off of - to learn how to
bring a larger game structure together?

4 Likes

Look into GameStates, this should help you move between menus and gameplay.

Books, I can suggest many but what is your target platform to start with?

EDIT

Also, Hi @mattkw80 and Welcome to the Community!

Happy Coding!

1 Like

I have written many whole engines from scratch, in fact I am doing another right now :smile:

The way I work these days is I start with something really simple. Generally I start with a scene manager which is incredibly simple.

Just think about what you really need to do. You need to update your “world” , and you need to draw you “world”

So you create a base class that has an update method and a draw method

Then you start adding things you want.

Need a physics system? Add one. Doesn’t matter if it works at this stage, just stub it out
Need an entity component system ? Add one.
Need a sound system? Add one.

And so on until you get bored or have the layout of an entire engine.

Then start fleshing out the code solving problems as you go. This is the fun bit and where you can learn a lot.

For example your user interface. You can just grab one someone else has written and plug it into your nacient engine, which is fine, or you can write your own.

Writing your own takes a LONG time, but you will learn a lot and could come up with a new way of dealing with the traditional UI issues.

If you get bored of doing that, rip it out and add one from someone else

I could point you at several scholarly articles which detail game engine design, but you will probably get 20 pages in and throw the book at the dog, kick the wife, and run away to the pub never to code again.

Just write a list of what you want to do, and then stat doing them.

3 Likes

So much rage…

Also: Nascent. Unless, that’s American?

2 Likes

Thanks all!

Platform… targeting Windows and Linux. I’m really only making little 2D side scrollers and top downs to amuse myself. I’ve bounced between all the usual suspects - Godot, Unity, etc. - but I feel Monogame gets me a little more - out of someone else’s engine and editor. Godot’s text editor drives me insane - and I can’t get Unity stable on any system I’ve ever used it on… which… must just be be, because people obviously have great success with it… I can only ever get it to crash.

And another goal here - is for me to learn proper OOP. Seems to me Godot and Unity kind of obscure that - as opposed to Monogame - where you really are making your own classes.

I’ll look into game states, and go from there - thanks everyone.

I feel like I’ve been learning the basics for 10 years, and have yet to grasp how it all comes together.

2 Likes

I think this will be helpful for you. It’s not MG but it is C#:

OpenRA is an open source reimplementation of Command & Conquer: Red Alert , Dune 2000 , and Command & Conquer: Tiberian Dawn written in C# using SDL which allows cross-platform programming for Windows, *BSD, Mac and Linux. At the first execution, it automatically downloads the original game files or installs some of them from the original game discs if such an option is chosen.

https://www.openra.net/


1 Like

Oh wow JimBob - thanks so much.

I’'ve played all these games … so looking under the hood could be helpful.

Thanks very much!

2 Likes

:+1: :+1:

2 Likes

Please do!

2 Likes

OMG Dune… brings a tear to my eye.
It’s only been 27 years…

2 Likes

mattkw80; One of the books that I have read that helps explain some of the things you are asking was “Players Making Decisions_ Game Design Essentials” by Zack Hiwiller. It is not about any particular engine or programming language, but instead looks at game design from the point of view of “what do you what the player to achieve ?”. I recommend it.

2 Likes

I’ll check it out - thanks!

Try to make something thats just slightly out of your comfort zone. When implementing something there are many ways to do it that vary heavily based on your game, some are good, some are bad, and many are fine. The only way I know of getting better and figuring out which are good and bad is to try to implement them. So maybe if you want to reproduce stardew then implement one feature at a time. Can you make a guy move around? Can you come up with a system for moving between multiple maps? Can you import the map tiles from a program like Tiled or write your own editor? Etc.

There’s no one magic right way to do things and you will get a better intuition for how to do stuff the more you make things the wrong way.

2 Likes

I can make a guy move around, and tile a map for sure.

I start to fail when it comes to multiple files and classes. So if my current game state is “MENU” when the game first loads… okay, I can make a Title Screen or Menu - all right there in the provided game loop , If (mygamestate == “menu”) { x20 lines of code to draw a menu and handle enough input so player can press ENTER }.

But then the player wants to Play…so they press ENTER… and now the GAME STATE == “PLAY”. My main game file is going to get pretty crowded, quickly. I know I need a LEVEL which has a PLAYER and TILES and ITEMS and MOBS, etc.

^This is where I have a heck of a time. I’ll put each class in it’s own file, that’s no problem.

Tying it all together, that’s where I fall down.

This is where you need to get into OOP/OOD understanding Object Orientated Programming and Design is really going to help you out here.

2 Likes

So I’m not sure exactly what you are asking but I’m going to answer this question I made up instead “Hey my update loop is crowded, how do I go about making it clearer?”

  1. Having a crowded update loop is not that bad, taking related code and shuffling it into all these classes so that you can’t see the code in context and beside similar code is not great. If your code works then maybe it’s fine?
  2. The most obvious functions to write are ones that eliminate code reuse, so if you have the same code written out two or more times make it into a function.
  3. After that I like to try to remove code that is less about game design and more about the framework that the update doesn’t care about. Eg. swapping out a texture is a function that the update loop can call so that updating doesn’t have to worry about how textures are loaded, stored, and drawn.
1 Like

Charles : “This is where you need to get into OOP/OOD understanding Object Orientated Programming and Design is really going to help you out here.”

^Exactly. This is where I struggle. This is the chasm I’m having trouble getting across.

1 Like

Yea, it can be a wide one, and from my experience, the best way to learn it is to do it, have you had a bit of a google to get the principles under your belt?

I find the guids you find on this sort of thing, very, very dry lol, so you can come across stuff like this, which is all correct, and propper, but you have no context as to how YOU would apply it, and especially in a game…

I am thinking of doing a series of public posts for beginners, and I think this sort of stuff would be super useful as regard MonoGame.

I was lucky that when I came to XNA I was already a C# programmer, if you are coming to this new to C# and even indeed programming in general, it can be quite hurdle…

I’ve been programming for 15+ years, but not proper OOP. I tend to use VB and Python, where - they certainly allow OOP, they also allow you to … do whatever you want. I’ve had the most gamedev success with Lua Love… no OOP there at all. Proper OOP trips me up. I wish I would have started that way, strictly.

As for the googling - oh yes, I’ve been working on this for 5 years. I get mid point into the HEAD FIRST C# book, and eventually stop, think I’ve done 3 attempts to get through that. I’ve done the Yellow Book… but I don’t recall it showing how to apply OOP in an application. With C#… (or any language really) - it’s not the syntax that trips me up - it always comes back to not knowing how to structure a big project using proper OOP.

Closest I came - was a text based RPG in Python… which I put together solely to see OOP. And it did work, and maybe I need to go back and review what I did there. The idea there was … a GAME has a MAP which has a PLAYER who stands on TILES next to ITEMS and MOBS. If I recall, that was the closest my brain ever came to ‘getting’ it.

If anyone can refer me to a book or article where they had their 'Ah ha! ’ moment, I’d gladly check it out.

I really think starting in VB… and doing 15 years of VB, has screwed me up.

1 Like

VB (I’m assuming VB6) actually has some OO concepts such as classes. You may have done plenty OO without realising it :).

I’d suggest looking from a different angle - what do you want to do? What game do you want to write? In the past I chose to make computer versions of boardgames as this gave me a ready made spec/design so I just needed to do the programming part.