Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Collision Detection with Tiled (TMX)

Author
Message
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 7th Aug 2013 08:47
So, I've always tried to use my own collision detection methods in AppGameKit, but I'm looking to ease development and use stuff built-in. I'm looking at this TMX loader here http://forum.thegamecreators.com/?m=forum_view&t=205387&b=41 and I'm wondering the best way of getting the collision data.

Reading into it, AppGameKit uses dummy sprites that I can assign collision data to. Is this about it? Load a map, read in the collision points, and for each new group create a new dummy sprite and assign collision properties to it?

Is this about correct?

Hi there. My name is Dug. I have just met you, and I love you.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 7th Aug 2013 18:40
I suggest to insert a value in the map in a layer, and read it from Json or XML.
In this way you avoid collision detection calculation (i think you mean with background).

Long life to Steve!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 8th Aug 2013 22:05
Are you talking about with the individual tiles? Or the separate collision zone data that can be embedded in the TMX files?

DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th Aug 2013 22:58
If you just need a tiled grid collision with objects, I would just use the co-ordinates to work out which sprites you are over, and grab the relevant data out of an array. My Editor example covers this. No real need for dummy sprites for tiled collision.

3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 8th Aug 2013 23:23 Edited at: 8th Aug 2013 23:32
well tmx you can make the sprite go between two points I was about to show a video of how this can be accompished. The concept behind this is that you load the points as place holders that check to see if the enemy passes those bounds then it reverses direction. I have already implemented that into my 4 layer system of tiled import. It shows the animated walking of the enemey as it goes back and forth on a given column and between the two dummy sprites that the enemy will go from and too. I useually load the bounds that the enemy can travel as a seperate tiled sheet.

I think I might be missinterperting what you want to do though. I play with tiled alot so I don't know what you are tring to do with it.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 9th Aug 2013 05:55
You can give a string or number to layer settings and you can use for example -1 to say no walk.
We are building a 250000px map for a mmorpg and we are using this system.

Long life to Steve!
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 9th Aug 2013 17:54 Edited at: 9th Aug 2013 18:02
i assign a whole layer as collision but I think this might be ineffective for long segments of walls. It is also uneffective on long walkways. setting physics on a object actually slows the game a little. I use the group method to detect if the sprite collides with a sprite in the layer for instance.

SetSpriteGroup its a agk fuction.

You check collision by seeing if sprite collides with that group.

agk::GetSpriteHitGroup(1,agk::GetSpriteX(charid),agk::GetSpriteY(charid)) checks if the current sprite charactor hits the group.

i also use agk::GetSpriteCollision to check if a sprite hits another in a layer
i use this for coin collection or enemy hitting the player.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 10th Aug 2013 23:09 Edited at: 10th Aug 2013 23:31
Otherwise, what if I did a seperate layer for collision? Store it in memory, if the value is '0' then the tile is walkable, if something else then it isn't? (Or something along those lines)

EDIT: This leads me to another question. How do you guys add 'objects' to the maps, like coins or enemies? Right now, I'm just viewing Tiled as a static scenery editor, but there has to be some creative way in order to get interactive objects in there.

Hi there. My name is Dug. I have just met you, and I love you.
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 12th Aug 2013 18:45 Edited at: 12th Aug 2013 19:08
tmx files can be seperated by layers if you use vectors it is very simple. I don't use 0's or 1's any more for collision detection sence I have my own editor. I have recieved emails to make my program available. I might make it availiable I just want to sell it not give it away. My editor does alot of tough stuff for me. Expessially when using tmx files. I am currently making 3d worlds with tmx files. which will be usefull for my next part of my editor. I am using loadsubimage to get images that will help in making a 3d game, but right know I am making a 2d game.

Any way this is how I implement jump. I use the tiled layer when is in a vector format and assign it group one. This following code assigns the 4th layer to group 1. If you look at the tiled file that is what I call the collision layer.





Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.

Attachments

Login to view attachments
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 13th Aug 2013 17:53
I think you are on the wrong way.
You must check the tile number, not the layer.
I done a collision manager for tiles and a tile engine in 200 lines.
You have too many lines, and layers there.
Look the video i done with my game "Impossible Quest" in the showcase, using only 2 Layers.

Long life to Steve!
3d point in space
15
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 13th Aug 2013 18:13 Edited at: 13th Aug 2013 18:14
not really does not matter how many layers you have I think it is faster in developing a game. My app runs close to 60 frames per secound so I dont think that I am doing anything wrong. My editor makes it easy as long as I dont have more then 99 layers.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 13th Aug 2013 19:24
You know Tiled can make objects. So interactive things like coins and whatnot could just be objects instead of a layer tile. Making a new layer to place things like a few pieces of rope for instance wastes a lot of space in the map format, since it'll write 0s to every square that doesn't have rope in that layer. Few layers equals faster load times.

Login to post a reply

Server time is: 2024-11-24 17:29:00
Your offset time is: 2024-11-24 17:29:00