Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Open source code for a beginner


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 Kaanin25   Members   -  Reputation: 129

Like
0Likes
Like

Posted 05 June 2012 - 07:58 PM

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?

Edited by Kaanin25, 05 June 2012 - 08:01 PM.


Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6991

Like
8Likes
Like

Posted 05 June 2012 - 09:57 PM

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.
[ 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 ]

#3 Marvel Magnum   Members   -  Reputation: 333

Like
0Likes
Like

Posted 05 June 2012 - 11:37 PM

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


Very nicely put. :)

#4 EnigmaticProgrammer   Banned   -  Reputation: 141

Like
1Likes
Like

Posted 06 June 2012 - 03:25 AM

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.

#5 Lazy Foo   Members   -  Reputation: 1105

Like
7Likes
Like

Posted 07 June 2012 - 10:27 AM

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


#6 Goran Milovanovic   Members   -  Reputation: 1104

Like
-2Likes
Like

Posted 07 June 2012 - 11:16 AM

I love you Lazy Foo!

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

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

#7 Marvel Magnum   Members   -  Reputation: 333

Like
-2Likes
Like

Posted 07 June 2012 - 11:52 PM

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!

#8 dejaime   Crossbones+   -  Reputation: 4119

Like
2Likes
Like

Posted 08 June 2012 - 07:09 AM

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

#9 Serapth   Crossbones+   -  Reputation: 5795

Like
2Likes
Like

Posted 08 June 2012 - 08:29 AM

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.

#10 Serapth   Crossbones+   -  Reputation: 5795

Like
3Likes
Like

Posted 08 June 2012 - 08:35 AM

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.

#11 Kaanin25   Members   -  Reputation: 129

Like
2Likes
Like

Posted 13 June 2012 - 12:51 PM

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. Posted Image


Notice how I very specifically noted that I was not bashing your code...I understand it was a tutorial designed with the intent to show beginners how to handle the SDL library and setup a very simple game; and for that purpose you did a fantastic job, your tutorial has been very sucessfull and I myself thank you for making it.

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.


So you just assume that im sitting around all day just parusing through other people's code without writing any of my own? That I havn't already gotten "my hands dirty". I have been writing code on and off for some time now; I have a few past projects under my belt. I am not an infinite pool of resources unto myself and when I lack the skill and knowlege to solve a problem I seek out others who are better then me for answers.

In my particular case I had a problem with the game I am developing right now and all the solutions I had come up with on my own have been unsatisfactory. I thought maybe I could get a look at few other open source projects made by better programmers to see how they did it.

learning by example is a very valid form of education. If you don't want to help that is fine, then dont post, but please don't berate me as if im not trying.
Sorry if that was a bit of a rant, but it really upset me. I came looking for help.

Thank you very much for the resources Serapth, EnigmaticProgrammer, and Dejaime.

Edited by Kaanin25, 14 June 2012 - 08:03 AM.


#12 sednihp   Members   -  Reputation: 241

Like
4Likes
Like

Posted 14 June 2012 - 12:32 PM

I've put up some of my games over on my blog if you want some small SDL games to look at. They're nothing amazing (Pong, breakout, space invaders, bomber run clones) but they might give you something to peruse...

I will say, I've only been at this for 4-5 months so I'm no expert, but I'm pretty happy with my code.

Edited by sednihp, 14 June 2012 - 12:33 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS