Java-Gaming.org Hi !
 Featured games (90) games approved by the League of Dukes Games in Showcase (753) Games in Android Showcase (228) games submitted by our members Games in WIP (842) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Show Posts Pages: [1] 2 3
1  Game Development / Game Mechanics / Re: A* AStar Algorithm follow path on: 2013-12-28 13:02:05
Hi, thanks for the answer. The problem lies in the "walking" through those points... the algorithm and grid is fine

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
2  Game Development / Game Mechanics / A* AStar Algorithm follow path on: 2013-12-28 12: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... 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 creepyif (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
 3 Java Game APIs & Engines / OpenGL Development / Re: LWJGL openGL - set new position of vertex array on: 2013-11-14 18: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 17: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
5  Java Game APIs & Engines / OpenGL Development / LWJGL openGL - set new position of vertex array on: 2013-11-14 16:34:38
Hello,

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

 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
6  Java Game APIs & Engines / OpenGL Development / Re: Repeating infinite-like background on: 2013-10-24 17: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.

 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 14: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 19:58:56 Yeah you got it. Thanks for your patience 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!
9  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-19 18: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
 10 Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-19 12: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
11  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-18 20:06:13
this is going to be an one man show, anyway hope is there

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 17:39:19
Thanks dude, but the problem was something else my method for texture rendering used the normal x and y coords

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

 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 Pleaseeeee there is only a little step to success and I can sleep again
 13 Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-18 17:03:56 I would like to have such a contest twice a year instead of only once. Because it's fun 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
 14 Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-17 17: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
15  Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-17 13: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

 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 17: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 09: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
 18 Game Development / Newbie & Debugging Questions / Re: Separating Axis Theorem + OpenGL rotation on: 2013-09-15 16: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 13: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

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 12:22:09
Hello everybody

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);`

21  Game Development / Game Mechanics / Re: Fog of War in 2D RTS Game on: 2013-07-24 12: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 13:05:06 No idea?
 23 Game Development / Game Mechanics / Re: Fog of War in 2D RTS Game on: 2013-07-17 14: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 the biggest 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
 24 Game Development / Game Mechanics / Fog of War in 2D RTS Game on: 2013-07-17 13:53:51 Hello guys 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 Please help me thanks
 25 Java Game APIs & Engines / OpenGL Development / Sun-like light from above and shadows in open GL on: 2013-07-15 14: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 10:06:24 Hello 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
 27 Game Development / Newbie & Debugging Questions / Re: Flickering textures (borders) in slick2D on: 2013-06-27 08: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 08: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 Thanks for the game. Kronos
 29 Game Development / Newbie & Debugging Questions / Re: Flickering textures (borders) in slick2D on: 2013-06-26 08:58:50 Hey vsync really removed the flickering 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 08:29:05 I couldn't fight this flickering yet 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
 Pages: [1] 2 3
 ivj94 (582 views) 2018-03-24 14:47:39 ivj94 (46 views) 2018-03-24 14:46:31 ivj94 (374 views) 2018-03-24 14:43:53 Solater (61 views) 2018-03-17 05:04:08 nelsongames (108 views) 2018-03-05 17:56:34 Gornova (150 views) 2018-03-02 22:15:33 buddyBro (691 views) 2018-02-28 16:59:18 buddyBro (91 views) 2018-02-28 16:45:17 xxMrPHDxx (493 views) 2017-12-31 17:17:51 xxMrPHDxx (730 views) 2017-12-31 17:15:51
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 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