Show Posts
|
|
Pages: [1] 2
|
|
2
|
Game Development / Newbie & Debugging Questions / BoundingBox( Rectangle ) class, help?
|
on: 2013-02-27 18:44:52
|
Ok, so for my game, I need to check collisions, and I thought the best way would be to create bounding boxes ( aka Rectangles ) around all my objects. I know that there is a Rectangle class somewhere in the Java API. but I need one with a little more precision. I cannot use any external libraries in my project, so I can't use any of lwjgl features or of libgdx features. I have created a class, I have tried testing it, but I'm not too sure if I'm testing it wrong, or if there is a problem in my class. Can someone please read over it and tell me if its wrong, or where i should improve something? The code will be in the pastebin : http://pastebin.java-gaming.org/d409e4c4246Thanks ~ Scyth
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Errors, Errors and more bloody errors!
|
on: 2013-01-25 21:45:04
|
i'm constantly getting errors! It's the very last obstacle i need to get past and my game is finally completed, This is how i check if the user has stepped on the last tile of the last level: 1 2 3 4 5 6 7
| else if( tiles.level == 25) { if( tiles.tileID[player.pY][player.pX] == 2 ) { game_won = 1; } } |
but im getting the errors with this bit of 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 49
| private void CheckGameState() { if(GameMode == 1) { if(secs == 0) { try { Thread.currentThread(); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } System.exit(0); } if(game_won == 1) { game_active = 0; Dialog.alert("Congratulations! You have won!"); try { Thread.currentThread(); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } System.exit(0); } } if(game_won == 1) { if(GameMode != 1) { game_active = 0; Dialog.alert("Try the classic now!"); try { Thread.currentThread(); Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } System.exit(0); } } } |
Do any of you have a better way for me to do this? Like im simply trying to close the game! but i also want to have some text painted onto the screen to notify the user? Thanks for any help.
|
|
|
|
|
11
|
Game Development / Newbie & Debugging Questions / RuntimeException error - How/Why am I getting it?
|
on: 2013-01-23 21:30:48
|
Can anyone explain to me what a RuntimeException is? I'm getting it from these bits of code when I try to do something when the secs get to 0 : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
| t = new Thread(){ public void run() { while(game_active) { secs = secs - 1; try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }; t.start(); |
1 2 3 4 5 6 7 8 9 10 11 12
| public void update(){ if( secs == 0) { GameOver(); } } private void GameOver() { Dialog.alert("Game Over!"); } |
Or if i change it i get an illegalstateexcpetion, however if i use System.exit(0) it simply closes it, no errors. Any ideas?
|
|
|
|
|
12
|
Game Development / Newbie & Debugging Questions / Re: ArrayOutOfBoundsException help.
|
on: 2013-01-20 00:19:13
|
the players pX was the equal to the [20] part of tileID[15][20], so i added an extra column to it, so its tileID[15][21]. I understand it now, the pX wasn't equal to tileID[y].length - 1 it was equal to tileID[y].length. i've got a little engine set up now, so it's speeding up my game, all i need to do is create the levels using matrices which means its speeding up the production of it. It's for blackberry smartphones so it doesn't have to be amazing  just really good
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / [Solved]ArrayOutOfBoundsException help.
|
on: 2013-01-16 22:03:02
|
Before you say anything, I have googled this problem. I'm getting an ArrayIndexOutOfBoundException every time my gets to 14/15. I do not understand why, because technically the 1
| int[][] tileID = new int[15][20]; |
and the pX should refer to the 20. I do not know how to approach this problem, this is my code for moving my player, it includes a check to see if the player is on a tile it shouldn't be on, which i believe is where the problem is coming from. 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
| public void movePlayer(int pSX, int pSY) { prevX = pX; prevY = pY; pSpeedX = pSX; pSpeedY = pSY; if( pSY == 0) { pX += pSpeedX; if( tiles.tileID[pY][pX] == 1) { pX = prevX; pY = prevY; } } if( pSX == 0) { pY += pSpeedY; if( tiles.tileID[pY][pX] == 1) { pX = prevX; pY= prevY; } } } |
I know I'm posting a lot, but I'm really not sure how to do these things :/
|
|
|
|
|
15
|
Game Development / Newbie & Debugging Questions / Re: Tiled Level Collision Help
|
on: 2013-01-16 21:34:17
|
I got it working! I think some people said this already, and with that and by reading through Ultroman's code, I got a way of doing it formed in my head. Thanks  I simply let the player walk onto a "wall" then check to see if the player is on a "wall" by using 1 2 3 4 5
| if( level1[pY][pX] == 1 ) { pX = prevX; pY = prevY; } |
I knew something simple would have been what it takes to do it, thanks everyone for helping me out! This took much longer than I had anticipated 
|
|
|
|
|
17
|
Game Development / Newbie & Debugging Questions / Re: Tiled Level Collision Help
|
on: 2013-01-16 17:47:20
|
I understand the points so i'll try that  thanks for the suggestions. If it helps, I'm not looking for a complex collision system just an extremely simple one, my map is all squares and the character will end up being a circle, so it doesn't need to be too complicated. Everything i try seems to fail but.
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: Tiled Level Collision Help
|
on: 2013-01-15 22:12:52
|
It moves one cell which is 16*16, but I haven't really done a cell if you know what I mean, just the level1[][], ahhh! I'm so confused! I can't get this to work! It's probably something extremely easy, I'm just missing it! My character now jumps several spaces, regardless of where it is. I'm using a simple Graphics package because that is what I'm restricted too. I need to try and have it that the character can move if its on an '0' tile but it can't move onto a 1 tile. i've tried trying to predict what the tiles around the character are, but I can't get that to work either  sorrry, I've been trying to fix this for the last couple of days, and haven't had a clue. is there anyway I could do and then use it to define the player position? but how can i use it for rendering the image according to the
|
|
|
|
|
20
|
Game Development / Newbie & Debugging Questions / Tiled Level Collision Help
|
on: 2013-01-15 19:59:39
|
I have a tiled level, which is expressed as: 1 2
| int[][] level1 = {{1,0,0,0,0,0,1,1}, {1,0,0,0,0,0,0,1}; |
etc I then render the tiles with code from mattheus 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| public void renderTiles(Graphics g) { for (int y = 0; y < level1.length; y++) { for (int x = 0; x < level1[y].length; x++) { renderTile(x, y, level1[y][x], g); } } } public void renderTile(int x, int y, int tileID, Graphics g) { switch (tileID) { case 0: g.setColor(Color.BLACK); g.fillRect(x * 16, y * 16, 16, 16); break; case 1: g.setColor(Color.GREEN); g.fillRect(x * 16, y * 16, 16, 16); break; } } |
My player info: 1
| int playerX = 16, playerY = 16; |
how can I check collision between the player and the tiles which are 1? I've tried, some different methods: - Surround wall tiles in a Rectangle each the player in a Rectangle and check for collision between them. But I needed to use an array of Rectangles, and I hit the problem: i had to define what [] is for the .intersects() method.
- I tried checking if playerX and playerY were 'Beside' a wall so that it wouldn't allow them to move, again, I think I need to define what tile I'm comparing them to.
Anyone have any suggestions I can try?
|
|
|
|
|
22
|
Games Center / 4K Game Competition - 2013 / Re: [WIP] On!
|
on: 2013-01-10 18:07:02
|
Woo! Very addictive and plays very smoothly, when I try to move up, I seem to move up the screen extremely fast, and it's a little hard to control when trying to get the power-ups, in saying that, i got a score of 3720 
|
|
|
|
|
26
|
Game Development / Newbie & Debugging Questions / Maze Game Advice
|
on: 2013-01-09 18:17:14
|
Hey again, I have another noobie question It's not so much a coding one but I may need help with that in the end. Also, something that might be necessary is that I'm using the BlackBerry JDE 5.0.0 so I'm restricted to using the Graphics package that comes with it. I'm sure a lot of you probably do not have these libraries however like I said my question isn't really a coding one. 1. Is it practical to create a bunch of tiles, and define the walkable pathways using a certain number, so that i wouldn't have to worry about collision detection for a simple maze game. 2. How would I store the co-ordinates of the walkable tiles, so that I can iterate through like an array to see in what directions the player can walk. Thanks for any advice!
|
|
|
|
|
29
|
Game Development / Newbie & Debugging Questions / Re: Setting Up libGDX?
|
on: 2012-12-30 18:26:25
|
|
I tried google and there was nothing that helped.
Matheus I have four projects:
game game-android game-desktop game-html
in eclipse there's errors beside the andriod and html one, probably because I do not have the libraries for those.
what one do I code in?
|
|
|
|
|
30
|
Game Development / Newbie & Debugging Questions / Setting Up libGDX?
|
on: 2012-12-30 18:18:53
|
|
Ok, so following the posts on the discussion about why people are still using java2D I have decided I want to try out libGDX. I was linked to where to download a libGDX ui setup application and then a tutorial for libGDX.
The ui app has created four projects for me. I only want to program for desktop, what do I do now? I'm really confused. I don't know what projects I need to work in or what other libraries I may/ may not need for libGDX.
Can someone help me please?
~Scyth
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|