Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (565)
Games in Android Showcase (151)
games submitted by our members
Games in WIP (606)
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 20: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 19: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 18:30:24

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

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 04:56:27

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

5  Discussions / General Discussions / Re: JEP for making Unsafe a public API on: 2014-05-05 01: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...

Field field = Unsafe.class.getDeclaredField("theUnsafe");


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 01: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-04 23: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 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 14: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 03:33:07
New log (around 4 minutes of execution):
10  Java Game APIs & Engines / OpenGL Development / Re: How can I improve my rendering? (VAO/VBO) on: 2014-05-02 19: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 14:04:17
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.

Hey there, my -Xprof log result:

As you can see, my 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 (wtf?) is using 13%.
12  Java Game APIs & Engines / OpenGL Development / How can I improve my rendering? (VAO/VBO) on: 2014-05-01 16: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:

Aand the "VertexObject" class used in Tessellator:

(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 18:11:44
Ook, thank you!
14  Game Development / Newbie & Debugging Questions / Run another program inside my program applet/canvas? on: 2012-12-13 17:50:00

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?

Pages: [1]
theagentd (11 views)
2015-03-27 23:08:20

wxwsk8er (52 views)
2015-03-20 15:39:46

Fairy Tailz (46 views)
2015-03-15 21:52:20

Olo (28 views)
2015-03-13 17:51:59

Olo (30 views)
2015-03-13 17:50:51

Olo (37 views)
2015-03-13 17:50:16

Olo (44 views)
2015-03-13 17:47:07

ClaasJG (57 views)
2015-03-10 11:36:42

ClaasJG (41 views)
2015-03-10 11:33:01

Pippogeek (47 views)
2015-03-05 14:36:23
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27 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‑
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!