Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Game Mechanics / Re: How to handle collision detection when an entity movement speed is high? on: 2014-05-10 22:04:58
I think I've explained it bad, so here I go again.

I AM checking for collision and not intersection. It's something like:

  • player wants to move from 126,126 to 126,127
  • creates a new Box for that position { x = 126, y = 127, width = 32, height = 32 } (width and height are playerWidth and playerHeight, respectively).
  • check if this box collides with any object (entity/block/etc) on the map. if yes, the movement does not happen. if no, the movement goes normally.

BUT, the problem is: in the example above, the player moved +1 y (his movement speed is 1). but, what if his movement speed is 2?

So, here we go again:

  • player wants to move from 126,126 to 126,128
  • creates a new Box for that position { x = 126, y = 128, width = 32, height = 32 }
  • the new Box endX and endY are 158 and 160, respectively.
  • there is a block located at y = 160.
  • so, the player can't move, since it would collide with the block. BUT, the player could have moved to y = 127 (endY = 159), with 1 movement speed.

So, moving the player with 1 movement speed is alright. The problem is when moving with higher and/or fractional movement speeds (like 2.5, 3.25, etc).
2  Game Development / Game Mechanics / Re: Organizing classes on: 2014-05-10 21:52:29
Is it best to load all of my 3D models at the very beginning of my game, or should I load them for each level and dispose them as levels change?

Is it the loading and storing that slows down the program, or is it the rendering?

This is for mobile devices.

It depends on what is "slows down the program". Loading will increase CPU usage, storing will increase RAM allocated.
3  Game Development / Game Mechanics / How to handle collision detection when an entity movement speed is high? on: 2014-05-10 20:30:24
Hello.

So, basically, my collision detection code is something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
public Boolean canMove() {
  Position pos = positionEntityWannaMoveTo;

  for (WorldObject : All Objects In Map) {
    if (WorldObject.intersects(pos)) {
      return false;
    }
  }

  return true;
}


Ok, obviously, my code isn't like this because it would use too much CPU considering the map has a high number of entities/tiles, but the "base" of the detection is something like that.

Suppose, my player is at Y 126.0, and his height is 32.0. So, his feet Y is 158.0, and there is a solid block at Y 159.0. So, if my player movement speed is 1.0, it will move correctly. But, what if the movement speed is 2.0, then the final move feet Y would be 160.0, being blocked by the block.

Then I tried to divide the movement speed in parts, so it would detect and move each 1.0 of movement speed. But, what if the movement speed is partial, like, 3.5? Then I should move each 0.5 of movement speed? And if it is 3.85?

So, there is a proper way to handle the movements with partial movement speed?
4  Game Development / Game Mechanics / Better way to move the map according to player position? on: 2014-05-08 06:56:27
Hello,

I'm developing a 2D game with tiled-based maps. So, when my player moves any point after/before screenWidth / 2 or screenHeight / 2, it'll .glTranslate the map and everything drawn on it. To calculate when it should translate or not, untranslate or not, and how much translate, I'm not using anything like matrixes: I'm just using pure math code.

My question is: is there a way to do it better? This way, right now, isn't affecting performance or anything related, but I'm just wondering if I could get the same result using transformation or projection matrixes? (Since I don't know how those works.)

Thanks.
5  Discussions / General Discussions / Re: JEP for making Unsafe a public API on: 2014-05-05 03:40:56
Oops, sorry, didn't noticed that!

Well, I know that you are not talking about accesibility... but in case anyone want it, you can easily access the Unsafe class...

1  
2  
3  
4  
5  
Field field = Unsafe.class.getDeclaredField("theUnsafe");

field.setAccessible(true);

return (Unsafe) field.get(null); // Return the Unsafe instance
6  Discussions / General Discussions / Re: JEP for making Unsafe a public API on: 2014-05-05 03:36:05
I don't get it... I can access Unsafe normally, it's a public class. I can normally use 'Unsafe.getInstance()'. So, of what are you talking about?
7  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-05 01:52:28
Well, there's 3 things you need to do:

1. Pack all your sprites into texture atlases. Plenty of information around about how to do this.
2. Sort your sprites according to rendering state needed, eg. blend mode, texture binding
3. Batch all your sprites up into groups with the same rendering state, writing indices out to an index array, and use glDrawElements to draw, say, 100 sprites in one go, rather than 100 calls to glDrawArrays.

Stop using that tesselator thing.

Cas Smiley

Hello, and thanks for answering me, I know how boring this can be.

Well, I'll follow your tips ^^. Just wondering, when you say writing indices out to an index array, it's something like the method 'addVertex' here http://www.java-gaming.org/?action=pastebin&id=910? If yes, is it possible to configure more vertex properties, like brightness and etc using this array? (As I've seen, Minecraft have block brightness, and they are set on the arrays sent to glDrawArrays too.)
8  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-03 16:46:05
Erm... hm... well... yeah, I'm drawing each sprite separately :// I'm very newbie on OpenGL, started learning like 1 month. I don't know how to name it correctly, but the Tessellator class is something like "vertex array immediate mode", isn't it?

Btw, the detectTerrainIntersection was my fault, I was calling it for each entity, each tick. Now I've made some 'cached collisions' workaround and it's working great, not even getting 4% on profilling.

So yeah, the problem is my stupid Tessellator class with immediate mode for every block and every entity on world, since I still am not that experienced to do something like Sprite Batching.

@Edit: Oh, and glBindTexture is taking 8%... another problem from immediate mode.
9  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-03 05:33:07
New log (around 4 minutes of execution):
http://www.java-gaming.org/?action=pastebin&id=912
10  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-02 21:31:20
Hey there,
Just saying, probably tomorrow I'll post it, because I upgraded from Win7 -> Win 8 and Intel haven't published the drivers for my graphics board, so yea it'll take some time 'til I be able to re-open my game.
11  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-02 16:04:17
@orogamo:
Yes I've already seen the display lists, but the problem is: I have some animated tiles. But I'll try it, like rendering all static tiles via display lists and after, draw animated tiles separated, but I still think that the problem isn't the tiles itself, but yes the entities, and the entities are always in movement and changing sprites so display lists won't work :/ Anyway, thanks.

@princec:
Hey there, my -Xprof log result: http://www.java-gaming.org/?action=pastebin&id=911

As you can see, my org.shura.rpg.game.map.MapPhysics.detectTerrainIntersection is taking 15% of the time, but I still don't think this is the main issue (yeah, today I'll try to modify some things on it). GL.drawArrays is using 24%, and java.util.zip.Deflater.deflateBytes (wtf?) is using 13%.
12  Java Game APIs & Engines / OpenGL Development / How can I improve my rendering? (VAO/VBO) on: 2014-05-01 18:40:00
(First, sorry for my bad english, I'm brazilian :/)

Good afternoon,

Well, I'm learning OpenGL/LWJGL right now, and I'm developing a little 2d game:



My problem is, even it's a 2D game, with 12 entities on my map, I'm having only 30 FPS. Yes, it's a crappy 2009' notebook with Intel on-board graphics and a simple dual-core CPU, but the same way, 30 FPS is sooo little for a 2D game.

So I've been reading some tutorials, articles, topics and etc about Sprite Batching, VBOs and VAOs, but I couldn't get it well. My rendering class right now is an edited Tessellator-class taken from Minecraft, used for testing and learning purposes only.

The class "Tessellator" right now:

http://www.java-gaming.org/?action=pastebin&id=909

Aand the "VertexObject" class used in Tessellator:

http://www.java-gaming.org/?action=pastebin&id=910

(Methods like hasColor(), getColor(), hasTexture(), getTextureUV(), etc, are all from sub-class Tessellator, but I'm sure they doesn't matter here.)

So, how can this be improved? I know there's a better solution for glXPointer, but even reading a lot I can't put it on practice.

Thanks in advance.
13  Game Development / Newbie & Debugging Questions / Re: Run another program inside my program applet/canvas? on: 2012-12-13 19:11:44
Ook, thank you!
14  Game Development / Newbie & Debugging Questions / Run another program inside my program applet/canvas? on: 2012-12-13 18:50:00
Hello!

I was thinking... in Java, is there a way to run another java program, and display this program INSIDE my program, via Canvas or something?

Thanks.
Pages: [1]
 

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 (35 views)
2014-07-24 01:59:36

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

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

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

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

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

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

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

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

Riven (56 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!