Source code for games?

Started by
22 comments, last by jpetrie 15 years, 9 months ago
Quote:Original post by Gage64
a tetris clone (too simple)

Does that mean that you have already written your own tetris clone? If not, try it. You might be surprised at how hard it really is.

I have been writing tetris clones for several years now, and I'm still not pleased with the result ;-)
Advertisement
Quote:Original post by Spoonbender
I'm curious what it is that qualifies you, the person who's in "way over your head" to decide that advice given by people who actually know more than you, is invalid.

...

Or then again, maybe not, if you really intend to ignore any advice that could be helpful.


That article is geared towards complete noobs, for whom the advice there is very relevant. But someone more experienced can differentiate between well written and poorly written code, distinguish between good habits and bad habits, and actually learn something from the code rather than blindly copy it.

Whether I am experienced enough for that, I don't know, but for now I'd like to think that I am.

Quote:What is it you expect to gain from reading this source code then?


For now it seems that writing code by myself isn't working too well for me, so I would like a change of atmosphere. I thought that rewriting a game using my own coding style, perhaps restructuring the code (in particular, rewriting C code to take advantage of C++ features) and extending it, would inspire me to write my own code.

I don't know if this is the most productive use of my time, but it can't be much worse than what I'm doing now (which is mostly nothing).

Quote:Since you don't want a link to that article again, here's another one you may find relevant.


I'd like to think that your intentions are good, but still, that was uncalled for. I am quite aware of my incompetence, which I've hinted at in my original post.

Quote:Original post by DevFred
Does that mean that you have already written your own tetris clone? If not, try. You might be surprised at how hard it really is.


I have and you're right, it wasn't easy.

@jpetrie:

Given that you are the author of that article, I really appreciate the fact that you decided to post the links to these games even though they are probably over my head. I will definitely take a look at them.

@Daaark:

Why did you delete your second reply? I thought it was totaly awesome!

And finally, thanks to everyone who posted links, I really appreciate it. Please keep 'em coming!
Quote:Original post by Gage64
Quote:Original post by DevFred
Does that mean that you have already written your own tetris clone? If not, try. You might be surprised at how hard it really is.

I have and you're right, it wasn't easy.

OK, so if you have succeeded at writing small games, maybe it's time to read books about design of large software systems? Like "Design Patterns" by Gamma et al?
Quote:Original post by DevFred
OK, so if you have succeeded at writing small games, maybe it's time to read books about design of large software systems? Like "Design Patterns" by Gamma et al?


I have read various articles (like the ones in the first link in my sig) and looked at some books on software design. I'm very interested in software engineering, design patterns, etc., but it seems that to really understand these things you have to have a lot of programming experience. At the very least, more than writing a tetris clone. I've written some other small things (snake, pong, some very simple 3D demos), but nothing really large that requires a lot of up-front design, and I'm not sure how to make the transition.

That's actually one of the reasons I want to create a more complicated game - so that I can later look at those books again and see if I can apply some of the advice there. But like I said, I'm having trouble coding by myself (staying motivated, etc.) so I wanted to try a different approach.

@jpetire:

You made some interesting comments on the source code of the games you mentioned. Does that mean that you have been reading source code? [grin]
I have made an open source platform game, but I shudder to think about someone using the source code to learn how to build a large program. Why not just start a project yourself? Yes you will make mistakes, but that's often the best way to learn.
Quote:Original post by Gage64
@jpetire:

You made some interesting comments on the source code of the games you mentioned. Does that mean that you have been reading source code? [grin]

Read the article he linked to (which he commented on), on the importance/value of making mistakes as a core part of learning.
Quote:Original post by Gage64
I'm very interested in software engineering, design patterns, etc.
I've written [...] nothing really large that requires a lot of up-front design

"Large software system" does NOT imply "up-front design". Take a look at extreme programming. Agile methodologies see "up-front design" as bad practice. Instead, you should write your software in a way that allows it to be changed easily.

Of course this requires adequate tools for refactoring. For example, say you want to rename a class Foo to Bar. In antiquated environments, you have to rename the file itself, then the name after the "class" keyword, and then you have to manually touch every piece of code that uses the Foo class and change the word Foo to Bar. Oh and don't forget to change the makefiles. And the header inclusion guard macros. Did I forget something? :)

How easily can you rename a class in your environment? I don't know the state of the art in C++ tools, I would really like to know.

With Java and Eclipse, you just go anywhere in the code where the word "Foo" is, press Shift+Alt+R, type Bar and then press enter. All other changes are done automatically, and if there are no potential name clashes, after 2 or 3 seconds everything is done.

Without adequate tools, you need up-front design, because refactoring would simply take too much time. I know C++ as a language is not very parser-friendly, so I wouldn't be surprised if it was harder to rename a class (and that is just the tip of the iceberg of refactoring).

[Edited by - DevFred on July 1, 2008 2:04:30 PM]
There is a book I like which has the full source to the engine. ADVANCED VISUAL EFFECTS WITH DIRECT3D by Peter Walsh.

Link to the source is at the bottom of the page:

http://www.courseptr.com/ptr_detail.cfm?group=Game%20Design%20%26%20Development&subcat=Game%20Art&isbn=978%2D1%2D59200%2D961%2D9#downloads

I would highly recommend picking up the book as well but the source is pretty easy to grok through.

Greg
Founder Caffeinated Gameswww.caffeinatedgames.com
I would read this blog before getting interested in design patterns. I couldn't agree more with Mr. Ericson.

http://realtimecollisiondetection.net/blog/?p=44

It shounds like you are interested in C and C++, but there are a bunch of starter kits for XNA game studio. There was a recent one that was RPG starter kit, but there are ones for FPS type games as well.

This topic is closed to new replies.

Advertisement