Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tiled Map Engine
Started by Caleb P Feb 01 2013 03:53 AM

250 replies to this topic
[TOPIC CONTROLS]
Page 1 of 11 1 2 3 »
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

This is a thread for creation of an opensource tiled map loader+game engine.

If you wish to contribute to it, please feel free - just post and you can be included in the development. You can also put feature requests, comments, etc.
uid: 147322 topic_id: 35538 reply_id: 335538


[TOPIC: post.html]
#2

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Sounds good. We can keep things on both DropBox (private) and GitHub (public). I just got LUA maps loading in my codebase, so if it's okay with you we can start there....

Send me your email and I can share the project folder with you. I can handle releases via GitHub at the github URL for the project.

Here's where the latest code and example will live for the community...

https://github.com/superqix/CoronaTiled/archive/master.zip
uid: 51498 topic_id: 35538 reply_id: 141252


[TOPIC: post.html]
#3

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

Hey guys, I just found Caleb's post yesterday, and I'm very excited to see what you two end up creating. I'd like to put in a request if you guys don't mind.

Request:
--Physics for the Object Layer in Tiled (as well as adding Object Layer support).-- The reason why I point this out is that after people create tiled layers for their maps, it'd be nice to add physics bodies in the form of objects (instead of a second layer with tiles including physics). *Nice for when people are trying to add physics to their map and surfaces don't match up exactly with tile edges.* Using different layers and creativity, just allowing objects would open a million possibilities and customization right away.

Forgive me but I'm fairly new to programming and have been making a game on corona by myself. I have a question (or request I guess) pertaining to the current version of GridMap. I'm just confused with the documentation for how to add physics to the tiles using your program. Do you possibly have some sample code I could look at where a physics tile layer interacts with some moving object or something? Thanks, rather than having you explain it to me this would probably be better... Then I'm wasting my time and not yours. :) Thanks!
uid: 215209 topic_id: 35538 reply_id: 141265


[TOPIC: post.html]
#4

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Hey, @no2games:

I have another suggestion. Instead of communicating with email, how about ALL of the communication goes on within this thread? Basically like using this thread as an email conversation. I know it might get cluttery, but then it would really be open source. If you don't want to do that, we'll have to think up something else - I don't want to communicate through email.

@cjc83486:

https://www.dropbox.com/s/a5y5zhop7mpqsc6/GridMapExample.zip

The images for it are sourced from IndieGameDesigner.com - I got them from this thread and watermarked them.
uid: 147322 topic_id: 35538 reply_id: 141319


[TOPIC: post.html]
#5

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

@Caleb, I'm fine with using the thread for communication. I think I need an email to share the dropbox folder with you if we both want access to update files. I don't know if this board does PMs, but that would be better than posting your email here :)

BTW, Github is better for merging changes if we get a bunch of devs signing up, but I'm sure we can make it work initially if it's just the two of us.

I will check out your example too, I'm trying to merge our two code bases right now...

@cjc83486

I'm all about the objects layer. It's one of the reasons I want to build this importer.
uid: 51498 topic_id: 35538 reply_id: 141330


[TOPIC: post.html]
#6

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Okay, it looks like Corona Lime is going OSS on GitHub... That may render this project moot...

http://developer.coronalabs.com/forum/2013/02/01/lime-update-news-not-download-link

I'm going to offer my help getting corona lime onto GitHub, so maybe this turn into updates and such for a common code base.
uid: 51498 topic_id: 35538 reply_id: 141332


[TOPIC: post.html]
#7

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

I've still been working on this off and on... I did pull the Physics/Properties code out of GridMap and added to Tiled, but it wasn't working like I wanted. But, I had a big break though today and bang out a lot of stuff that was just kinda working:

* Set properties & physics from Tiled (thanks to Caleb + GridMap)
* Image Layers
* Object Layers (except for tile objects)
* Physics on object layers with generated bounding shapes (first 8 points)

I still need to clean up some stuff before releasing it into the wild... but it's looking pretty good.

corona tiled 1

corona tiled 2

uid: 51498 topic_id: 35538 reply_id: 144563


[TOPIC: post.html]
#8

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Wow - looks great!

I've also been working on it... Not getting such good results. I've been trying (and mostly failing) to get a culling system up.

Which makes me think that we should make a tiled image loader separate from a tiled level builder. I suppose it could just use object layers for physics, and then add it all into the tiled image loader.

Anyways, any ideas on what to name it?

C
uid: 147322 topic_id: 35538 reply_id: 144571


[TOPIC: post.html]
#9

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Yes, at some point we should break out the loader/parser from the rendering engine or have different kinds of calls to load maps...

I for sure want to add some more parameters to the load call so you can get to just a portion of the map. that should be enough culling for 99% of the people out there...

function tiledMap:load( mapFile, tileTop, tileBottom, tileWidth, tileHeight )

Also, one of the issues right now is it's really hard to set properties of an individual tile in (x,y) space or set an individual objects properties when a object layer has it's properties set--all these cases tend to overwrite each other.

I think I need some sort of table merge that has a preference setting for which table overwrites the others values.

As far as names go, I'm happy with something simple and straightforward. CoronaTiled is what the GitHub prodject is named, but I'm open to suggestions. :)
uid: 51498 topic_id: 35538 reply_id: 144577


[TOPIC: post.html]
#10

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

Wow, this is nice! Few questions:

Are you using Gridmap, or the one you made previously?
*If the latter, I think you guys should settle on one or the other so you guys don't overlap on problem solving. :)

For the objects that are polygons, it looks like you can use 8 points, in which they can be non-convex as well.. is this correct? For the polygon shapes, it looks like there is no middle to the object, do objects sometimes accidently go through these since it has no thickness?

I was talking to Caleb about this before on his gridmap forum, but I'm guessing you're not subscribed to that Topic... do you think you could have this ready to be used by March 15th? I know it's only 2 weeks but it seems you are pretty far on it, and that's when my spring break is. I've got a full school load so it's really the only time I have to put a large amount of effort into my project, so if you could that'd be amazing.

Thanks a lot to the both of you, literally are lifesavors (I wouldn't have known how to create my game without your projects).

-Curt
uid: 215209 topic_id: 35538 reply_id: 144600


[TOPIC: post.html]
#11

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Curt,

This is a combination of GridMap + CoronaTiled, so hopefully you get the best of both. Fast ImageSheet based multi-layer maps and object layers (my CoronaTiled) AND the ability to set Physics and other properties from the Tiled property editor (Caleb's Gridmap) with some bug fixes and other fun stuff tossed in for good measure.

I think your right, we need to pick a new name and start this as a fresh project so it isn't confused with all the other projects out there.

Corona's limit on a physics body is 8 points, and non-convex--I don't check for either, I just pass the first 8 points and hope for the best.

Things like this are NEVER finished, especially since Tiled supports so many options, but I will post the code so far and an example project/tmx map on GitHub either tomorrow or early next week.

Hopefully a few people can try it out and post some bugs and we can all have something stable by 3/15.

I see few "showstoppers" that I would want to have before we call it a 1.0 version:

* Image layer properties (Stretch to fill map, Tile to fill map)
* A display.newRect() as a map background (solid, gradient)
* Inherited properties at the Map -> Layer -> Individual Tiles/Objects
* Tile objects (player start, power ups, etc)
* Chunking or culling maps
* A few demo projects and maps (Platformer, RPG, Big Map, etc.)
* Documentation, or at least a screencast or two

Anything I'm forgetting?
uid: 51498 topic_id: 35538 reply_id: 144611


[TOPIC: post.html]
#12

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

I've got a name idea - Quartz Tile Engine. That way, if we ever separate the tile renderer and the level builder, we can use rock/mineral names for it to go with the theme. It also sounds pretty cool...

Let me know if that sounds good. That's all I posted to say - I'll be back (hopefully) in the morning :)

C
uid: 147322 topic_id: 35538 reply_id: 144614


[TOPIC: post.html]
#13

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

No2games and Caleb,

Yeah that sounds awesome, I don't mind if a few bugs come up, I'd be happy to test run most of the versions and updates. The game I'm currently making is a RPG, so if you have someone that is making a Platformer, we should have 90% of users covered testing wise.

As far as the design go, I like the idea of making physics objects mainly for the object layer. For most RPG users, I'm unsure if they will benefit too much from tile physics layers over object physics layers. Anyway, this is how I imagine using it:

--Use tile-LAYERS for fore-ground and back-ground layers. *Currently what I'm doing is putting "ground" in the name of the Tiled layers I am having my player walk on. I use a search function for each layer to check for the substring "ground" and put it underneath my character, the rest are set to above.

--Use an Object-PHYSICS-LAYER for houses, trees, fences, etc.
*here you just set the Object physics layer invisible with .isVisible=false These objects don't really need to be distinguished and can be treated as a layer, since all you need to do is bump into them.

--Use INDIVIDUAL-PHYSICS-Objects for power ups/items/NPC characters
*How I do power-ups currently is use a pre-collision event handler and remove the object before I collide with it. Really all you guys should have to do is to make it so users can access individual OBJECTS. Currently you can set properties on individual objects, so really all people would need to do is have a 'type' or 'name' property where they can code "Make all objects of type "potionItem" do this..." Basically that functionality is already in there.

--Use Object LAYERS for spawn areas
*Basically you can randomly spawn enemies or items within the bounds of layers of type "spawnArea". Same thing with a Player start position object. This way making maps is really fast and there aren't enemies wedged in trees and such.

--Use INDIVIDUAL-Objects for things such as doors and NPC (non-player characters) talking radiuses.
*I'm not sure if I need to use these as physics objects, rather I may just make it when my player is colliding or within a certain distance with these objects to bring up a "talk" or "open door" button once pressed you change map or display talking text.

Well there is how I plan to use it. As you can see, really all you guys have to do is make it so people can add tile layers for background, physic-object-layers for the general static collision (people can make multiple if they want to add character jump features.. etc.), and individual physics objects and objects. The rest the user should be able to figure out because there are way too many options that a game designer will want. (possibly the only other thing people could want is physics tile layers and individual physics tiles.

Good luck and thanks a bunch,
-Curt
uid: 215209 topic_id: 35538 reply_id: 144630


[TOPIC: post.html]
#14

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Okay, I cleaned up everything this morning and added imageObjects as an object type... These are very cool, because they don't snap to the grid but use the same images as a tile set, so they are perfect for a layer of interaction enabled tiles scattered about a level.

Caleb and Curt, here's a direct download from gitHub...

https://github.com/superqix/CoronaTiled/archive/master.zip

Take a look at the TMX file as well for how the layer properties are set up. Right now you go into a layer's properties and simply add "physics:enabled"="true" and you get a static body. Add "objects:bodyType"="dynamic" and they are affected by gravity.

Here are the big issues:

1) You can't set a single object or tiles properties--only at the Layer level. This needs to change for this to really be, but I don't want them to completely overwrite each other. So you could set "objects:bodyType"="dynamic" at the layer level and "angle"="45" at the object level and both sets of properties should affect the object.

2) Polygons and Polylines don't work consistently. I'm new to Box2d, so I don't know why. Make some triangles (which should never be invalid) and 80% of them work, but a few act like they aren't even there. Rects, Circles and Lines work 100% of the time

I love the idea of naming the components out of materials that physical tiles are made out of. There's Porcelain, Marble, Glass, Quartz, Ceramic, etc. I personally would vote for Ceramic because it begins with a "C" like Corona.

uid: 51498 topic_id: 35538 reply_id: 144680


[TOPIC: post.html]
#15

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Pushed a new commit that takes care of #1 in the msg above. Now you can go into an single object and set its properties. The "physics:" prefix doesn't work, but "bodyType", "rotation", etc. all do.

https://github.com/superqix/CoronaTiled/archive/master.zip

Now if I can only figure out #2

This totally makes me want to build a physics based platformer.
uid: 51498 topic_id: 35538 reply_id: 144693


[TOPIC: post.html]
#16

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

Thank you very much, I ran it and it looks great, I'll try to fiddle with it when I have time.
uid: 215209 topic_id: 35538 reply_id: 144752


[TOPIC: post.html]
#17

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

@no2games:
I've just finished v0.0 of Quartz Tile Renderer - it just renders maps, no physics, values, or anything else. However, it does use an extremely fast method of culling. It's based on a post months (years?) ago about culling; it changes the image on tiles instead of moving them one by one. That way you only render the amount of tiles needed. The culling isn't customizable, it just culls to the screen size. However, custom culling shouldn't be too hard to add.

The thing that I really want to add is rendering only the tiles that exist. As is, for each layer, Quartz is rendering visible width*visible height tiles per layer - if you only have one real tile on a layer, it still renders every one possible. So a map with 32x32 px tiles on a 1024x768 sized device, even if only one tile is displayed, will render 33x25 tiles (one more in both dimensions) or 825 tiles. That's a lot of tiles, and with a lot of layers, it can get slowed down. Here's an example, along with the Quartz renderer.

I like the name idea, too. Ceramic can be the name of the entire library, and each component can be one of the names you mentioned. I'm calling this rendering library "Quartz" because it's pretty, but not worth much :)

@cjc83486:
Are you going to be a tester, or a co-creator? Either one is fine. I'm just curious.
Caleb
uid: 147322 topic_id: 35538 reply_id: 144818


[TOPIC: post.html]
#18

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

Caleb- Most likely test, though here and there I may add additional features in which I'll definately post incase you guys want to add them. As far as actual development I dont think with school, work, and my current project that ill have time to make a huge contribution, just small additions. Haha you guys definately make it hard to say no though with how well it is turning out. I love the way you are optimizing the maps with culling and visible display area. I was thinking the same thing about the latter :).

No2games- Have you been making sure that all the points are in a clockwise rotation? If the problem keeps persisting maybe the easiest thing to do is just make polygons and triangles out of multiple line objects. Im away from my computer currently (typing on phone) so i dont know how tiled is outputing a polygon's points. However, if it lists it in the order a person places the points in tiled, then you can play connect the dots with line objects. This will overcone corona's restriction on non-convex polygons and a limit to 8 sides. :) This will make a polygon with no inside however... But may be useful still for what we are doing.
uid: 215209 topic_id: 35538 reply_id: 144866


[TOPIC: post.html]
#19

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

@Caleb,

Good first effort on Quartz, I can see the concept, but I think you should load 2x or 4x the number of tiles vs. the screen size. I was only seeing 20fps in the windows simulator and 10 to 15fps on my old iPad while scrolling, and I think it's all in that map.move() function.

I think if you loaded enough tiles to cover a full scroll in all directions (so 4 * w,h) and let the person move the map display object normally, then on release call map.update() you wouldn't even notice the update() function happen.

That should be easily 60fps with a minor hiccup on release that you could then optimize the crap out of.

Just my $.02 :)
uid: 51498 topic_id: 35538 reply_id: 144881


[TOPIC: post.html]
#20

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

@Curt

I didn't know that the points needed to be clockwise... That would make sense. I found this code on stack overflow to order points in that way...

function appSortPointsClockwise(points)
    local centerPoint = appGetCenterPointOfPoints(points)
    app.pointsCenterPoint = centerPoint
    table.sort(points, appGetIsLess)
    return points
end

function appGetIsLess(a, b)
    local center = app.pointsCenterPoint

    if a.x >= 0 and b.x < 0 then return true
    elseif a.x == 0 and b.x == 0 then return a.y > b.y
    end

    local det = (a.x - center.x) * (b.y - center.y) - (b.x - center.x) * (a.y - center.y)
    if det < 0 then return true
    elseif det > 0 then return false
    end

    local d1 = (a.x - center.x) * (a.x - center.x) + (a.y - center.y) * (a.y - center.y)
    local d2 = (b.x - center.x) * (b.x - center.x) + (b.y - center.y) * (b.y - center.y)
    return d1 > d2
end

function appGetCenterPointOfPoints(points)
    local pointsSum = {x = 0, y = 0}
    for i = 1, #points do pointsSum.x = pointsSum.x + points[i].x; pointsSum.y = pointsSum.y + points[i].y end
    return {x = pointsSum.x / #points, y = pointsSum.y / #points}
end

I will try and add that in this week...
uid: 51498 topic_id: 35538 reply_id: 144882


[TOPIC: post.html]
#21

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

Oh, and BTW (I know this is 3 posts right in a row) I'm in love with the names, and I like the idea of breaking out the different renders to keep the overall project from getting too complicated. Here's how I see it working....

require ("ceramic") --  object physics and rendering to display object
require ("quartz") -- rendering/culling engine for large maps
require ("marble") -- some cool other feature, maybe random map generation
etc
etc

all of these libraries would require the tiled.lua core that could share the loading/savinging/ect.
uid: 51498 topic_id: 35538 reply_id: 144884


[TOPIC: post.html]
#22

cjc83486

[GLOBAL: userInfoPane.html]
cjc83486
  • Enthusiast

  • 34 posts
  • Corona SDK

Awesome, glad that was the case, I can't wait to use it, though unfortunately I have 3 midterm tests this week, a quiz, and a lab, so I'm a bit full. So question, does CoronaTiled currently only load in object layers or does it load in tiles as well at the moment? I know you guys plan to eventually make it into two separate parts, but just asking for the current version.

Thanks a ton guys, your work is amazing, once the word gets out I'm sure a ton of people will be using it.
uid: 215209 topic_id: 35538 reply_id: 145019


[TOPIC: post.html]
#23

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

@no2games:
Should have said potentially extremely fast :)

From working a bit more on it, I think I'll keep that for now. I'm attempting a new method of culling, just to see which is the easiest/cleanest/fastest. Now I'm going to try removing and adding tiles offscreen and onscreen. So I'll see which is fastest.

C
uid: 147322 topic_id: 35538 reply_id: 145060


[TOPIC: post.html]
#24

ponywolf

[GLOBAL: userInfoPane.html]
ponywolf
  • Contributor

  • 264 posts
  • Corona SDK

FYI: I pushed some bug fixes out this morning...

@ Caleb

Potential performance vs. actual performance :) That gets me every time.

@cjc83486

Yes, the code in the link above does all this..

  • JSON/LUA exported map files
  • Multiple Tile Layers
  • Multiple Tilesets
  • Margins and spacing
  • Uses Corona Image Maps and Image Map groups if you limit yourself to a single tileset image
  • Object types (regular, polygon, line)
  • Image Objects
  • Physics and display object properties
  • Image Layers

    It's pretty much good to go to build a full game. In fact, I was going build a quick clone of a Labyrinth-style game using Ceramic/Tiled as an example. I figure it would be about 150 lines of code tops.
    uid: 51498 topic_id: 35538 reply_id: 145068


  • [TOPIC: post.html]
    #25

    ponywolf

    [GLOBAL: userInfoPane.html]
    ponywolf
    • Contributor

    • 264 posts
    • Corona SDK

    I've still been working on this off and on... I did pull the Physics/Properties code out of GridMap and added to Tiled, but it wasn't working like I wanted. But, I had a big break though today and bang out a lot of stuff that was just kinda working:

    * Set properties & physics from Tiled (thanks to Caleb + GridMap)
    * Image Layers
    * Object Layers (except for tile objects)
    * Physics on object layers with generated bounding shapes (first 8 points)

    I still need to clean up some stuff before releasing it into the wild... but it's looking pretty good.

    corona tiled 1

    corona tiled 2

    uid: 51498 topic_id: 35538 reply_id: 144563



    [topic_controls]
    Page 1 of 11 1 2 3 »
     
    [/topic_controls]