Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Spot well written games  (Read 11205 times)
0 Members and 1 Guest are viewing this topic.
Haksu
Guest
« Posted 2007-12-29 00:11:19 »

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.

Offline SwampChicken
« Reply #1 - Posted 2007-12-29 05:51:05 »

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

Offline purpleguitar

Junior Member





« Reply #2 - Posted 2007-12-29 14:36:37 »

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. 
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Haksu
Guest
« Reply #3 - Posted 2007-12-29 23:49:48 »

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.

Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #4 - Posted 2007-12-30 13:20:31 »

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. 
For something which is supposed to be good code theres an awfully large number of singletons in there.  Shocked

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline purpleguitar

Junior Member





« Reply #5 - Posted 2007-12-30 13:59:15 »

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.
Haksu
Guest
« Reply #6 - Posted 2007-12-31 01:51:51 »

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.
Offline purpleguitar

Junior Member





« Reply #7 - Posted 2007-12-31 14:38:06 »

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.
Offline Jackal von ÖRF

Junior Member





« Reply #8 - Posted 2007-12-31 15:00:02 »

Hopefully there is finnish word for it.

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

Haksu
Guest
« Reply #9 - Posted 2007-12-31 22:57:55 »

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.

Ok, thanks.


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

Yes, it think that word "ainokainen" has not been used about since 18th century.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #10 - Posted 2008-10-09 15:25:40 »

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
Sad TUER is on sourceforge, I have made some efforts, I have put a lot of comments especially in the most recent classes.

Offline SwampChicken
« Reply #11 - Posted 2008-10-10 05:54:04 »

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

JGO Kernel


Medals: 42
Projects: 11


Game Engineer


« Reply #12 - Posted 2008-10-10 07:32:28 »

Bleh, I so thoroughly avoided Singletons that I didn't even know what they were.  Shocked

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.

See my work:
OTC Software
Offline Del-ONE

Senior Newbie





« Reply #13 - Posted 2008-10-10 22:29:27 »

Any1 know of other sites like Sourceforge, where u can see and take on projects?
Offline Jackal von ÖRF

Junior Member





« Reply #14 - Posted 2008-10-10 23:11:49 »

http://code.google.com/

Offline gouessej
« Reply #15 - Posted 2008-10-11 23:19:23 »

Any1 know of other sites like Sourceforge, where u can see and take on projects?
Free open source games written in Java:
http://tuer.tuxfamily.org/fgf/players_portal/

Offline ewjordan

Junior Member





« Reply #16 - Posted 2008-10-12 10:36:45 »

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).
Offline Markus_Persson

JGO Wizard


Medals: 14
Projects: 19


Mojang Specifications


« Reply #17 - Posted 2008-10-13 11:00:49 »

I am not claiming that my code is the best there is, but I know for sure there is a lot worse out there.

Apart from the singletons (and some comment abuse, but that's a highly personal opinion), that's some seriously clean code, mister!

Play Minecraft!
Offline Jackal von ÖRF

Junior Member





« Reply #18 - Posted 2008-10-13 12:31:20 »

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:
http://dimdwarf.sourceforge.net/
https://dimdwarf.svn.sourceforge.net/svnroot/dimdwarf/trunk/

Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #19 - Posted 2008-11-27 15:17:00 »

Bleh, I so thoroughly avoided Singletons that I didn't even know what they were.  Shocked

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.

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 Smiley.
* blahblahblahh has been reading a thread recently about some truly impressively crap interview questions for programmers...

malloc will be first against the wall when the revolution comes...
Offline cylab

JGO Ninja


Medals: 38



« Reply #20 - Posted 2008-11-27 16:34:57 »

Quote
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?"
"Erm... Just create one" Wink

Mathias - I Know What [you] Did Last Summer!
Offline HappyCat

Junior Newbie





« Reply #21 - Posted 2008-11-27 18:26:12 »

Excuse my ignorance ...

I never use singletons myself (I tend to use classes full of static stuff instead), but what's so bad about them anyway?


Offline cylab

JGO Ninja


Medals: 38



« Reply #22 - Posted 2008-11-27 19:48:49 »

Excuse my ignorance ...

I never use singletons myself (I tend to use classes full of static stuff instead), but what's so bad about them anyway?

The static stuff  Roll Eyes

Serious: Singletons lead to code with implicit dependencies not exposed in the classes interface. This creates unexpected sideeffects. This way large software systems using singletons are difficult to maintain. Especially if there are frequent changes in the development team. Also Singletons and code using Singletons are difficult to unit test.

Mathias - I Know What [you] Did Last Summer!
Offline princec

JGO Kernel


Medals: 339
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #23 - Posted 2008-11-27 19:51:55 »

Can't say that I've ever had a problem with them. They Just Work.

Cas Smiley

Offline HappyCat

Junior Newbie





« Reply #24 - Posted 2008-11-27 20:29:43 »

The static stuff  Roll Eyes

Serious: Singletons lead to code with implicit dependencies not exposed in the classes interface. This creates unexpected sideeffects. This way large software systems using singletons are difficult to maintain. Especially if there are frequent changes in the development team. Also Singletons and code using Singletons are difficult to unit test.

Fair enough. I've been using static stuff like this for years and I can't say I've noticed any problems. Then again, I mostly work on smaller projects with relatively stable teams and no unit testing - oh, the luxury!  :-)

Offline bienator

Senior Member




OutOfCoffeeException


« Reply #25 - Posted 2008-11-27 20:34:40 »

Can't say that I've ever had a problem with them. They Just Work.

Cas Smiley
believe me, they only work if you look at them  Wink

Offline cylab

JGO Ninja


Medals: 38



« Reply #26 - Posted 2008-11-27 21:16:43 »

Sure Singletons do work, but they are just one pitfall more you stumble upon when you last expect it. Using a service/component orientated approach with all required dependencies declared in the constructor makes things so much easier.

But then again, it all depends on the projects' context. (And is really OffTopic Smiley)

Mathias - I Know What [you] Did Last Summer!
Offline princec

JGO Kernel


Medals: 339
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #27 - Posted 2008-11-27 21:21:58 »

Back on topic: singletons work really great in games programming. Actually static instance variables work really great in games programming. You can tell you've got a well written game when there's singletons about because you know someone's just gone and made something work easily and quickly without wanking around.

Cas Smiley

Offline cylab

JGO Ninja


Medals: 38



« Reply #28 - Posted 2008-11-27 21:41:49 »

You can tell you've got a well written game when there's singletons about because you know someone's just gone and made something work easily and quickly without wanking around.
LOL


Mathias - I Know What [you] Did Last Summer!
Offline VeaR

Junior Member





« Reply #29 - Posted 2008-11-27 21:57:03 »

Statics are enemies of threading. Static singletons are enemies of subclassing.

I prefer having all my singletons accessible trough an ApplicationContext, like in servlets or similar to DarkStar. If i need to switch a singleton with a different implementation, i just change the reference in the ApplicationContext. There is no need for all the high-level classes to hold a reference to each other, they all access each other trough the ApplicationContext. I use a number of non-singleton (UpdateContext, CullContext, RenderContext, ThreadContext) context classes too. ThreadLocal is almost as fast as static, and is faster when using multiple threads (even on a hyper-threading but single-core CPU).
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (11 views)
2014-07-24 01:59:36

Riven (9 views)
2014-07-23 21:16:32

Riven (11 views)
2014-07-23 21:07:15

Riven (12 views)
2014-07-23 20:56:16

ctomni231 (42 views)
2014-07-18 06:55:21

Zero Volt (38 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (34 views)
2014-07-16 23:30:00

Cero (49 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!