Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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  Java Game APIs & Engines / OpenGL Development / Re: [LWJGL Texture render order?] *solved* on: 2013-01-29 10:59:25
There's several OpenGL debugging functions out there, don't forget to put them in your main loop, so things like that won't occur.
2  Game Development / Newbie & Debugging Questions / Re: How do games like Hill Climb Racing do collision detection? on: 2013-01-09 23:20:12
Look up Box2D, it's a 2D physics engine, probably the best around.
I'm not sure about this because most of the time I use pure LWJGL, but I think that Slick2D comes with it and LibGDX also (which is great for android game development).
However, I'm sure that it wouldn't be too hard to implement it into a LWJGL engine.  Roll Eyes
Edit: And here you go: http://www.jbox2d.org/
If you aren't sure how to use it here's a cool video on it from "TheCodingUniverse".
<a href="http://www.youtube.com/v/ZKJC2cloIqc?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/ZKJC2cloIqc?version=3&amp;hl=en_US&amp;start=</a>
3  Java Game APIs & Engines / OpenGL Development / Re: 2D ray casting lighting problem on: 2013-01-09 21:58:23
A slightly more flexible attenuation would be this:
1  
Attenuation = 1.0 / (ConstantAtt + (LinearAtt * Distance) + (QuadraticAtt * Distance * Distance))


Described here (5.5.1) and implemented here.

Extending it to a spotlight effect should not be too tough, either:
http://glsl.heroku.com/e#5700.4

Smiley
I'll definietly try this out tomorrow, thanks for posting it!
4  Game Development / Newbie & Debugging Questions / Re: Maze Game Advice on: 2013-01-09 18:58:37
Hi.
Some quick answers to your questions:
1. Yes, it's a good idea to make your mazes tile based. It will be useful when you would like to generate random mazes.
2. You can do it by dozens of different ways, however here is a pretty primitive solution:
Refer numbers to your tiles so it'll be like:
0 = Nothing
1 = Wall
2 = Player
And to store these values create a multidimensional array (int[][] level = new level[100][100] <- Here's the code to create 100*100 level).
After this all you have to do on movement is to check if the position where you want to move is a wall or not, with something like this:
1  
2  
3  
4  
5  
6  
7  
int playerPosition_x = 10;
int playerPosition_y = 10;
if(Keys.Right.isPressed()){
   if(level[playerPosition_x+1][playerPosition_y] == 0){
      //You can move here because there's nothing
  }
}

Please keep in my that I don't know how you have to handle inputs on BlackBerry JDE so Keys.Right.isPressed() is just an example.
Also don't forget to check if playerPosition_x+1 (or whatever tile you want to move to) is out of your array's bounds. (e.g. level[101][100], this will throw an OutOfBoundException since our level in my example is only 100 by 100 and not 101 by 100).
If you didn't understand anything just let me know and I'll try to explain it.
Good luck with your project! Smiley
5  Java Game APIs & Engines / OpenGL Development / Re: 2D ray casting lighting problem on: 2013-01-09 18:38:52
Okay, so after some day I've come up with a solution for attenuation with a simple fragment shader. Cool
If anyone else thinking about creating 2D lighting check out my shader: http://glsl.heroku.com/e#5900.4
Also I have to mention that I'm really newbie when it comes to shaders, I've started to learn them 3 hours ago so I'm pretty sure this could be improved, however, it's seems like a nice starting point.  Roll Eyes
6  Java Game APIs & Engines / OpenGL Development / Re: 2D ray casting lighting problem on: 2013-01-05 21:53:54
I guess the best solution is:
float distanceToLight = [...];
float pseudoRadius = Math.sqrt(radius + radius);
float extrusion = pseudoRadius-distanceToLight;

Well, if I understand the code what you gave me correctly then this is exactly what I do right now:
I have a radius to light up, calculate the dark areas and fill them in with polygons.
My only problem is that as you can see on my second picture it's not perfect since the polygon doesn't have as much vertexes as my circle do, and even if it would work I wouldn't be really happy about the result (I kinda want that attenuation).
Maybe I've messed up something, here's my code (it's getting runned for every vertex as you can see):
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public void render(){
   glColor4f(0.976f, 0.972f, 0.772f, 0.8f);
   glCircle3i(x, y, radius);
   glColor4f(0f, 0f, 0f, 1f);
   glBegin(GL_TRIANGLE_STRIP);
   {
      for(int i = 0; i < vertexes.size(); i++){
         Vector2f[] object_vertexes = vertexes.get(i);
         for(int n = 0; n < object_vertexes.length; n++){
            Vector2f p1 = new Vector2f(x+(debugWidth/2), y+(debugHeight/2));
            Vector2f p2 = object_vertexes[n];
            float distance = (float) Math.sqrt((Math.pow(p2.x-p1.x, 2) + Math.pow(p2.y-p1.y, 2)));
            float remaining = radius-distance;
            Vector2f extendedPoint = new Vector2f(p2.x+(p2.x-p1.x) / distance * remaining, p2.y+(p2.y-p1.y) / distance * remaining);
            glVertex2f(p2.x, p2.y);
            glVertex2f(extendedPoint.x, extendedPoint.y);
         }
      }
   }
   glEnd();
}
7  Java Game APIs & Engines / OpenGL Development / 2D ray casting lighting problem on: 2013-01-05 21:23:02
Hey guys, I'm lurking around for a while now but this is my first post, so big hello to you all! Smiley
I'm just getting started with OpenGL and game development so please bear with me guys.
So I've come to the point that I can create all the shapes what I want to, I can handle transformations, and know how to use textures.
I thought that the next step will be 2D lights and shadows but I just can't get it working.
I've read the articles and visited links featured on this forum about it, and I do understand that I should cast "rays" from my lighting spot to all the vertices and then mask away the non visible parts, my only problem is that I don't know how should I do that? Also I don't really understand how to make a lighting source which attenuates with distance.
My thoughts about that is that I just render multiple circles with different opacity, but this sounds like a horrible idea.
For my other problem (lighting and shadows) I've came up with my own crappy solution:
What I do is that I render a light yellow circle with the radius of the light source and low alpha value, then I go through my vertices stored in an ArrayList and check if they're in the radius of the circle and if so then I do extend the vector with "remaining" length (which is getting calculated like this: I calculate the distance between the center of the rendered circle and the vertex and and I substract my radius with it) and I create a vertex at the casted spot (the crossing point of my ray and the vertex) and at the end of the extended vector. I do this with all of the vertices (per object) so I get a black polygon at the end.  Roll Eyes
I know this is really bad solution, altough I've spent a lot of time to make it.
Here's a picture presentating my method (and it's fault when I move light source too close):






I would really appreciate any help.
Thank you all guys, have a nice day Wink
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (33 views)
2013-05-17 21:29:12

alaslipknot (42 views)
2013-05-16 21:24:48

gouessej (72 views)
2013-05-16 00:53:38

gouessej (71 views)
2013-05-16 00:17:58

theagentd (79 views)
2013-05-15 15:01:13

theagentd (74 views)
2013-05-15 15:00:54

StreetDoggy (114 views)
2013-05-14 15:56:26

kutucuk (138 views)
2013-05-12 17:10:36

kutucuk (138 views)
2013-05-12 15:36:09

UnluckyDevil (146 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.179 seconds with 21 queries.