Open source code for a beginner

Started by
10 comments, last by sednihp 11 years, 10 months ago
I have a firm understanding of C++ beyond the beginner stuff; I know classes, polymorphism, templates, ect... What I am looking for is some example source code that is properly written to look at. Something small and simple like Tetris or Snake, not huge like the Doom 3 source code.

I found this on LazyFoo's website. http://lazyfoo.net/g...locks/index.php and it's working code, but there are a lot of global variables, C style functions that should be part of a class object, and so forth. I'm not bashing his code, Ive written far worse myself.

I don't need perfect, I just need something with a good format as a reference. Something I can use whenever I hit a roadblock to look and see "how they did it".

Anyone know of or have any open source game code I can look at?
Advertisement

C style functions that should be part of a class object

I'm not so sure about that one. Not everything needs to be in a class, and it's ok to have free standing functions (and in many situations, it's the better thing to do). I'm not saying I'd recommend using that code as a guideline, and maybe you already understand this, but I wanted to point it out just in case because it's really easy to take OOP further than it should be (because not everything in code is an object).

Anyway, it's hard to give you meaningful code without knowing what it is you're looking for. I don't know if you're looking for design patterns, or algorithms, or syntax styles, or program flow, etc. Or maybe you're looking for all of them, in which case I think that's a massive question and needs to be broken down into bite sized chunks.

You'll find that in programming, you usually have to come up with your own solution (and it may suck). A lot of times, you won't understand "how they did it" until you understand the problem well enough to solve it on your own (even if your solution is crappy). At which point, you are more likely to meaningfully grok "how they did it." And usually, you don't understand "how they did it" by perusing through source code, but instead by presenting your solution/problem/roadblock to others and receiving their feedback. That is to say, you usually don't learn most of the important things from other people's source code, but instead by their normal english (or whatever language) words describing the high-level details. Once you understand the high-level details and the actual meaning/algorithm/design, you can trivially translate it into code. The code is just a low-level implementation of a high-level idea. Sorry, I'm going on a tangent now.
[size=2][ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

...
You'll find that in programming, ...


Very nicely put. :)
I found this open source project a long time ago through these forums. Although, the developer has not been quite as active lately and the code is a bit of a mess, it has given me some insight into how to design my engine. Personally, It was easier for me to understand than the source code for id Tech 3.

I found this on LazyFoo's website. http://lazyfoo.net/g...locks/index.php and it's working code, but there are a lot of global variables, C style functions that should be part of a class object, and so forth. I'm not bashing his code, Ive written far worse myself.


Notice how I very specifically noted that that the source for the game is how not to to make game, in bold and capslock so you know I'm serious. :)

You want to know the best way to learn design? Stop going around to other people's projects hoping you'll find some magical piece of wisdom and go out and get your hands dirty.

Learn to make games with my SDL 2 Tutorials

I love you Lazy Foo!

+---------------------------------------------------------------------+

| Game Dev video tutorials -> http://www.youtube.com/goranmilovano | +---------------------------------------------------------------------+
The Secret Mantra

You want to know the best way to learn design? ... go out and get your hands dirty.


Super awesome LazyFoo! Love ya!
Try checking Allegro SpeedHack, it's an allegro "contest" where people make simple games in a short time stamp (not like in hours, but still not years). The games' sources are available (or were). Worth checking!

Link speedhack.allegro.cc
This seems to be exactly what you are looking for. Also, keep in mind, it is ONE way to do things, and it favors readability over performance, but it goes beyond the level of polish of most demos/tutorials.

You want to know the best way to learn design? Stop going around to other people's projects hoping you'll find some magical piece of wisdom and go out and get your hands dirty.



I agree and disagree with this. The best way to learn just about anything is by doing it, jumping in and getting your hands dirty.

That said, you can learn an absolute ton about design from other people. Past mentors, reading other peoples code, books. There have been some books that had a profound effect on my code, Effective C++, Code Complete, JavaScript:The Good Parts, Refactoring, Design Patterns to name but a few.

You jump right in to learn how to make shitty code; you read books, blog posts and talk to other developers to learn how to make it better.

This topic is closed to new replies.

Advertisement