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 (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 3 ... 5
1  Game Development / Newbie & Debugging Questions / Re: [LibGDX] TiledMapTile IDs or something else to determine... on: 2013-05-12 21:43:58
Hi Axeman,
I think I am not as experienced as you are with tile maps. Can you explain it in more detail or if you don't mind, can you share the code?
I felt like I needed to change something in the editor but I was not sure.

I was using Tiled as my tilemap editor. I right clicked my tile representing my wall and set tile properties for that specific tile. Notice I´m not setting the property for the layer or anything in the map: I´m using the specific tile. That way all tiles on the map have the same property. I had a property name "checkCollision", since different tiles reacted differently to collision. Walls were solid and Conveyor belt sped up the entity checking for collision.

Anyway, in my levelloader I wrote something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
int tileHeight = 32;
int tileWidth = 32;
String type = "";
Array<Wall> wallTiles  = new Array<Wall>();
     
for(int layers = 0; layers < map.layers.size(); layers++) {
   for(int y = 0; y < map.height; y++)
      for(int x = 0; x < map.width; x++) {
           
              type = (map.getTileProperty(map.layers.get(layers).tiles[y][x], "CheckCollision"));
              if(type != null && type.equals("solid")) {
                 Wall wall = new Wall(x * tileWidth, y * tileHeight, tileHeight, tileWidth);
                 wallTiles.add(wall);
               }}


Note that this code is based on the old TiledMap API in LibGDX, but I figured it might be easier to read in code...

So basically I read the tilemap and check each tile if it has the property name "CheckCollision". If it returns the property value "solid" I create a new wall with position and tilesize and store it in the list.
2  Game Development / Newbie & Debugging Questions / Re: [LibGDX] TiledMapTile IDs or something else to determine... on: 2013-05-12 17:21:49
I made a class called Wall and I set a tileproperty for my walltile to "solid" in my tilemap editor. Then when I read the .tmx file I made a new Wall object and stored it in a list. That way I had a list of bounding boxes to test collision against.
3  Game Development / Newbie & Debugging Questions / Re: A better way than AABB collision to solve precision problem on: 2013-05-10 11:32:45
I think you´re complicating it and thereby introducing more bugs that´s gonna be harder to debug. Try to keep it simple. If you need two rectangles and two AABB you´re doing it wrong and should go back to the drawing board. For example, you shouldn´t need to do two intersection test since you can get all the information you need from one test. In your case you check which axis has the smallest overlap and then the collision will occur on that axis.
4  Game Development / Newbie & Debugging Questions / Re: Where to begin?? on: 2013-05-10 01:57:18
after reading it i will just try the both and figure out which i prefer and is more suitable for me  Grin

That´s the spirit: More "programming games" and less "thinking about the best way to get started programming games". Smiley
5  Game Development / Newbie & Debugging Questions / Re: A better way than AABB collision to solve precision problem on: 2013-05-10 01:23:02
Let´s say we have object A and B. If object A is 1 pixel away from object B and the speed of A is 5 pixels per frame you will only get a "true" from the collision check when A is overlapping with 4 pixels. What you want to do is to correct the overlap by the minimum amount. I wrote a bit about this in your last thread about collision detection so I won´t repeat myself, but read it and hopefully you´ll get some ideas.
6  Game Development / Newbie & Debugging Questions / Re: Finding nearest objects on: 2013-05-05 18:29:18
Sounds like a Sweep and prune. You check all AABBs for overlaps on first the x axis and then the y axis. Basically you check all points one dimension at a time. Then, if two objects overlap on both axes, there´s an intersection. Then you can keep an almost sorted list since an objects position change very little frame... It´s the basic idea, but google "Sweep and prune" and you will find a lot of better explanations. Smiley

ps1. I actually came up with something like this idea a couple of months ago when thinking about how to solve collisions. "How come no one has come up with this idea before?", I tought. Of course someone already did: David Baraff in 1992! I guess I wasn´t that groundbreaking after all... Smiley

ps2. "Nearby" should be "overlapping".
7  Game Development / Newbie & Debugging Questions / Re: Rotating bullet bullet shot[need help] on: 2013-05-05 01:39:45
Something like this should do the trick

bulletDirection = mousePosition - gunPosition
normalize the vector bulletDirection
multiply bulletDirection with the desired speed
8  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-03 20:10:42
Did you read my reply?
9  Discussions / General Discussions / Re: Your favorite platform games of the last five (5) years? on: 2013-05-03 15:48:12
Platformer in the last 5 years? Super Mario Galaxy 1 and 2. Great games! Smiley
10  Game Development / Newbie & Debugging Questions / Re: Player wall collision sliding problem [Need Help] on: 2013-05-03 14:47:20
I belive that this is a common problem. First you check if there´s a collision in the y-axis and stops velocity if intersection returns true, then you do the same in the x-axis. The problem is that when intersection is true in the x-axis, it will also be true in the y-axis since for a collision to be true you have to be "in" a collision. H3ckboys solution is one, another one is the one I posted in your last topic about collisions here http://www.java-gaming.org/topics/corner-collision-detection-need-help/29399/msg/269818/view.html#msg269818: Check for intersection. If it returns true you check how much the objects overlap and then push back one object the amout of overlap. This way you´ll always be just outside of collision.
11  Games Center / Showcase / Re: Aircraft War on: 2013-05-02 13:58:27
Nice going! I have fond memories of Wings of fury so this is kind of a blast from the past.

I have a huge problem with the game though and that´s the controls. First of all, it get´s very cramped on the keyboard with the Z, A, Space and B. It doesn´t fit right in the hand at all, so it would be a good idea to look it over. Secondly, the Left and Right is totally opposite to my intuition. At the very least you should add an options to invert the steering. If you feel like fixing this I´ll gladly be looking forward to an update. Smiley
12  Games Center / WIP games, tools & toy projects / Re: Pseudo Voxel Expriements on: 2013-05-02 01:39:22
Looks great! I like the little Santa-looking guy... Smiley
13  Game Development / Newbie & Debugging Questions / Re: Tile Based Map Slick2d on: 2013-05-01 22:31:22
You´re not really stating a problem. You have a tmx file and then you load the data into an array which sets each tile as blocked or not blocked. What else do you want to do?
14  Game Development / Newbie & Debugging Questions / Re: [SOLVED] {lwjgl} Recreate the "intersects" for Rectangle collision on: 2013-05-01 16:24:54
You´re welcome! Feel free to press the "appreciate" buttons... Smiley
15  Game Development / Newbie & Debugging Questions / Re: [SOLVED] {lwjgl} Recreate the "intersects" for Rectangle collision on: 2013-05-01 00:35:35
Doesn't make much of a difference though. Just noticed a little optimisation.

Yeah, it´s the same idea. But since I also wrote some stuff about how to deal with a collision I thought it was worth the extra post. Smiley
16  Game Development / Newbie & Debugging Questions / Re: {lwjgl} Recreate the "intersects" for Rectangle collision on: 2013-04-30 23:31:36
I posted a AABB method a couple of days back. Hope it helps.

http://www.java-gaming.org/topics/corner-collision-detection-need-help/29399/msg/269818/view.html#msg269818
17  Game Development / Newbie & Debugging Questions / Re: Limiting the fps of a game using no external libraries on: 2013-04-30 14:40:51
Here´s the classic Java gaming text on game loops: http://www.java-gaming.org/index.php?topic=24220.0
18  Game Development / Newbie & Debugging Questions / Re: Hi, just a few questions hehe on: 2013-04-30 14:18:52
I don´t really have a great relationship with general purpose game programming books. They come out strong and say they will cover everything but in the end that means they doesn´t really cover anything. On top of that most Java game programming books focus on the Java API for game development but if you browse the forum you´ll find that few belive that this is a good idea. Smiley The really good game programming books I´ve come across are the one that focuses on specific areas, like "Real time collision detection" (a hard core collision detection book) and... Some AI book I can´t remember that name of on top of my head. One general purpose book I am interested in though, but haven´t had a chance to check out, is "Beginning Android Games" by one of the creators of LibGDX, Mario Zechner. It looks promising... Anyway, since you have so much Java experience there are a lot of tutorials out there that will get you started on understanding the basics of a real time game and I would also suggest reading a lot of game code.

Regarding the fact that you want to don´t want to use a library I would suggest starting out with LWJGL, a Java port for OpenGL. OpenGL may sound like it´s for 3d only (it did to me when I got started) but it´s just as good for 2d games and is really the only way to go if you want to get serious.

So to sum it up: Tutorials, code and LWJGL. Good luck and welcome! Smiley
19  Games Center / Contests / Re: Ludum Dare 26 starting 26th April! on: 2013-04-29 01:37:04
Just thought I'd make a quick post of where I'm at for this LD.
I'm having to enter the jam as I have a friend doing arty stuff for me, and we're progressing along quite well.

We decided interpret the theme in the setting: a submarine. Submarines are built to be quite minimalistic as they need to be compact yet functional. Basically the premise of the game is that you have to single handedly fix a sinking submarine, namely three components of: The fuel, the battery and the engine, even while they continue to break. There's very little gameplay(you might even say... MINIMALISTIC Grin), but what you have to do is rather hard.

Looks really nice! Somehow that old school graphics makes me think of the Sierra game "Codename: Iceman" (yes. I´m that old). And a simple mechanic can still make a great game. I´m looking forward to try it out!
20  Game Development / Newbie & Debugging Questions / Re: [Slick2D] coordinate checking on: 2013-04-27 04:38:14
You need to put the player in the same coordinate system as your map so they have the same point of reference. Don´t spawn the player at zero, spawn the player at some coordinate on the map that´s... Not zero... Smiley
21  Game Development / Newbie & Debugging Questions / Re: [Slick2D] coordinate checking on: 2013-04-27 04:21:06
Why and how could the tilemap have negative coordinates? I think you´ll have to explain more... Smiley
22  Game Development / Newbie & Debugging Questions / Re: shooting is working but ... on: 2013-04-27 04:13:26
Eh? Perhaps i misunderstood. Did you get a stranger result when changing x,y to floats? The cast to int was for the drawing only.
23  Game Development / Newbie & Debugging Questions / Re: shooting is working but ... on: 2013-04-27 04:02:50
cast the x and y variables to a int in the drawing

...and add 0.5 to round it off to the nearest int

1  
g2d.drawRect((int) (gun.getX() + 0.5f), (int) (gun.getY() + 0.5f), gun.getW(), gun.getH());
24  Game Development / Newbie & Debugging Questions / Re: Question about TileMap and Tiled on: 2013-04-27 03:37:14
I meant I tried my little snippet and it didn´t stretch... But all is well that ends well!  Grin
25  Game Development / Newbie & Debugging Questions / Re: Corner collision detection. [Need Help] on: 2013-04-27 03:31:56
If you want to do a "AABB vs AABB" test here´s a vector based way to do it.

You need some vectors for the boxes: center, half the width and half the height.
You also need a vector to store the result: minimum translation vector.

1  
2  
3  
4  
5  
minimumTranslationVector.x = Math.abs(this.center.x - other.center.x) - (this.halfWidth + other.halfWidth);
minimumTranslationVector.y = Math.abs(this.center.y - other.center.y) - (this.halfHeight + other.halfHeight);

if(minimumTranslationVector.x < 0 && minimumTranslationVector.y < 0)
       //Collision


What this mean is that you test one axis at a time for overlap. The absolut value ( = positive value) of "(this.center - other.center)" puts the center position close to zero and then you add half the size of the box. If the "subtracted position" is greater than the size of the boxes, you get a positive value and there is no overlap. If the "subtracted position" is smaller than the size of the boxes, you get a negative value.

That is all if we just want to test intersection, but what is the "minimum translation vector" (I´m just gonna call it by it´s abbreviation "mtv" from now on)? This is a little bonus: it is the smallest amount you have to push back an object for it to NOT be intersecting. This is often a problem in collision detection, that you get stuck too deep in a collision so you can´t get out. So how do you use the mtv? One way is to see what axis is has the smallest intersection and push it back that way. Let´s say you´re testing collision between a Player and a Wall:

1) Get the vector from the center of the player to the center of the wall: Wall.center - Player.center.
2) Find out on which axis has the smallest intersection (let´s just say in this case it is x)
3) player.position.x += mtv.x.

The result is that the player is positioned precisely outside the collision every collision check.

I hope it helps.

(any errors I blame on the very, very late hour over here... Smiley)
26  Game Development / Newbie & Debugging Questions / Re: Question about TileMap and Tiled on: 2013-04-27 00:12:54
I think he wants the game to scale, but not stretch. If so, I think that this is a solution.

Tried it. Didn´t stretch.
27  Game Development / Newbie & Debugging Questions / Re: How do I start making a game? on: 2013-04-27 00:06:57
This is a question that´s asked a lot, so I suggest you start out by searching the forum. There are also a lot of good tutorials out there, both text and video, so a google search will get you a long way. LibGDX has a lot of stuff on their site and a very simple "this is how LibGDX works"-game code example that is really useful for understanding how it works.
28  Game Development / Newbie & Debugging Questions / Re: Question about TileMap and Tiled on: 2013-04-26 23:50:43
Try adding this to your resize method:

1  
2  
3  
public void resize(int width, int height) {
   camera.setToOrtho(false, width, height);
}


This should set the viewport to the same size as the window.
29  Game Development / Newbie & Debugging Questions / Re: Question about TileMap and Tiled on: 2013-04-26 15:27:31
I´m not really sure I understand your problem, but the way you describe it is the way it´s supposed to behave. If you resize your window everything will scale to the new resolution.

One thing that is important to understand is that you´re actually not loading 16x16 pixels that you can plot to the screen: You´re loading a texture that is pasted on a rectangle. A rectangle doesn´t have "pixel size", just coordinates, and will clamp the image within these coordinates .This mean that when you resize the window, you also scale the rectangle (= sprite) to fit the new window resolution and since texture coordinates are relative to the rectangle you´ll also scale the texture. Hence, everything will stretch.

So if what you are experiencing are that the "stretch ratio" of the tile is equal to the new window size, this is expected. You may not like it but it is normal. If not, I think you need to clarify your problem.
30  Games Center / Showcase / Re: [Android] Flying Bob - fast-paced game arcade on: 2013-04-25 01:53:20
It looks absolutly fantastic! I really, really hope I´ll get to play this on my iPhone soon! Cheesy
Pages: [1] 2 3 ... 5
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 (60 views)
2013-05-17 21:29:12

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

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

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

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

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

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

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

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

UnluckyDevil (175 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.218 seconds with 20 queries.