Show Posts
|
|
Pages: [1] 2
|
|
6
|
Game Development / Game Mechanics / Re: How would you do player-to-player collision with box2d?
|
on: 2013-05-11 10:47:39
|
I tried, but it seems like this too causes the two bodies to become stuck. I guess that when velocity is set to zero they stay in a colliding state. ? What happens if you set the linear velocity to (0,0) only if the linear velocity is not (0,0)? This way, once they collide and their linear velocities are already at (0,0) --- you can move them again. I think that's a better way of handling it than separating them just enough so that they could move again. for example: 1 2 3 4 5 6 7 8 9
| if(fixtureA and fixtureB are both players){ if(fixtureA.getBody().getLinearVelocity != (0,0)){ fixtureA.getBody().setLinearVelocity(0.0f,0.0f); }
if(fixtureB.getBody().getLinearVelocity != (0,0)){ fixtureB.getBody().setLinearVelocity(0.0f,0.0f); } } |
Maybe you could try it out.
|
|
|
|
|
7
|
Game Development / Networking & Multiplayer / Re: Connect Java App to a Wordpress MYSQL Database
|
on: 2013-05-11 10:07:21
|
MySQL has nothing to do with PHP. What you need to do is simply to connect to the database directly from you java code, and perform the (SQL) query. Do some google searches for "mysql java tutorial". It might also be possible to decide if a user is succesfully authenticated based on the HTTP status codes. If wordpress does this in a sane way 
|
|
|
|
|
12
|
Game Development / Game Mechanics / How would you do player-to-player collision with box2d?
|
on: 2013-05-10 08:05:12
|
|
I'm trying to find a good way to achieve "correct" behavior when two players collide in a multiplayer game. My current situation is that when they collide, they apply forces to each other and starts spinning and changing direction.
I want them to be unable to walk through each other, but not to cause any force/impulse being applied. One idea I have is to add collision filtering for the players, and handle it manually.
|
|
|
|
|
23
|
Java Game APIs & Engines / OpenGL Development / Re: Render to texture (FBO) - result is upside down
|
on: 2011-04-22 23:32:20
|
Yes, seems like that was the problem. I went from this 1 2 3 4 5 6 7 8 9 10 11 12 13
| private void drawFullscreenQuad() { glBegin(GL_QUADS); glNormal3d(0, 0, 1); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(width, 0); glTexCoord2f(1, 1); glVertex2f(width, height); glTexCoord2f(0, 1); glVertex2f(0, height); glEnd(); } |
to this 1 2 3 4 5 6 7 8 9 10 11 12
| private void drawFullscreenQuad() { glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(0, 0); glTexCoord2f(1, 1); glVertex2f(width, 0); glTexCoord2f(1, 0); glVertex2f(width, height); glTexCoord2f(0, 0); glVertex2f(0, height); glEnd(); } |
and now it works fine. I think I was confused by the fact that in slick2d (0,0) is upper left corner. Thanks for helping me sorting it out! 
|
|
|
|
|
25
|
Java Game APIs & Engines / OpenGL Development / Render to texture (FBO) - result is upside down
|
on: 2011-04-22 21:47:12
|
I've managed to render to texture, and also render the resulting texture on a quad. My problem is that the result is upside down and I cannot figure out why. What I basically do is creating an instance of the following class with the screen size as width and height parameters. Then I activate it when I want to start rendering to texture, and deactivate it when I'm done. Then I fetch the result as a texture id, which I then bind to GL_TEXTURE_2D later on. This works fine, but as I said from the beginning: it is upside down! LWJGL code:
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 41 42 43 44 45 46 47 48
| import org.lwjgl.BufferUtils; import org.lwjgl.opengl.*;
import java.nio.ByteBuffer;
public class FBORenderer { private int fbo; private int texture; private int height; private int width; private ByteBuffer byteBuffer;
public FBORenderer(int w, int h) { fbo = ARBFramebufferObject.glGenFramebuffers(); texture = GL11.glGenTextures(); width = w; height = h;
activate();
byteBuffer = BufferUtils.createByteBuffer(4 * width * height);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_BYTE, byteBuffer);
ARBFramebufferObject.glFramebufferTexture2D(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, ARBFramebufferObject.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
deactivate(); }
public void activate(){ ARBFramebufferObject.glBindFramebuffer(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, fbo); }
public void deactivate() { ARBFramebufferObject.glBindFramebuffer(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, 0); }
public int getTexture() { return texture; } } |
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Re: Render to texture using FBO - result texture is white
|
on: 2011-04-18 19:01:03
|
Thanks to both of you! The render texture stuff was just left overs from some trial and error. sorry @Bonbon-Chan you were right about the texture filter. After adding that I got it working! Anyhow, I couldn't manage to call glTexImage2D with null as the last argument. If I try to create a smaller bytebuffer I get an error telling me that the buffer's size is x but must be y.
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / Render to texture using FBO - result texture is white
|
on: 2011-04-17 20:30:20
|
I'm trying to render to texture using a FBO. I'm not sure what I'm doing wrong, but when rendering the resulting texture is all white. Below is some of my code. Please tell me if you see what I'm doing wrong. Am I missing something? 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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| renderToTexture.activate(); GL11.glPushAttrib(GL11.GL_VIEWPORT_BIT); GL11.glViewport(0, 0, width, height); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
renderNoise();
p1.render(); p2.render(); ball.render();
renderToTexture.deactivate(); GL11.glPopAttrib();
SlickCallable.enterSafeBlock(); int rtt = renderToTexture.getTexture();
glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, rtt);
glBegin(GL_QUADS); glNormal3d(0, 0, 1); glTexCoord2f(0, 0); glVertex2f(0, 0); glTexCoord2f(1, 0); glVertex2f(width, 0); glTexCoord2f(1, 1); glVertex2f(width, height); glTexCoord2f(0, 1); glVertex2f(0, height); glEnd();
glDisable(GL_TEXTURE_2D); SlickCallable.leaveSafeBlock();
public class FBORenderer { private int fbo; private int rbo; private int texture; private int height; private int width; private ByteBuffer byteBuffer;
public FBORenderer(int w, int h) { fbo = ARBFramebufferObject.glGenFramebuffers(); texture = GL11.glGenTextures(); width = w; height = h;
activate();
byteBuffer = BufferUtils.createByteBuffer(4 * 4 * width * height); GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_FLOAT, byteBuffer);
ARBFramebufferObject.glFramebufferTexture2D(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, ARBFramebufferObject.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
deactivate(); }
public void activate(){ ARBFramebufferObject.glBindFramebuffer(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, fbo); }
public void deactivate() { ARBFramebufferObject.glBindFramebuffer(ARBFramebufferObject.GL_DRAW_FRAMEBUFFER, 0); ARBFramebufferObject.glBindRenderbuffer(ARBFramebufferObject.GL_RENDERBUFFER, 0); }
public int getTexture() { return texture; } }
|
|
|
|
|
|
29
|
Java Game APIs & Engines / OpenGL Development / Procedural Textures
|
on: 2011-04-14 23:06:08
|
I want to generate textures using for instance perlin noise. My problem is that I don't know how to create a texture from the color (RGB) data. It would be nice if someone could provide a simple code sample or article/tutorial/resource for how this is done (preferrably with LWJGL) 
|
|
|
|
|
30
|
Java Game APIs & Engines / J2ME / Re: Deploying, and installing on a cellphone
|
on: 2008-05-07 12:06:24
|
Actually, that was just because I'd chosen MIDP 2.1 for some strange reason  . (Created a new project hoping there was a problem there..) Still, I now get an error when running it. I got this before also. That's why I created the new project. The actual problem I got is that I receive " Application error" when running it.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|