Spot well written games

Hello,

if there is similar thread than this somewhere then please tell me.

I’ve been searching java games and sources from sourceforge but there’s quite many of these and I cannot say are these games coded very well (if I would know then I wouldn’t need to know how those are coded). If someone knows some well coded and commented small games there, post the name/link here, please. I think it may help people to learn something new.

You can learn something from every style of code, regardless of whether it’s ‘good’ or ‘bad’.
Broad code exposure is your friend.

I agree that one can learn from reading any code, but my experience is that reading code is like reading anything else: you learn more from reading material of higher quality. On the other hand, as a teacher, I have seen many students learn and copy bad practices from reading bad code. I therefore believe that Haksu’s request has merit.

I am not claiming that my code is the best there is, but I know for sure there is a lot worse out there. My EEClone game is a case study for teaching design patterns through Java game development. It’s not on sourceforge, but you can download the source at http://www.cs.bsu.edu/~pvg/games/eeclone. I appreciate any feedback you have, especially since I am currently working on a similar case study with different pedagogic motivation. I hope thiis useful to you. For the academics out there, I have a paper on EEClone in the proceedings of SIGCSE '07 conference and a longer version is forthcoming in JERIC.

SwampChicken: I really believe that I can atleast save some time if I learn only the good things.

purpleguitar: Thank you very much, I’ll look into it,

I forgot to add that programs doesn’t have to be from sourceforge.

Thank you both for answering.

For something which is supposed to be good code theres an awfully large number of singletons in there. :o

This is explained in the JERIC paper, but here’s the gist of it. The Singletons were placed there for pedagogic purposes. As soon as students see Singletons, they grab onto them and abuse them. This happens whether they are introduced in class or whether they see them somewhere else. The problem with seeing them outside of a controlled environment is that the problems inherent in Singletons are not obvious. Hence, I made a conscious effort in this project to include a few Singletons so that we could have class discussions about how they worked syntactically and what the implications were for overall system design. The conversations were very enlightening, with most students seeing that Singletons were dangerous. (In fact, you and I had a very similar discussion to this earlier regarding sound systems, and that’s one place where my students seemed to think that the Singletons were okay.)

Unfortunately, despite the enlightening conversations, I saw that my students still abused the Singletons, especially the old C/C++ programmers who cared more about coding than software design. My current plan is that, next time I undertake this kind of project, that it needs to be large enough scale that the implications are clear. To do this would require writing several versions of a software system, so that the negative effects of ad hoc design decisions made early in the lifecycle can be seen later in the lifecycle. Of course, I’ll probably never have the time to actually do this, and we’re hindered in University by the semester system: even the biggest one-semester student project is still small, in the grand scheme of things.

So to sum it up to Haksu: I recommend understanding Singletons so that you can communicate about them, but I do not advise using them, despite what’s in the EEClone code.

I had to use wikipedia to find out what singleton means and I’m still not sure what it means. Hopefully there is finnish word for it.

I caution you against using Wikipedia for specific design patterns: there is some information on there that is a bit strange and, in my opinion, plain wrong. (Who has time to get into edit wars over such things though?) The c2 pages are much more insightful, in my opinion: http://c2.com/cgi/wiki?SingletonPattern

In a nutshell: a Singleton is a class for which there is only one* globally-accessible instance.

*The c2 article points out that the “one” part is not strictly necessary, as long as the client can treat the returned instances as being equivalent.

The Finnish word would be “ainokainen” (see page 3) but nobody uses that word in real life. The word “singleton” is used instead.

Ok, thanks.

Yes, it think that word “ainokainen” has not been used about since 18th century.

:frowning: TUER is on sourceforge, I have made some efforts, I have put a lot of comments especially in the most recent classes.

Haksu,
In the meantime buy/steal/borrow/torrent a finnish version of the book Effective Java, 2nd edition by Joshua Bloch

Bleh, I so thoroughly avoided Singletons that I didn’t even know what they were. :o

I had a job interview where they asked me about them, basically saying, “If you wanted to have a variable that there was only instance of, how would you do that?” My response was… “Uh, make it static?”

Wrong, I guess. But I still have never personally seen a situation where a static variable doesn’t do the job better.

Any1 know of other sites like Sourceforge, where u can see and take on projects?

http://code.google.com/

Free open source games written in Java:
http://tuer.tuxfamily.org/fgf/players_portal/

David Brackeen (who’s around here sometimes) put out a Java game development book, Developing Games in Java, that is certainly worth taking a look at even if it’s a few years old: http://www.brackeen.com/javagamebook/ is the home page, though the purchase link seems to be broken - you can probably find it on Amazon. His project, Pulpcore (http://www.interactivepulp.com/pulpcore/), is a very well designed open source 2d game library that would give you an example of excellent game code - it’s not exactly a game, but it’s got tons of useful stuff for games in it, and might give you some ideas. It’s all very well organized, so it should be intelligible.

Also, I second the recommendation of Effective Java, it’s a great read and has a lot of useful advice - IMO, the advice in that book is far more applicable to games than any of the design pattern overload that is so prevalent in most Java books (to be fair, that stuff is essential for enterprise Java, but the focus in a game is totally different since you don’t have to worry about extensibility as much, which is what most design patterns aim to maximize).

[quote=“purpleguitar,post:3,topic:31160”]
Apart from the singletons (and some comment abuse, but that’s a highly personal opinion), that’s some seriously clean code, mister!

True, it’s not bad, although there is still some room for improvement. I recommend reading the book Clean Code.

Here is what my code looks like nowadays:


https://dimdwarf.svn.sourceforge.net/svnroot/dimdwarf/trunk/

Awesome answer.

When they shake their heads, ask “what? It works.”.

When they say “but you want to prevent access to that variable based on context and situations”, you’d obviously go “um, OK, wrap it in an object”, at which point you’ve just described a singleton.

IMHO it’s a stupid question if they stopped at the “only one instance” point - and suggests they probably dont understand the craptitude of singletons themselves :).
* blahblahblahh has been reading a thread recently about some truly impressively crap interview questions for programmers…