Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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] 2 3
1  Game Development / Game Mechanics / Re: A* AStar Algorithm follow path on: 2013-12-28 14:02:05
Hi, thanks for the answer. The problem lies in the "walking" through those points... the algorithm and grid is fine Wink

This is how I got so far, after starting this topic:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
int mul = 0;
   public void update(int delta) {
      if (waycount >= 0) {
         if (waycount >= 1 && way.get(waycount-1) == null) {
            waycount--;
         } else if(waycount >= 1 && way.get(waycount-1) != null) {
            if ((way.get(waycount-1).x - way.get(waycount).x) < 0) {
               mul = -1;
            } else if ((way.get(waycount-1).x - way.get(waycount).x) > 0) {
               mul = 1;
            } else if ((way.get(waycount-1).x - way.get(waycount).x) == 0) {
               waycount--;
            }
         }
         
         x += mul * Timer.getInstance().getMovementSpeed() * delta;
         
         if((mul < 0 && Floor.convertToIndexX(x) <= way.get(waycount).x) || (mul > 0 && Floor.convertToIndexX(x) >= way.get(waycount).x) ) {
            waycount--;
         }
      } else {
         if (!arrived) {
            x = Floor.convertToPixelX(way.get(0).x);
            arrived = true;
         }
      }
   }


First I try to determine which direction I have to choose, -1 or 1.... This does not work everytime... however  Roll Eyes
2  Game Development / Game Mechanics / A* AStar Algorithm follow path on: 2013-12-28 13:31:03
Hey,
I'm working on a SimTower clone, and have implemented an a star algorithm successfully, BUT I got huge problems following the path I get from the algo. I got units which can move in that "tower", and each unit gets an own path as an ArrayList containing waypoints. The problem is, that these waypoints are coordinates from a two dimensional array, which I created on the flow from the information my tower gives. I didn't implemented my tower tile based, that is not cool... Sad however I have to convert all tower information into an 2dim Array. I think there is no mistake. The problem is to follow the path...

1  
2  
3  
4  
5  
x += (Floor.convertToPixelX(way.get(waycount).x) - x); //moving that unit, not with delta time yet.... works, but creepy

if (Floor.convertToIndexX(x) == way.get(waycount).x && Floor.convertToIndexX(y) == way.get(waycount).y) {
waycount--;  //waycount starts with the highest index... the fist part of the way
}


I dont need a 100% solution for this. I need an idea how to implement it better, and make it even work. How would you do this? If you interessted in my Waypoint class, let me know, maybe the whole implementation is crap Sad
3  Java Game APIs & Engines / OpenGL Development / Re: LWJGL openGL - set new position of vertex array on: 2013-11-14 19:24:11
Hey that really brought light into it. Thanks a lot. So I render my stuff and moving them around with translations and so on. And If I want to check for collision, I use the ordinary xyz with height depth values, which I change simultaneously!? That makes sense. By the way, using the SAT for collision detection is the right ways, or?

Another question. As I said, these vertices are fixed. I have a class Cube(x, y, z, width, height, depth), how would you bring them in the array?
4  Java Game APIs & Engines / OpenGL Development / Re: LWJGL openGL - set new position of vertex array on: 2013-11-14 18:55:34
Hi,

I currently  have these fixed vertices and add a value on the x and z axis to "move" them. This is done by a loop. So I'm iterating over all vertices and add a value. Because I think (I might be very very wrong), that "only" translating them, won't do anything on the vertices. The data is the same. So how could I possibly check for collision, if i check always the same information. I have to change them. But how? With stupid for loops?! Not really Cheesy
5  Java Game APIs & Engines / OpenGL Development / LWJGL openGL - set new position of vertex array on: 2013-11-14 17:34:38
Hello,

I got a massive problem to understand how I can set a new position of my vertex array.

If this is my quad

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
float[] vertices =
         {      
    -1.0f, -1.0f, 1.0f,
          1.0f, -1.0f, 1.0f,
          -1.0f, 1.0f, 1.0f,
          1.0f, 1.0f, 1.0f,

          -1.0f, -1.0f, -1.0f,
          1.0f, -1.0f, -1.0f,
          -1.0f, 1.0f, -1.0f,
          1.0f, 1.0f, -1.0f,

          -1.0f, 1.0f, 1.0f,
          1.0f, 1.0f, 1.0f,
          -1.0f, 1.0f, -1.0f,
          1.0f, 1.0f, -1.0f,

          -1.0f, -1.0f, 1.0f,
          1.0f, -1.0f, 1.0f,
          -1.0f, -1.0f, -1.0f,
          1.0f, -1.0f, -1.0f,

          -1.0f, -1.0f, 1.0f,
          -1.0f, 1.0f, 1.0f,
          -1.0f, -1.0f, -1.0f,
          -1.0f, 1.0f, -1.0f,

          1.0f, -1.0f, 1.0f,
          1.0f, 1.0f, 1.0f,
          1.0f, -1.0f, -1.0f,
          1.0f, 1.0f, -1.0f};


And I want that quad to move, do I have to iterate through each vertex and change it? glTranslatef() is a possibilty, BUT the vertices aren't changed, so I cannot make a collision detection, right? It will only be moved on the screen as I render it, but the numbers would be the same. So how can I do this effiently? I'am really suprised, because every single tutorial (written or youtube) do not cover this. They only translate them around, and that should be all?? BTW, has anyone a good collision detection tutorial for me? I really appreciate any help  Kiss
6  Java Game APIs & Engines / OpenGL Development / Re: Repeating infinite-like background on: 2013-10-24 19:15:18
Thanks for the answers. Right now I have two ArrayLists. The First contains my street marks as rectangles. The second is the "garbage collector" for the rectangles, which aren't seen anymore.
I add them this way:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
         
if (player.x % 800 > last) {

float width = 160;
float height = 15;
for (int i = 0; i < 10; i++) {
streetMarks.add(new Entity(streetMarkcounter * width + streetMarkcounter * 60, Window.getHeight() / 2, width, height));
streetMarkcounter++;
}

last = (int) (player.x % 800);
}


So every 800 pixels there should come these marks. But sometimes, that doesn't work. I also use this way to add new enemies, every 800 pixels. But something is wrong.

Does anyone know whats up there? thanks
7  Java Game APIs & Engines / OpenGL Development / Repeating infinite-like background on: 2013-10-24 16:22:09
Hello guys,

I need your help again. Imagine you're looking onto a road like a bird and you're flying it in eastern direction. I want the background to be always white stripes (the road middle marks) to move with. I already got a crappy solution ( I won't show it yet, because I want to see what you think) but as I said this is crap.

Or this way: How would you draw an infinite road from the birds-eye's view?

Thanks a lot.

cheers Kronos
8  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-21 21:58:56
Yeah you got it. Thanks for your patience Cheesy
In addition that I forgot to add the coords I had a messed up Camera class.... I fixed it and everything is fine now. Many thanks!  Kiss
9  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-19 20:04:34
Hello,

that helped a bit. But I'm stucking again.
The pumpkin is either in the left bottom corner, but rotates the right way. If I add x and y coords it runs faster then the particle effect, which uses only the x and y coords from the pumpkin. It has also the 4 Verctors for the polygon.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
      float radAng = (float) Math.toRadians(this.angle);
      float cz = (float) Math.cos(radAng);
      float sz = (float) Math.sin(radAng);
     
      float hx = (width/2);
      float hy = (height/2);
     
      float hx1 = -hx;    // top left
     float hy1 = -hy;
      float hx2 = -hx;   // bottom left
     float hy2 =  hy;
      float hx3 =  hx;   // bottom right
     float hy3 =  hy;
      float hx4 =  hx;   // top right
     float hy4 = -hy;
     
// I added the x and y coords. looked good at first
     float x1 = cz * hx1 - sz * hy1;
      float y1 = sz * hx1 + cz * hy1;
      float x2 = cz * hx2 - sz * hy2;
      float y2 = sz * hx2 + cz * hy2;
      float x3 = cz * hx3 - sz * hy3;
      float y3 = sz * hx3 + cz * hy3;
      float x4 = cz * hx4 - sz * hy4;
      float y4 = sz * hx4 + cz * hy4;

      tmpDots[0].set(x1, y1);
      tmpDots[1].set(x2, y2);
      tmpDots[2].set(x3, y3);
      tmpDots[3].set(x4, y4);


the pumpkin should be where the particle effect is.


any idea? I think I messed up everything by now Sad
10  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-19 14:17:45
Hello,
Yes I want to rotate the pumpkin around it's center and move it in its new facing direction. I Think it is the same as in GTA I + II. I think it is called Bird's-eye view. however, there is only missing the translation because it has now a too big rotation radius, and thats completely wrong. I hope you guys understand me better now Cheesy
11  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-18 22:06:13
this is going to be an one man show, anyway hope is there  Roll Eyes

This is the current rotation at an angle given by the user input (left right key)



this code is doing the rotation...

1  
2  
3  
4  
5  
   
tmpDots[0].set(x * cosAngle - y * sinAngle, x * sinAngle + y * cosAngle);
      tmpDots[1].set(x * cosAngle - (y + height) * sinAngle, x * sinAngle + (y + height) * cosAngle);
      tmpDots[2].set((x + width) * cosAngle - (y + height) * sinAngle, (x + width) * sinAngle + (y + height) * cosAngle);
      tmpDots[3].set((x + width) * cosAngle - y * sinAngle, (x + width) * sinAngle + y * cosAngle);


I saw this behaviour when I only used the glRotatef() method without translating, but in this case I really do not know how to translate it.
12  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-18 19:39:19
Thanks dude, but the problem was something else Cheesy my method for texture rendering used the normal x and y coords Cheesy

I think I got the right rotation Part, but now it has to be translated that it rotates around its center. In openGl I used this

1  
2  
3  
GL11.glTranslatef(player.x-player.width/2, player.y-player.height/2, 0f);
GL11.glRotatef(player.angle, 0f, 0f, 1f);
GL11.glTranslatef(-player.x-player.width/2, -player.y-player.width/2, 0f);


what would be the equivalent in "plain" java code. I naivle tried this Cheesy

1  
2  
3  
4  
5  
6  
7  
before:
      x -= width/2;
      y -= height/2;

after rotation:
      x -= -width/2;
      y -= -height/2;


I feel a little bit dumb with this try Cheesy Pleaseeeee there is only a little step to success and I can sleep again  Pointing
13  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-18 19:03:56
I would like to have such a contest twice a year instead of only once. Because it's fun Cheesy
And lwjgl should be an option too. I saw that the last lwjgl16k contest was in 2011. Maybe we could rearrange this and combine it with the rules of 4K and relieve the contest.
And the execution problem isn't one, because who except us is going to play them? We know how to execute a jar file.

We could also use a wrapper like jarSplice. But in the end we have to do this contest. Either with Graphics2D or GL11 Cheesy

 persecutioncomplex Pointing
14  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-17 19:37:18
Hey thanks for the answer, could please show me with code or an example? I tried some thing that didn't work or did the same Cheesy
15  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-17 15:19:23
Ok I came to the point that rotating the polygons only with openGL is not the right way, because it is just an illusion. The actual verctors aren't rotated at all.

So here is my code (little different now) with the user input and rotating stuff. What do I have to do? Really I do not come further. I need your help. Getting desperate  Cry

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
hip = forwardSpeed * delta;
     
         float radAng = (float) Math.toRadians(player.angle);
         float cosAngle = (float) Math.cos(radAng);
         float sinAngle = (float) Math.sin(radAng);
         
         
         if(Keyboard.isKeyDown(Keyboard.KEY_W)) {
            player.x += hip * sinAngle;
            player.y += hip * cosAngle;
         }
         
         if(Keyboard.isKeyDown(Keyboard.KEY_S)) {
            hip = backwardSpeed * delta;
           
            player.y -= hip * Math.sin(Math.toRadians(player.angle));
            player.x -= hip * Math.cos(Math.toRadians(player.angle));
         }
16  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-16 19:20:15
Okay thanks, but I think I will keep it as it is, I might want to use more than 4 axes later.

Anyone else can help me with the real problem?
17  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-16 11:36:00
I did not found out something new, but I created a screenshot to visualize my problem. I understand that the collision detection is working, but only internally. What I am rendering is not true!?

Here you are:



please please help meee  Pointing
18  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-15 18:30:05
Hey thanks for your answer. Only the Player's polygon is rotated, the other polygons are "normal". I did not understand your last sentence. What do you mean exactly?
19  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-15 15:41:32
Oh I am sorry

This methods are in Polygon

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
   public boolean collides(Polygon polygon) {
      Dot[] axes = new Dot[polygon.dotCount];
     
      for(int i=0; i < polygon.dotCount; i++) {
         Dot p1 = polygon.getDots()[i];
         Dot p2 = polygon.getDots()[i + 1 == polygon.dotCount ? 0 : i +1];
         
         Dot edge = p1.subtract(p2);
         Dot normal = edge.perp();
         axes[i] = normal;
      }
     
      for(int i=0; i < axes.length; i++) {
         Projection p1 = this.project(axes[i]);
         Projection p2 = polygon.project(axes[i]);
         
         if(!p1.overlap(p2)) {
            return false;
         }
      }
     
      return true;
   }

   public Projection project(Dot axis) {
      float min = axis.dotProd(getDots()[0]);
      float max = min;
     
      for(int i=1; i < getDots().length; i++) {
         float p = axis.dotProd(getDots()[i]);
         
         if(p < min) {
            min = p;
         } else if(p > max) {
            max = p;
         }
      }
     
      return new Projection(min, max);
   }

where Dot is a Vector, I just called it Dot Wink


Projection.class
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
public class Projection {
   
   protected float min;
   protected float max;
   
   public Projection(float min, float max) {
      this.min = min;
      this.max = max;
   }
   
   public boolean overlap(Projection proj) {
      boolean temp = true;
      if(min > proj.max || max < proj.min)
         temp = false;
     
      return temp;
   }
}


I hope that was all of the relevant code. Sorry again, I thought that was a common problem.
20  Game Development / Newbie & Debugging Questions / Separating Axis Theorem + OpenGL rotation on: 2013-09-15 14:22:09
Hello everybody Smiley

I finally got SAT working but only if I leave out the roation part from OpenGL. My Player object rotates around his own axis
1  
2  
3  
         GL11.glTranslatef(player.x-player.width/2, player.y-player.height/2, 0f);
         GL11.glRotatef(player.angle, 0f, 0f, 1f);
         GL11.glTranslatef(-player.x-player.width/2, -player.y-player.width/2, 0f);


Works great so far. But the collision detection does not recognize that the polygon (trapez) has rotated.
How do I connect my SAT collision detection with the angle my polygon has rotated?

This is how I go forward:

1  
2  
3  
            
player.y += speed * delta * Math.sin(Math.toRadians(player.angle) - Math.PI/2);
player.x += speed * delta * Math.cos(Math.toRadians(player.angle) - Math.PI/2);


I really need your help Smiley thanks in advance
21  Game Development / Game Mechanics / Re: Fog of War in 2D RTS Game on: 2013-07-24 14:16:48
Here is what I found now. Works fine

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
   
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT);

GL11.glEnable(GL11.GL_STENCIL_TEST);
           GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xffffffff);
           GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_REPLACE, GL11.GL_REPLACE);
           GL11.glColorMask(false, false, false, false);

      //draw white circle here
         
           GL11.glColorMask(true, true, true, true);
           GL11.glDepthMask(true);
           GL11.glStencilFunc(GL11.GL_NOTEQUAL, 1, 1);
           GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
           
                //draw black fog here
       
      GL11.glEnable(GL11.GL_STENCIL_TEST);
22  Game Development / Game Mechanics / Re: Fog of War in 2D RTS Game on: 2013-07-23 15:05:06
No idea? Sad
23  Game Development / Game Mechanics / Re: Fog of War in 2D RTS Game on: 2013-07-17 16:15:38
Okay I think I solved the problem that the map is kept revealed bye just saving pixels to an array and so on. That shouldn't be the problem. The only one left is the rendering Cheesy the biggest Tongue

The Question again: Which blendFunc in combination with what other commands do I have put together in which order?

I really appreciate any code snippets Cheesy
24  Game Development / Game Mechanics / Fog of War in 2D RTS Game on: 2013-07-17 15:53:51
Hello guys Smiley

I'm making a 2d openGL RTS game with lwjgl. Everything is good so far, but I want to implement the fog of war.

I thought of alphamapping the units of the localplayer by blending them. I already made this alpha map effect with slick2D, but I am quite new to openGL and can't figure out to make this.
But there are two problems. I don't want to use textures for the "revealing map action" of a unit, instead I want to draw circles with individual radii. The second problem is, that the map is would only be revealed temporarly. If they move further, the map would be black with this solution. Instead it should be 50% transparent or something like that. YOu all know how fog of war works Cheesy

Please help me Smiley

thanks
25  Java Game APIs & Engines / OpenGL Development / Sun-like light from above and shadows in open GL on: 2013-07-15 16:10:00
Hello,

I'm thinking about having shadows in my game. It is a 2D game seen from above. I want to implement shadows. The rendered sprites and images should get their own dynamic shadow. How would you implement this? Or is it advisable to draw it staticly in the sprite itself? The light must not be movable.

I hope somebody can help me.
Thanks in advance
26  Game Development / Newbie & Debugging Questions / A lot of ArrayLists. Is this good style? on: 2013-07-13 12:06:24
Hello Smiley

Everytime I start coding a game I tend to use lots of ArrayLists, for example when I want to store entities. I iterate through them to check for collisions. Is this a good way to implement a game... consisting of arraylists?

How do you handle entities and so on?

I would appreciate any tipps.
THanks  Wink
27  Game Development / Newbie & Debugging Questions / Re: Flickering textures (borders) in slick2D on: 2013-06-27 10:33:45
HI, do you mean the movement from the character or camera? The character is multiplied with delta. But the in the translation method I dont use any delta.
28  Games Center / Showcase / Re: [Web][PC] DRINK - A One Button Game on: 2013-06-27 10:07:34
Wow, this is really funny and a nice game. I love the artwork and that the girls sprinkles herself with the juice. I really laughed loud Cheesy
Thanks for the game.

Kronos
29  Game Development / Newbie & Debugging Questions / Re: Flickering textures (borders) in slick2D on: 2013-06-26 10:58:50
Hey vsync really removed the flickering Cheesy thanks, I didn't thought of it, because I always thought I enabled it.

But now the translation looks jerky ( I hope it is the right word), like it would stuck after every "centimetre". Is there something in my translation code, that causes this?
30  Game Development / Newbie & Debugging Questions / Re: Flickering textures (borders) in slick2D on: 2013-06-26 10:29:05
I couldn't fight this flickering yet Sad
But I think the way I handle my background could be a hughe factor for this appearance. I have a 1024*512 big PNG for the background. I scale it during runtime every frame by 3, so it's 3072* 1536.
First I had this size, but slick said this would be too big for the current Hardware (onBoard Graphics). So we decided to scale it down do meet the requirements, since it is pixelart it could be scaled anyway.

But is this the proper way? I mean it works, but the flickering (only during camera translation) is not beatiful at all  Undecided
Pages: [1] 2 3
 

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

The first screenshot will be displayed as a thumbnail.

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

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

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

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

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

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

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

Riven (48 views)
2014-07-14 18:02:53

OpenGLShaders (38 views)
2014-07-14 16:23:47

Riven (37 views)
2014-07-14 11:51:35
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!