Java Game Dev Wiki

For quite some time I have been thinking that there should be some sort of wiki page associated with Java game dev. A lot of really useful information appears in this forum and some really brilliant things are discussed. However several things that I need now were discussed some years ago, and signal to noise ratio and discussions vs conclusions makes it difficult to find what I am looking for(even though that is much better than most other places). I expect that goes for many others here as well. Since I run the games4j.com website, I have been planning a wiki for some time, but the java4k compo was actually the thing that pushed me from planning to doing.

So anyway here is the wiki:
wiki.games4j.com

Let me know what you think about this idea, and if you will contribute to it.

I did add some initial stuff in there, to my best knowledge. Do edit it if you think it is wrong and don’t be afraid to add stuff. No need for signup(for now at least), so just start typing.

Since the wiki is connected to http://games4j.com I added a section for all the platforms that the site supports.

Hope you like it!

hey, I actually made the collision tutorial just now.

one question: how do I do code boxes? or even for that matter make it skip lines, cause it wont when I am doing code, so it is like completely blocked up…

looking good

edit: nvm, figured it out by looking at the fullscreen one you did.

Yes, a good place to start if you don’t know wiki markup/formatting so well, is to go to: http://en.wikipedia.org/wiki/Wikipedia:Cheatsheet. However the code style markup is not in there. For that you can use


<pre>
sourcecode
</pre>

oh nice, looks like a very good resource.

Looking at the tutorial, it could use a little cleanup.

  1. The Sprite class should create the bounds rectangle in it’s constructor and the getBounds method should just return that rectangle to avoid unnecessary object creation.
  2. Decide on collide or collision for the method name, both are used at the moment.
  3. It should be clear that the sprite’s position should not change within that method (as the new position might result in missed collisions)
  4. Collision only needs to be called on one of the sprites. The way it is written, collision will be called twice on each sprite in the collision.

I really like the idea of a Wiki. I put my game loop code.

for the first one, I have to make it every time… cause otherwise the rectangle would not move whenever the player moved.

second, sry, I must have missed that, I fixed it (I wrote most of that code on the spot…)

third, which method?

fourth, i dont know what to say besides, your wrong, and here is why :slight_smile:

you would be right except for this line of code

for (int j = [b]i+1[/b]; j < actors.size(); j++) {

you will notice that the second for loop starts in the list one AFTER the sprite it has already picked.

I have a few points…

  1. Why would the sprite always be represented by a rectangle? A shape would be better which defaulted to a rectangle. Shoot-em-ups usually represent the player with a single pixel whilst circles often work better for bullets then rectangles because the bullets are circular. That’s just two examples and there are plenty more.

  2. Some of the code isn’t formatted correctly, there is no tabbing. I’ve reformatted the code on your collision page but it should have been written correctly in the first place.

edit:
3) You don’t need to comment every line, just describe the important blocks of code. Commenting every line just adds confusion and things like marking where a method ends and their code continues is just overkill. When it’s 3 lines long and the only method, people can tell where it ends.

  1. It’s convention to use JavaDoc for documenting methods, not comments.

Sorry, I am used to using a fixed bounding rectangle and sprite’s position as an offset.

collide, if you move the sprite in that method you could move it into a sprite you have already checked or away from a sprite you have not checked yet.

You are correct, I missed the i.

Cool! Some nice contributions are arriving!

Gaming and networking frameworks has been added to the lists, 4K hints added and improved, and code examples in “Timing in main loops” and “Collision detection”.

@h3ckboy

You were using mixing Sprite and Actor in the code. I changed it to only use Sprite, since that is the most predominant.
http://wiki.games4j.com/wiki/en/Special:Diff?topic=Collision_detection&version2=76&version1=77

I also added some links that can be useful for geometry based collision detection.

Definitely a good point. I see that code as just one way of doing a simple collision check, so it makes sense to have it there. The problem is that Shape.intersects() only works for rectangles, so code for arbitrary Shapes would probably be much more complex. However, anyone with such working code are welcome to add or link them.

I have some code for lines, circles, rectangles and rotated rectangles, but the code is very proprietary to my situation, so I can’t add that as it is. I added some links that I based my code on.

sry, I used actor, and I tried to use sprite… but I must have accidentally wrote actors.

I remind you, I wrote that code one on the spot, so some might be wrong :P.

about the other shapes, basically the same as jojoh said…

and anyways, I labeled mine as “box collision”, so feel free to add others :slight_smile: