Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Are there any very simple open source games available just to demonstrate the basics of the programming techniques? Preferably something which fits in to a couple hundred lines of actual code. Specifically, I'm looking for an open source game written in Objective-C and Cocoa.

I would also appreciate one written in C.

All the projects that I find online are relatively complicated.

share|improve this question
1  
I guess part of the problem is that there hardly is such a beast as a 'simple game'. A game generally needs input handling, drawing code, game logic, resource loading, perhaps audio. That alone makes for a couple hundreds of lines of code. Add a menu and a hud and it grows. Even simple DirectX samples rather quickly grow to a few hundred lines, without counting the service functions in the sample framework, and there's just something being drawn to the screen without any game logic. –  Kaj Jul 31 '10 at 4:47
    
I presume it is definitely much easier in Java, but still, snake was about 300 lines. Of course much of the underlying stuff isn't seen in a Java applet –  Mechko Jul 31 '10 at 4:52
    
Can you clarify what you mean by "the programming techniques"? The programming techniques for a 300 line game aren't the same as the techniques for a 30,000 line game, and those aren't the same as for a 300,000 line game. –  user744 Jul 31 '10 at 19:55
    
Very simply, I think what I need is an example of drawing graphics and taking input. –  Mechko Jul 31 '10 at 23:05
add comment

6 Answers

If you want 200 lines, then the only type of game I can think of would be a good old-fashioned text adventure. :) Don't underestimate the challenges of that.

Here's a text adventure in Objective-C: http://www.spintz.com/electron/electron.html

share|improve this answer
add comment

You can find a few open source games written in objective-c on github. Although most are larger than a few hundred lines.

If you're looking for "tiny" examples and you like Roguelikes, you should check out the listings for the 1kb roguelikes contest. There are a couple C examples that are rather clever (though they probably aren't good learning examples, just fun to read.)

share|improve this answer
add comment

If your interested in FPS you can look at Cube Engine.

Also the Quake 3 Engine is available for free. You can find it on the id Software website. Bottom of the right side bar.

share|improve this answer
1  
I think the Quake 3 engine goes a bit over a few hundred lines ;o) –  Kaj Aug 1 '10 at 17:07
add comment

I am, very slowly, teaching myself programming (only need to grasp basic game logic) with the free book "Invent Your Own Computer Games with Python".

It's written with the idea that all an aspiring game programmer wants to do is get to the point of writing games, so that is what it lets you do, from the very beginning. In the end you will be making games that are pretty much what you describe here.

share|improve this answer
    
I frequently recommend this book to beginners. I mean "I've never programmed before" beginners, so this may be TOO simple. –  jhocking Jun 10 '11 at 21:11
add comment

An Allegro Game in 20 lines of code.

  • It can be considered "free to use" since it is snippets on public forum
  • C language
  • some "dirty techniques" how to squeeze code in C
  • some techniques how to make game simply
  • at most 20 lines (there are few exceptions and there is a problem that C is maybe too compressible, because there is almost no restriction on newlines or whitespaces; LOC is usually a bad metric)
  • Not sure if the "basics of the programming techniques" falls here, but there are certainly
    1. arrays
    2. function composition
    3. C boolean properties
    4. C comma properties
    5. C macro-processor properties
    6. C ternary operator
    7. boolean logic with multiplication and addition
    8. ...
  • You would need some math background to understand some of them.
  • Snippets have < and > instead of [ and ] .

There is also Pac-Man for example.

It is something I would reccomend You if You are more advanced programmer, because some of these techniques are quite non-readable.Nevertheless, it is a nice set of techniques. Proper way would not be to make such "abominations" but to properly design, document, test (...) Your program and such code would be the result of many compression techniques applied on very good design. Please, this is not how You should program but a demonstration how much a game can be compressed.

share|improve this answer
add comment

I've got the source for a simple one we're using for a code war competition at Windward Wrocks. It's in C# but that's close to Objective C.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.