Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
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
1  Game Development / Newbie & Debugging Questions / Re: BoundingBox( Rectangle ) class, help? on: 2013-02-27 18:53:11
That is very neat and tidy, and small, but how would I go about checking of something specifically intersected the top, bottom, left or right of the bounds? that's why I have so many functions.
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/d409e4c4246

Thanks

    ~ Scyth
3  Game Development / Newbie & Debugging Questions / Re: Homemade Java Libraries - Eclipse on: 2013-02-17 10:48:33
Thanks a lot. This is going to help me and save me some time. Grin
4  Game Development / Newbie & Debugging Questions / Homemade Java Libraries - Eclipse on: 2013-02-16 20:02:39
I would like to create a library of classes that I use frequently in different projects.

How would I go about :

1) Creating the library.

2) Use the library in other projects.

Any help is much appreciated.

(Please don't link me to a SDK documentation or an API)
5  Game Development / Newbie & Debugging Questions / Re: Changing scenes in a game (ex; from map to battle) on: 2013-02-13 17:35:17
You could have different enums for different events.

for example, enums for the battle scenes
enums for the menus
enums for the maps
etc etc

then you just need to check which enum is active.

not sure if its a great solution, but it may be achievable
6  Game Development / Newbie & Debugging Questions / Re: Errors, Errors and more bloody errors! on: 2013-01-25 22:27:27
Got it sorted, it was the Dialogs causing the problems /:
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.
8  Game Development / Newbie & Debugging Questions / Re: RuntimeException error - How/Why am I getting it? on: 2013-01-24 18:28:37
Well done Tongue
9  Game Development / Newbie & Debugging Questions / Re: RuntimeException error - How/Why am I getting it? on: 2013-01-23 22:27:11
Thanks, i didnt know it would be that easy Smiley
10  Game Development / Newbie & Debugging Questions / Re: RuntimeException error - How/Why am I getting it? on: 2013-01-23 21:51:11
I'm using the BlackBerry JDE so i dont have deltaTime so i need to count in this way, I tried using a Timer and TimerTask but that was given me errors as well.

It tells me there is no stack trace.
It just repeats saying, NO STACK TRACE

how i can i get the same result using the two threads?
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();
        }
}
// 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 Smiley just really good
13  Game Development / Newbie & Debugging Questions / Re: ArrayOutOfBoundsException help. on: 2013-01-18 09:48:15
I got it sorted, don't know how but it works, and its been tested a lot so it should be 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
1  
int pX;


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)
   {
      // Set the previous positions of the x, y coordinates
     prevX = pX;
      prevY = pY;
     
      // Set The Player Speed
     pSpeedX = pSX;
      pSpeedY = pSY;
     
      // Move player then check if they are on a tile
     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 Smiley

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 Smiley
16  Game Development / Newbie & Debugging Questions / Re: Tiled Level Collision Help on: 2013-01-16 20:30:16
Thanks I'll read through that now Smiley

Thanks for the help everyone, I'll update you all if I get this working.
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 Smiley 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 Sad

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
1  
int[][] playerPos;


and then use it to define the player position?
but how can i  use it for rendering the image according to the
1  
playerPos[y][x]
19  Game Development / Newbie & Debugging Questions / Re: Tiled Level Collision Help on: 2013-01-15 20:29:46
First, what do you mean by minX minY and maxX and maxY of player? Would that be 0,0 and say 320,240.

any tips on how to do the Rectangles?

and what math? I'm completely confuzzled
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 Smiley
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
 // Render the Level
    public void renderTiles(Graphics g) {
         // Iterate through all tiles:
        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) {
           // don't forget the breaks! :)
          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?
21  Game Development / Newbie & Debugging Questions / Re: Game Loop not working? help? on: 2013-01-10 18:41:30
thanks i took out the while loop and it worked perfectly Smiley
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 Smiley
23  Game Development / Newbie & Debugging Questions / Game Loop not working? help? on: 2013-01-09 21:59:03
Ok, so I have a very simple game loop, which isn't working. At the moment its not even required to do much but it  just isn't working. I don't see why, it simply wont repaint the screen. With the blackberry libraries invalidate() is supposed to be the same as repaint().

here's my code:
http://pastebin.java-gaming.org/40b42118837
24  Game Development / Newbie & Debugging Questions / Re: Maze Game Advice on: 2013-01-09 19:12:43
Thanks that helped a lot! The code example is excellent! Thanks a lot Smiley
25  Game Development / Articles & tutorials / Re: Game loops! on: 2013-01-09 18:22:22
What is the interpolation used for?
26  Game Development / Newbie & Debugging Questions / Maze Game Advice on: 2013-01-09 18:17:14
Hey again, I have another noobie question Sad

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!
27  Game Development / Newbie & Debugging Questions / Re: Setting Up libGDX? on: 2013-01-01 01:55:10
Thank's, I got it setup, and am learning it.

Sorry, I thought code.google.com was just code but when i went on it, I followed a few tutorials on it. It's quite good.
28  Game Development / Newbie & Debugging Questions / Re: Setting Up libGDX? on: 2012-12-30 18:38:48
Thanks matheus Smiley

@Jimmit, all that kept coming up was code.google.com or whatever
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
Pages: [1] 2
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars and Titan!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (43 views)
2013-05-17 21:29:12

alaslipknot (52 views)
2013-05-16 21:24:48

gouessej (81 views)
2013-05-16 00:53:38

gouessej (80 views)
2013-05-16 00:17:58

theagentd (89 views)
2013-05-15 15:01:13

theagentd (82 views)
2013-05-15 15:00:54

StreetDoggy (126 views)
2013-05-14 15:56:26

kutucuk (148 views)
2013-05-12 17:10:36

kutucuk (148 views)
2013-05-12 15:36:09

UnluckyDevil (158 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.229 seconds with 20 queries.