Not only does this result in cleaner code when rendering and checking collisions (since you don't need to touch the Rectangle object at all), but it also is more flexible for future changes. Let's say you want one of your enemies to have a Circle bounds instead of Rectangle, you only need to change their draw() and intersects() methods.

3. Use descriptive method names like getImage() instead of getI(). It's important to code with some "good practice" as it will make your program easier to read/debug, and also less prone to errors.

@davedes thanks a lot, that seems pretty good the only problem now is that once again i had to re-do everything

PS : all i know to do with Java2D is drawing shapes,images and make them move with or without Key and/or Mouse listeners, if i start learning lwjgl today, how much would it take me to reach that very low level i have now with Java2D ? cause am starting to feel that am wasting my time here, i know that all my errors are not because of Java2D but sooner or later i had to stop developing with it and be forced to learn more advanced things, what do you think ? if i should start learning now, can you please post some "getting started" links ?

thank you

"It's not at all important to get it right the first time. It's vitally important to get it right the last time."

davedes example is n^2. That's fine if n is small. If it gets larger, you only need to check entities which are ahead of itself in the list as all behind have already checked themselves against the current one. Larger still: sweep and prune...larger still...spatial partitioning.

all i know to do with Java2D is drawing shapes,images and make them move with or without Key and/or Mouse listeners, if i start learning lwjgl today, how much would it take me to reach that very low level i have now with Java2D ? cause am starting to feel that am wasting my time here, i know that all my errors are not because of Java2D but sooner or later i had to stop developing with it and be forced to learn more advanced things, what do you think ?

For the record this code is libgdx, not lwjgl (although libgdx uses lwjgl on desktop). Libgdx is a cross platform library and it is quite popular. I would consider it a less maths and graphics, more gamey library. lwjgl is more or less just a wrapping around the opengl functions with stuff like input and window creation thrown in.In terms of lwjgl tutorials, check the wiki: http://www.lwjgl.org/wiki/index.php?title=Main_PageThere are tutorials on how to setup LWJGL, then read the basics section. Then learn about matrices (Nothing on the lwjgl wiki on them). Then read the 3.2 and newer stuff.Or you can learn libgdx. I don't use it so I can't help you.

I don't think LWJGL is a good idea for a beginner. LWJGL is very low level; it doesn't include anything like drawImage or drawRect. You have to build all of that yourself.

Instead, I would recommend LibGDX as suggested in many other threads. The good thing about LibGDX is that it tends to enforce better standards; i.e. using screens to make your game more modular, batching sprites, using texture atlases, etc.

This is how things tend to go when you are just beginning. You write something, and then realize there is a better way of doing it. This is why your first couple games should be very simple; think Tic Tac Toe, Pong, etc.

Quote

if i start learning lwjgl today, how much would it take me to reach that very low level i have now with Java2D ?

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