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 (406)
games submitted by our members
Games in WIP (293)
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 3 ... 15
1  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-21 03:50:08
oh no of course im not doing that.
2  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-21 03:16:16
I found out you can make properties for tiles and I am going to use those to help with collision. The last thing I am having great trouble with is why ".getCell(x, y)" returns a unique number even when trying it on the same tiles... This becomes a problem when trying to match it up with tile properties.
3  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 21:30:07
I just got the actual tiled map working (before i just saved the tile map as an image and moved that aorund) but now when I move the camera everything is very grainy when moving. Is there a reason for this? Just to test things out I tried this:

1  
2  
3  
4  
camera.update();
      renderer.setView(camera);
      renderer.render();
      camera.translate(.01f,.01f);
4  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 20:50:23
Here is what I was thinking to try out: Put all of the cell ID's that are passable into an array list. then do something like this:
1  
2  
3  
4  
5  
6  
7  
for(loop through above array list){
     if(tile to the left of character is passable)
          isAbleToMoveLeft = true;
     else
          isAbleToMoveLeft = false;
}
//repeat for each direction in for loop

i think something like this should work well
5  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 01:55:45
I am still not understanding the usage of the for loop... The "i" variable is not even being used.
6  Game Development / Newbie & Debugging Questions / Re: Tiled Map Collision Detection Help on: 2013-05-20 01:29:37
I do not really understand what you mean by your usage of the foor loop Huh
7  Game Development / Newbie & Debugging Questions / Tiled Map Collision Detection Help on: 2013-05-19 18:51:19
Hello forum, recently I began to use a Tiled map for my game. I was thinking about using a more traditional AABB collision method but then found out I can get tile ID's and so I would imagine I could figure out collision that way. I was trolling through past posts about Tiled and collision detection and came upon this:

Moving on. This is you would get the ID of a Tile with libgdx:
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  
// First, we need to get the layer in which you create the tiles.
// In this case I assume you call the layer 'collision' layer in Tiled.
private int computeCollisionLayerIndex(TiledMap map) {
    for (int i = 0; i < map.getLayers().getCount(); i++) {
        // This is used to get the layer with the name "collision" from all layers
       // (The layers name in Tiled)
       if (map.getLayers().get(i).getName().equalsIgnoreCase("collision")) {
            return i;
        }
    }
    return -1;
}

// Now we surround getting the layer from the index
// with a little error handling:
public void whatevername(TiledMap map) {
    int collisionLayerIndex = computeCollisionLayerIndex(map);
    if (collisionLayerIndex != -1) {
        MapLayer layer = map.getLayers().get(collisionLayerIndex
        if (layer instanceof TiledMapTileLayer) {
            getCollisionTilesFrom((TiledMapTileLayer) layer);
        } else throw some kind of error
    } else throw some kind of error
}

// And finally we print the ID of each tile in the layer
// I don't know what you would do with the tiles in the end,
// and since I don't know what tile ID's your tiles have,
// I simply print them.
public void getCollisionTilesFrom(TiledMapTileLayer layer) {
    for (int x = 0; x < layer.getWidth(); x++) {
        for (int y = 0; y < layer.getHeight(); y++) {
            TiledMapTileLayer.Cell cell = layer.getCell(x, y);
            if (cell == null) continue; // There is no cell
           if (cell.getTile() == null) continue; // No tile inside cell
           
            System.out.println(cell.getTile().getID()); // Get the ID.
       }
    }
}


With this code in particular
1  
 TiledMapTileLayer.Cell cell = layer.getCell(x, y);

You can get the ID from a specific cell. Now for the questions:
1. What would the cell ID turn up as ? A number or some string - how would this be relevant to what is exactly placed?
2. After I figure out when my player is next to a certain tile, how could i prevent the player from moving onto that tile? Would there be a simple way to determine if the tile is to the left of the character, and making a variable like isAbleToMoveLeft set to false if its near a tile where it can not move left.Maybe something like this?
1  
2  
3  
if(collisionTile.x < player.x){
     isAbleToMoveLeft = false;
}


3. Final question is this: I have items drawn in 4 layers in Tiled. Is this something that will effect the way collision detection works? In the method written by matheus23 the getCollisionTilesFrom method requires a layer. So I am curious if 4 layers will create problems.

Thanks for the help! Cool
8  Games Center / WIP games, tools & toy projects / Re: [WIP] 2d RPG with no name... on: 2013-05-18 23:00:51
I think this game is headed in more of an RPG direction then I originally intended. The whole free roaming concept isn't really doing it for me. I was in a google hangout with my friend and we came up with some ideas which you can view here: http://goo.gl/DCq38 All input is welcome.
9  Game Development / Newbie & Debugging Questions / Re: Parameters of method not working but work when directly coded on: 2013-05-18 01:21:44
Everything is looking good now! Thank you. I too thought this looked a little excessive but I had no other ideas on how to make it simpler Sad
10  Game Development / Newbie & Debugging Questions / Re: Parameters of method not working but work when directly coded on: 2013-05-18 01:03:10
I think I understand what I am doing wrong here but what is a good way to redesign my code?
11  Game Development / Newbie & Debugging Questions / Re: Parameters of method not working but work when directly coded on: 2013-05-18 00:54:41
I was wondering if it was that, and it turns out it is. Would a getter /  setter solve this problem? Since calling a setter would change the original value rather than the copy, if my logic is right here...
12  Game Development / Newbie & Debugging Questions / Parameters of method not working but work when directly coded on: 2013-05-18 00:43:59
Hey guys I have a rather odd (or it may just be my stupidity) question. I have a little animation method which is shown below:
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  
void setSprites(TextureRegion mainMob, TextureRegion upMob_STILL,
         TextureRegion upMob_LEFT, TextureRegion upMob_RIGHT,
         TextureRegion downMob_STILL, TextureRegion downMob_LEFT,
         TextureRegion downMob_RIGHT, TextureRegion rightMob_STILL,
         TextureRegion rightMob_LEFT, TextureRegion rightMob_RIGHT,
         TextureRegion leftMob_STILL, TextureRegion leftMob_LEFT,
         TextureRegion leftMob_RIGHT) {
      if (timer < 4)
         timer += .1f;
      else
         timer = 0;

      // walking right animation
     if (direction == 3) {
         if (timer < 1) {
            mainMob = rightMob_STILL;
         } else if (timer > 1 && timer < 2) {
            mainMob = rightMob_LEFT;
         } else if (timer > 2 && timer < 3) {
            mainMob = rightMob_STILL;
         } else if (timer > 3) {
            mainMob = rightMob_RIGHT;
         }
      }

      // walking left animation
     if (direction == 2) {
         if (timer < 1) {
            mainMob = leftMob_STILL;
         } else if (timer > 1 && timer < 2) {
            mainMob = leftMob_LEFT;
         } else if (timer > 2 && timer < 3) {
            mainMob = leftMob_STILL;
         } else if (timer > 3) {
            mainMob = leftMob_RIGHT;
         }
      }

      // walking up animation
     if (direction == 0) {
         if (timer < 1) {
            mainMob = upMob_STILL;
         } else if (timer > 1 && timer < 2) {
            mainMob = upMob_LEFT;
         } else if (timer > 2 && timer < 3) {
            mainMob = upMob_STILL;
         } else if (timer > 3) {
            mainMob = upMob_RIGHT;
         }
      }

      // walking down animation
     if (direction == 1) {
         if (timer < 1) {
            mainMob = downMob_STILL;
         } else if (timer > 1 && timer < 2) {
            mainMob = downMob_LEFT;
         } else if (timer > 2 && timer < 3) {
            mainMob = downMob_STILL;
         } else if (timer > 3) {
            mainMob = downMob_RIGHT;
         }
      }
   }

As you can see I have quite a lot of parameters, but that should all be working. I call the method appropriately, but the "mainMob" texture region is never changed. If I avoid using these parameters by doing this
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  
   void setSprites() {
      if (timer < 4)
         timer += .1f;
      else
         timer = 0;

      // walking Assets.right animation
     if (direction == 3) {
         if (timer < 1) {
            Assets.mainCreeper = Assets.rightCreeper_STILL;
         } else if (timer > 1 && timer < 2) {
            Assets.mainCreeper = Assets.rightCreeper_LEFT;
         } else if (timer > 2 && timer < 3) {
            Assets.mainCreeper = Assets.rightCreeper_STILL;
         } else if (timer > 3) {
            Assets.mainCreeper = Assets.rightCreeper_RIGHT;
         }
      }

      // walking left animation
     if (direction == 2) {
         if (timer < 1) {
            Assets.mainCreeper = Assets.leftCreeper_STILL;
         } else if (timer > 1 && timer < 2) {
            Assets.mainCreeper = Assets.leftCreeper_LEFT;
         } else if (timer > 2 && timer < 3) {
            Assets.mainCreeper = Assets.leftCreeper_STILL;
         } else if (timer > 3) {
            Assets.mainCreeper = Assets.leftCreeper_RIGHT;
         }
      }

      // walking Assets.up animation
     if (direction == 0) {
         if (timer < 1) {
            Assets.mainCreeper = Assets.upCreeper_STILL;
         } else if (timer > 1 && timer < 2) {
            Assets.mainCreeper = Assets.upCreeper_LEFT;
         } else if (timer > 2 && timer < 3) {
            Assets.mainCreeper = Assets.upCreeper_STILL;
         } else if (timer > 3) {
            Assets.mainCreeper = Assets.upCreeper_RIGHT;
         }
      }

      // walking Assets.down animation
     if (direction == 1) {
         if (timer < 1) {
            Assets.mainCreeper = Assets.downCreeper_STILL;
         } else if (timer > 1 && timer < 2) {
            Assets.mainCreeper = Assets.downCreeper_LEFT;
         } else if (timer > 2 && timer < 3) {
            Assets.mainCreeper = Assets.downCreeper_STILL;
         } else if (timer > 3) {
            Assets.mainCreeper = Assets.downCreeper_RIGHT;
         }
      }
   }


Everything works great this way. The "Assets.mainCreeper" is changed to whatever the current animation state should be. The only reason I can't do it like that is that I have many different types of mobs so I would want to use parameters rather than making a class or method specific for each mob type. Is there some specific reason that using parameters makes this not work at all? From my code (in the parameter example) everything is the same as the parameterless example which would make me think it would work. Is there something with using parameters that stops this from working properly? I know this may be a long question but I appreciate the help!

P.s. after the current image is set to the "mainMob" texture region or the "Assets.mainCreeper" i draw that texture region seems obvious but i thought i would include it.
13  Game Development / Newbie & Debugging Questions / Re: Movement is acting a bit odd on: 2013-05-16 02:31:53
From that it looks like everything should be going evenly. Would you mind sending me a link to the .jar to try it out?
14  Game Development / Newbie & Debugging Questions / Re: Movement is acting a bit odd on: 2013-05-15 02:18:25
Since your calling
1  
System.out.println(speed);


how does the speed compare when holding down each key?
15  Game Development / Newbie & Debugging Questions / Re: Sprite Animation to create effect using Atlas on: 2013-05-13 00:29:19
To draw something like this it is normally done using a sprite sheet. Each frame of the animation a separate part of the sheet (image). This website is a great tutorial for doing this in libgdx https://code.google.com/p/libgdx/wiki/SpriteAnimation
16  Game Development / Newbie & Debugging Questions / Re: Rectangle Intersection - LIBGDX -- Collision on: 2013-05-12 05:07:43
Do I get an appreciation?  Grin
17  Game Development / Newbie & Debugging Questions / Re: Rectangle Intersection - LIBGDX -- Collision on: 2013-05-12 04:31:44
When did those sometimes cases occur
18  Game Development / Newbie & Debugging Questions / Re: Rectangle Intersection - LIBGDX -- Collision on: 2013-05-12 04:27:57
I would have to assume intersects. I don't see how completely inside each other would ever be useful. Try it out it's not hard to use
19  Game Development / Newbie & Debugging Questions / Re: Rectangle Intersection - LIBGDX -- Collision on: 2013-05-12 04:10:40
To use the libgdx rectangle intersect method, first import
1  
import com.badlogic.gdx.math.Intersector;


and then to use the method type

1  
Intersector.overlaps(r1, r2);

where r1 is your first rectangle and r2 is your second rectangle. Its a boolean method so use it appropriately.

20  Games Center / WIP games, tools & toy projects / Re: [WIP] 2d RPG with no name... on: 2013-05-12 02:35:23
Added pigs that drop bacon Cheesy also re added that mining robot now with moving animations for up down left and right. More mobs and animals should now be simple to add. If you have suggestions for which to add feel free to tell me.

<a href="http://www.youtube.com/v/0dUAQm8Mujk?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/0dUAQm8Mujk?version=3&amp;hl=en_US&amp;start=</a>
21  Discussions / General Discussions / Re: I cant modify my posts! on: 2013-05-11 16:56:51
Thank you Riven Grin
22  Games Center / WIP games, tools & toy projects / Re: [WIP] 2d RPG with no name... on: 2013-05-11 01:45:09
Thats something I noticed I never thought about flipping some tiles. Currently I draw it with:

1  
2  
3  
4  
5  
6  
7  
8  
   void draw(SpriteBatch batch) {
      //draws grass image (64 , 64) everywhere
     for (int i = 0; i < Gdx.graphics.getWidth() + 128; i += 64) {
         for (int j = 0; j < Gdx.graphics.getHeight() + 128; j += 64) {
            batch.draw(Assets.grass, grassX + i, grassY + j);
         }
      }
   }


With this i'm not sure how I could do that... I guess I will have to think about it, unless you have any suggestions?
23  Discussions / General Discussions / Re: I cant modify my posts! on: 2013-05-11 01:42:59
I wanted to update the image and download but I can not... there seems to be some change. @Riven what happened?
24  Discussions / General Discussions / I cant modify my posts! on: 2013-05-11 01:40:23
I just updated my WIP game and wanted to update the download link on the original post, but theres no option to modify it!



When I go to more recent posts theres an option there. Why can I not modify the original post? Huh
25  Games Center / WIP games, tools & toy projects / Re: [WIP] 2d RPG with no name... on: 2013-05-11 01:35:56
Mob System has been implemented. I think its cool but would love to hear opinions.
Download: http://goo.gl/Hj4Q1

<a href="http://www.youtube.com/v/QdfMfajjbDg?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/QdfMfajjbDg?version=3&amp;hl=en_US&amp;start=</a>
26  Game Development / Newbie & Debugging Questions / Re: Any idea why my game slows down when I try to record a video of it using Fraps? on: 2013-05-08 22:25:53
If you use Windows, there is Microsoft Expression Encoder.

It's free, records HD, and doesn't interfere with performance.

Thanks a bunch! I thought for the longest time it was my crappy computer slowing the fps down when I was recording but it was just the software! Microsoft Expression Encoder works great, thanks again
27  Discussions / General Discussions / Re: Programming on iOS on: 2013-05-07 02:54:41
I used to have an android java compiler / ide for my phone (I probably still have it although I have never used it much) I am not sure for iOS however
28  Game Development / Newbie & Debugging Questions / Re: [SOLVED] strange if statement problem on: 2013-05-07 02:38:17
Why does that print yes while in the OP's case it does not?
29  Games Center / WIP games, tools & toy projects / Re: [WIP] 2d RPG with no name... on: 2013-05-06 01:27:29
Added a walking animation to the game - Someone commented on my youtube video asking about this and that reminded me it looked a little weird just gliding around. The downloads not updated since this isn't really major, heres a little video for it:

<a href="http://www.youtube.com/v/sELCcBA6coM?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/sELCcBA6coM?version=3&amp;hl=en_US&amp;start=</a>
30  Game Development / Articles & tutorials / Re: Particle Effects in libGDX on: 2013-05-05 17:01:01
this looks very helpful! Last time I tried using the particle effects I am pretty sure I got confused and quit, but you make it quite simple.
Pages: [1] 2 3 ... 15
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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 (77 views)
2013-05-17 20:29:12

alaslipknot (89 views)
2013-05-16 20:24:48

gouessej (119 views)
2013-05-15 23:53:38

gouessej (113 views)
2013-05-15 23:17:58

theagentd (126 views)
2013-05-15 14:01:13

theagentd (113 views)
2013-05-15 14:00:54

StreetDoggy (156 views)
2013-05-14 14:56:26

kutucuk (179 views)
2013-05-12 16:10:36

kutucuk (179 views)
2013-05-12 14:36:09

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

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

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

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

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

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

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

Topic Request
by kutucuk
2013-03-22 20: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.161 seconds with 20 queries.