Show Posts
|
|
Pages: [1]
|
|
3
|
Game Development / Game Mechanics / Collision Detection
|
on: 2013-03-02 15:56:36
|
|
In my game, entities are rectangles, but are able to rotate, I need a way to tell collision between them taking into account the rotation. I have a double x and y and a double rotation
|
|
|
|
|
6
|
Java Game APIs & Engines / Engines, Libraries and Tools / Slick2D Most efficient way to draw a pixel array
|
on: 2013-03-02 00:48:06
|
I have a int[] cols, and want to draw that in a grid across the screen, I currently have each color fill a 4x4 area, but I want to have it 1 pixel instead of 4. Doing that seems to cause tremendous lag. I am looking for a better way to do this. 1 2 3 4 5 6 7 8 9 10 11 12
| public void renderTiles(Graphics g, int xScroll, int yScroll, int width, int height){ for(int x = -1; x < width; x++){ for(int y = -1; y < height; y++){ int xt = (x+xScroll/tileSize)%size; int yt = (y+yScroll/tileSize)%size; if(xt < 0)xt += size; if(yt < 0)yt += size; g.setColor(new Color(tiles[xt+yt*size])); g.fillRect(x*tileSize-xScroll%tileSize, y*tileSize-yScroll%tileSize, tileSize, tileSize); } } } |
|
|
|
|
|
8
|
Game Development / Game Mechanics / Rotating A Point
|
on: 2013-03-01 23:22:41
|
|
I am rotating a sprite in game around the center, and need to find out where a certain point is, from the original, so for example in the original a point at (1, 1) on the 64 x 128 image. I need to find that point after the rotation. I am using slick2d as my graphics library
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Getting Highscores
|
on: 2013-01-28 17:55:52
|
|
Hi, I am making a game, and need a simple way to get the highest score, and that player's name. And a way to send data to say there's a new high score. I tried using a simple UDP system but i can't get it to work. I don;t mind running a server, but would prefer not to.
|
|
|
|
|
10
|
Game Development / Game Mechanics / Rendering A Rotatable Globe
|
on: 2012-12-07 17:54:11
|
I need some help for a project im working on, i want to make a 3D rotating globe, at the moment i am using a pixel array for my rendering, i would like to keep it like that, but i am not sure how to make the 3D globe with a pixel array. My Bitmap class 1 2 3 4 5 6 7 8 9 10 11
| public class Bitmap {
public final int width; public final int height; public int[] pixels;
public Bitmap(int width, int height) { this.width = width; this.height = height; pixels = new int[width * height]; } |
I need some help to make a rendering method for the globe.
|
|
|
|
|
11
|
Game Development / Game Mechanics / Rotating Towards Target
|
on: 2012-11-20 16:35:48
|
I am having some problems with my method for turning my entity to face another Entity. The angle calculation works perfectly, however the entity will rock back and forth flying away from the target if it is directly below it. I think it is my turning to desired rotation method... 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| MoveOrder mo = (MoveOrder) baseEntity.orders.get(0); if(baseEntity.x < mo.x+16 && baseEntity.x > mo.x-16 && baseEntity.y < mo.y+16 && baseEntity.y > mo.y-16)baseEntity.orders.remove(0); double xd = mo.x - baseEntity.x; double yd = mo.y - baseEntity.y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+90; while(rotation > 360)rotation -= 360; while(rotation < 0)rotation += 360; if(baseEntity.rot > rotation+turnSpeed){ baseEntity.rot -= turnSpeed; }else if(baseEntity.rot < rotation - turnSpeed){ baseEntity.rot += turnSpeed; }else{ baseEntity.rot = rotation; } |
Could anyone help me sort out how the ships turn to the desired rotation?
|
|
|
|
|
12
|
Games Center / Archived Projects / Re: [WIP] Space Storm
|
on: 2012-11-19 20:21:18
|
No problem, first deployment attempt is always troublesome  I also downloaded the .exe file, but it also seems to fail silently. Can't really tell what the problem is without logging or exceptions, unfortunately. Has somebody else got it to work? Oh god, i feel like a failure, i thought it worked. All my friends I've sent it too it seems to work fine, is your computer able to handle 1280x720 resolutions in LWJGL, that's the only difference i could think of, or maybe the antivirus is blocking it, what antivirus are you using?
|
|
|
|
|
13
|
Games Center / Archived Projects / Re: [WIP] Space Storm
|
on: 2012-11-19 20:07:34
|
Ok I just looked in C:/Users/<my username> but there's no exe file there. I tried running it using admin rights, but that made no difference either.
It shouldn't need admin rights, i'll add the link to the game.exe itself in the main post, sorry for the hassle...
|
|
|
|
|
14
|
Games Center / Archived Projects / Re: [WIP] Space Storm
|
on: 2012-11-19 19:57:54
|
Hey, I tried it but could not get it to work. I get the updater screen with the blog messages, which appears to perform an update. But when I click "Play" the game just drops back to the prompt with no popups or console output. Looks cool though, I'm curious  I tested this on a Windows 7 machine with Java 7 installed. I'll look into it, it should then run a different java file i compiled as an exe, if the launcher fails go to C:/Users/USERNAME/game.exe and try running that, it should have downloaded the game there
|
|
|
|
|
15
|
Games Center / Archived Projects / [WIP] Space Storm
|
on: 2012-11-19 19:25:44
|
 Space Storm is an in development Space Strategy Game by me, I'm 14 and a wannabe game developer, constructive criticism please. There is a changelog hosted off of tumblr.com you can find here http://spacestormblog.tumblr.com/ I have made a launcher which will automatically update and run the game. You can get it from here, https://dl.dropbox.com/u/63217995/Space%20Storm%20Launcher.jarIf the launcher says updating but then doesn't actually run the game after the updating message has gone, go to C:/Users/USERNAME/game.exe and run that If there is no file there, use this link for the direct .exe file https://dl.dropbox.com/u/63217995/Space%20Sim%20Game.exeWINDOWS ONLY FOR NOW, MAC AND LINUX BUILDS COMING SOONTo play, first add at least one enemy and one ally ship, select the one you want to place with left click, place it with right click. Press Space to start, select one of your ships with left click, then right click tells it where to move, the game is won when either team has no ships left, the star wars-esque intro is for the story/campaign I'm planning on adding later! Please post any bugs/errors that you find 
|
|
|
|
|
16
|
Game Development / Newbie & Debugging Questions / Rotating Towards Target
|
on: 2012-11-19 19:03:47
|
I am having some problems with my method for turning my entity to face another Entity. The angle calculation works perfectly, however the entity will rock back and forth flying away from the target if it is directly below it. I think it is my turning to desired rotation method... 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| MoveOrder mo = (MoveOrder) baseEntity.orders.get(0); if(baseEntity.x < mo.x+16 && baseEntity.x > mo.x-16 && baseEntity.y < mo.y+16 && baseEntity.y > mo.y-16)baseEntity.orders.remove(0); double xd = mo.x - baseEntity.x; double yd = mo.y - baseEntity.y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+90; while(rotation > 360)rotation -= 360; while(rotation < 0)rotation += 360; if(baseEntity.rot > rotation+turnSpeed){ baseEntity.rot -= turnSpeed; }else if(baseEntity.rot < rotation - turnSpeed){ baseEntity.rot += turnSpeed; }else{ baseEntity.rot = rotation; } |
Could anyone help me sort out how the ships turn to the desired rotation?
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: Rendering font with LWJGL
|
on: 2012-11-02 17:05:31
|
Texcoords are in the range 0..1  Thanks, completely forgot that, fixed it now 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| public static void draw(String string, int x, int y, float r, float g, float b, float a) { for (int i = 0; i < string.length(); i++) { int ch = chars.indexOf(string.charAt(i)); if (ch < 0) continue;
int xx = (ch % 10) * 12; int yy = (ch / 10) * 16; int xd = x + i * 12; GL11.glPushMatrix(); GL11.glColor4f(r, g, b, a); TextureHandler.font.bind(); GL11.glBegin(GL11.GL_QUADS); float left = (float) (1.0*(xx/128.0)); float right = (float) (1.0*((xx+10)/128.0)); float top = (float) (1.0*(yy/128.0)); float bottom = (float) (1.0*((yy+16)/128.0)); GL11.glTexCoord2f(left, top); GL11.glVertex2f(xd, y); GL11.glTexCoord2f(right, top); GL11.glVertex2f(xd+10, y); GL11.glTexCoord2f(right, bottom); GL11.glVertex2f(xd+10, y+16); GL11.glTexCoord2f(left, bottom); GL11.glVertex2f(xd, y+16); GL11.glEnd(); GL11.glPopMatrix(); } } |
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / [SOLVED]Rendering font with LWJGL
|
on: 2012-11-02 16:34:12
|
I am having some trouble rendering fonts with LWJGL, i have a 128x128 png with all the letters drawn out, my current code is 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
| package com.bomberBox.game.screen;
import org.lwjgl.opengl.GL11;
import com.bomberBox.game.TextureHandler;
public class Font { private static final String chars = "" + "ABCDEFGHIJ" + "KLMNOPQRST" + "UVWXYZabcd" + "efghijklmn" + "opqrstuvwx" + "yz/#: " + "0123456789";
public static void draw(String string, int x, int y, float r, float g, float b, float a) { for (int i = 0; i < string.length(); i++) { int ch = chars.indexOf(string.charAt(i)); if (ch < 0) continue;
int xx = (ch % 10) * 12; int yy = (ch / 10) * 16; int xd = x + i * 12; GL11.glPushMatrix(); GL11.glColor4f(r, g, b, a); TextureHandler.font.bind(); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(xx, yy); GL11.glVertex2f(xd, y); GL11.glTexCoord2f(xx + 10, yy); GL11.glVertex2f(xd+20, y); GL11.glTexCoord2f(xx + 10, yy + 16); GL11.glVertex2f(xd+20, y+32); GL11.glTexCoord2f(xx, yy + 16); GL11.glVertex2f(xd, y+32); GL11.glEnd(); GL11.glPopMatrix(); } } } |
It renders some white bars but not the font or words... I am struggling to see where i've gone wrong...
|
|
|
|
|
19
|
Game Development / Game Mechanics / Re: Calculating angle to mouse
|
on: 2012-10-30 21:37:33
|
Thanks! Got it to work, 1 2 3 4 5 6 7 8 9 10 11 12 13
| double movementAngle = Math.toRadians(rot); x += Math.sin(movementAngle) * 0.5; y -= Math.cos(movementAngle) * 0.5; if(orders.size() > 0){ if(orders.get(0) instanceof MoveOrder){ MoveOrder mo = (MoveOrder)orders.get(0); double xd = mo.x - x; double yd = mo.y - y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+90; rot = rotation; orders.remove(0); } } |
1 2
| float angle = (float) (rot % 360.0f); GL11.glRotated(angle+180.0f, 0, 0, 1); |
|
|
|
|
|
20
|
Game Development / Game Mechanics / Re: Calculating angle to mouse
|
on: 2012-10-30 21:07:51
|
Okay, i've done some testing, and it seems to work fine x Axis, but messes up somewhere on the y Axis, as in, if i tell it to go from (0,0) to (10,0) it works fine, if i want to move just in the x Axis it has to be 1 2 3 4
| MoveOrder mo = (MoveOrder)orders.get(0); double xd = mo.x - x; double yd = mo.y - y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+90; |
However, if i want to move in the y Axis it has to be 1 2 3 4
| MoveOrder mo = (MoveOrder)orders.get(0); double xd = mo.x - x; double yd = mo.y - y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+270; |
Which even further confuses me... I've got it to move in the right direction by doing it like this 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| double movementAngleX = Math.toRadians(rot); double movementAngleY = Math.toRadians(rot+180); x += Math.sin(movementAngleX) * 0.5; y += Math.cos(movementAngleY) * 0.5; if(orders.size() > 0){ if(orders.get(0) instanceof MoveOrder){ MoveOrder mo = (MoveOrder)orders.get(0); double xd = mo.x - x; double yd = mo.y - y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+90; rot = rotation; System.out.println(rot); orders.remove(0); } } |
But then the rotation on the image is messed up, the rendering code is (im using LWJGL) 1 2 3 4 5 6 7 8 9
| GL11.glTranslated(x+32, y+32, 0); GL11.glRotated(rot, 0, 0, -1); GL11.glBegin(GL11.GL_QUADS); GL11.glTexCoord2f(0.0f, 0.0f); GL11.glVertex2f(-32, -32); GL11.glTexCoord2f(1.0f, 0.0f); GL11.glVertex2f(32, -32); GL11.glTexCoord2f(1.0f, 1.0f); GL11.glVertex2f(32, 32); GL11.glTexCoord2f(0.0f, 1.0f); GL11.glVertex2f(-32, 32); GL11.glEnd(); |
Anyone got any ideas?
|
|
|
|
|
22
|
Game Development / Game Mechanics / [SOLVED] Calculating angle to mouse
|
on: 2012-10-30 15:47:01
|
I need help calculating the angle to the mouse from entities, 1 2 3 4 5 6 7 8 9
| if(orders.get(0) instanceof MoveOrder){ MoveOrder mo = (MoveOrder)orders.get(0); double xd = mo.x - x; double yd = mo.y - y; double rotation = Math.toDegrees(Math.atan2(yd,xd))+270; rot = rotation; System.out.println(rot); orders.remove(0); } |
This is my current code, but it doesn't seem to work, and the movement code is: 1 2 3 4 5
| while(rot > 360)rot-= 360; while(rot < 0)rot+= 360; double movementAngle = Math.toRadians(rot); x += Math.sin(movementAngle) * 0.5; y += Math.cos(movementAngle) * 0.5; |
can anyone help?
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|