Java-Gaming.org Java4K winners: [ by our judges | by the community ]         
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members



News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  Print  
  Java Game Dev Wiki  (Read 1806 times)
0 Members and 1 Guest are viewing this topic.
Offline jojoh

JGO Ninja
***

Posts: 554
Medals: 6


games4j.com


« on: 2010-01-25 09:21:49 »

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!

Offline h3ckboy

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #1 on: 2010-01-25 11:11:32 »

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

JGO Ninja
***

Posts: 554
Medals: 6


games4j.com


« Reply #2 on: 2010-01-25 11:43:23 »

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
1  
2  
3  
<pre>
sourcecode
</pre>

Games published by our own members! Go get 'em!
Offline kappa
« League of Dukes »

JGO Kernel
*****

Posts: 2360
Medals: 59


★★★★★


« Reply #3 on: 2010-01-25 17:07:52 »

oh nice, looks like a very good resource.
Offline Wildern

Full Member
**

Posts: 140



« Reply #4 on: 2010-01-28 19:00:26 »

hey, I actually made the collision tutorial just now.

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

Sr. Member
**

Posts: 371
Medals: 8



« Reply #5 on: 2010-01-28 21:47:07 »

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

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #6 on: 2010-01-31 08:31:19 »

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.


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 Smiley

you would be right except for this line of code
1  
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.
Offline JL235

JGO Ninja
***

Posts: 660
Medals: 21



« Reply #7 on: 2010-02-01 05:18:32 »

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.

4) It's convention to use JavaDoc for documenting methods, not comments.

Offline Wildern

Full Member
**

Posts: 140



« Reply #8 on: 2010-02-01 08:06:52 »

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

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


third, which method?

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.

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

you would be right except for this line of code
1  
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.

You are correct, I missed the i.
Offline jojoh

JGO Ninja
***

Posts: 554
Medals: 6


games4j.com


« Reply #9 on: 2010-02-01 08:09:17 »

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.

Games published by our own members! Go get 'em!
Offline jojoh

JGO Ninja
***

Posts: 554
Medals: 6


games4j.com


« Reply #10 on: 2010-02-01 09:17:26 »

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

Offline h3ckboy

JGO Kernel
*****

Posts: 1645
Medals: 4



« Reply #11 on: 2010-02-01 10:41:17 »

@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.

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 Tongue.

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

and anyways, I labeled mine as "box collision", so feel free to add others Smiley
Pages: [1]
  Print  
 
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.124 seconds with 20 queries.