Million Tile Engine Beta Release

What’s a good workflow / tools for creating images=>tilesets(with extrusion) that will allow you to add/modify/delete tiles to the tileset as you go, without the need to potentially have to rework any of the Tiler maps?  

I have TexturePacker for example and it seems to automatically layout sprites for you, so the concern would be it it rearranges the order of images on it.  Then you might have to go back and completely rework your Tiler maps.   I have spritehelper2 also and I know this lets you update sprites, haven’t double-checked if you can make the sprites same in the same positions however.    

Is there actually a way to manage images, extrude, create tilesheet in Photoshop (CS6) itself perhaps that avoids the need for TexturePacker or SpriteHelper and satisfies the above-mentioned goal?

 

Well I create individual tiles and name them so that I can use texturepacker to sort them by name in the layout area.  That way it keeps the order the same and groups like things together.  Of course if I added an extra tile that’s already been done in a group (say a type of tree) then if I were to add that in it would insert this into the tile set and could cause an issue in the code.  

What you might be better doing is a naming system that adds any new tiles to the end of the layout (numbering for instance).  

hi dyson,

I’ve setup zooming and panning on the map but as you’ve highlighted before, it starts to look bad when you scale out (scaling in and panning is perfect) as the edges become visible (and the culling, etc).  I’m guessing this is a tricky thing to overcome?  I’d have a go at it myself in the MTE file but it looks very complex unless you can suggest where to look?  m.zoom function hasn’t helped me figure it out.

Cheers

If you know how far you want to pan out, a simple workaround would be to set a smaller blockScale and start off zoomed in. For example, instead of using blockScale = 64, use blockScale = 32 and call mte.zoom(2, 1) before your enterFrame. This has a side-effect of increasing the apparent camera constraints if you’ve set any.

The upcoming updated will allow you to set a cullingMargin parameter when you call goto() to specify how far the active map region should extend from the edges of the screen. This is also useful to allow physics simulations to run beyond the edge of the screen. This part of the update is actually already in place and working, if not particularly well tested yet.

Both of these have the effect of increasing the number of active tiles, which may impact performance on older, slower devices.

That sounds perfect for the map.  I was probably going to have a wide sea border on the edges anyway.  I can therefore make the sea border wide enough to allow the zoom out to the level desired.

But I’ll try out the blockScale trick you mentioned in the meantime.

Do you have a view on what features you’ll release on the version after this coming one?  Putting it out as a topic thread might be useful when you have time.

Physics support for the various different kinds of Tiled objects is coming along nicely. The objects will automatically generate the correct physics body shape for themselves if the shape property is set to auto, and this includes automatic multi-body generation for polygons, polylines, and non-circular ellipses. 

At the moment all objects can be displayed with colored line strokes while ellipses and squares can also have a fill color. 

[media]http://www.youtube.com/watch?v=9m044O8W-Xc[/media]

@Coldwilson; The plan was to shift gears over to isometric support after the physics was more fleshed out, and that is still the plan at the moment. I’ll have a better idea exactly what that entails after this update is finished and I can devote some time to it. The seperate thread idea’s a good one. This thread is starting to get a little long, a little more difficult to read through.

@Coldwilson; Preliminary map-storing functionality is in place. Obviously the simulator isn’t the ideal test of this, but without map-storing the 60x40 maps in the RotateConstrainStoryboard sample project take about 22ms to load each time. With the new map-storage code, which was indeed incredibly simple to implement, they take 22ms to load the first time and then about 2ms on subsequent loads. 

This time refers to only the code going on in mte.loadMap(). Calling the necessary goto(), loading your sprites, and all that will of course take the time it always does, but these things are pretty small compared to the load time of a large map before the new storage code. This will be particularly useful for people with a very large world or overworld map.

All that Physics’y stuff looks awesome Dyson. I’ve yet to get to making something that’s a simple 2D map with a rectangle (as in basic platformer demo). Making tools takes so long :frowning:

@dyson122; That’s fantastic news.  my 500x500 is taking about 1.5 seconds on my Galaxy Note 2, it doesn’t sound much but it’s quite noticeable and would cause irritation for people.  Not so concerned about it on first load and it can be masked if needed.

I tried out the blockScale idea you suggested for zooming out and it does work properly.  I needed to scale it from 42 to 7 to get the zoom level I was after but anything above a zoom of about two (i.e. blockScale of 21) started causing the map to pause and stutter when dragged around.  I don’t think this is a phone memory constraint as the map moves around smoothly when I’m not zoomed out using this method or just the same method previously.   It might not be an issue on the cullingMargin approach but something to be aware of perhaps.

How can you get all sprites in a table? I need to get all sprites added to a certain layer with all their properties that were added through addSprite, is this possible?

What would be the easiest way to use tile properties to add a sprite? I want to use a tile in my tileset as a designated “spawner”. I did figure out a way to do it but it takes much too long to load. Id like to add in my own tile properties: dialog, imagesheet, character sequence, etc.

Hi all,

Firstly, dyson, many congratulations on MTE! It looks awesome and I just wanted to join others in saying what a great piece of work it is!

I only purchased it recently and this morning has been the first proper chance I’ve had to play with it but I’m pleased to say it does everything it promises and is looking great! I really can’t wait to start digging in, deconstructing the demos and learning how to use it to create a couple of RPGs and platform games I’ve been thinking about for a while.

Great stuff! Looking forward to all future updates!

Android Performance

I thought I’d feed back on Android performance as there were some queries/concerns relating to this (I know I had some). Well, I’m pleased to say it’s good news. Very good news. I have the following 3 Android devices (my old phone, current phone and tablet) and I’ve built and deployed all the demos to each:

HTC Desire / Android 2.2.2
HTC One X / Android 4.1.1
Asus Eee Pad Transformer Prime (TF201) / Android 4.1.1

As you’d expect, the HTC One X and Asus Transformer Prime had no problems at all with performance. The biggest surprise, however, was that the older HTC Desire performed brilliantly as well. Here are the average FPS for each demo on each device:

0v844 Demo / HTC Desire / HTC One X / Asus Transformer Prime
CastleDemo / 30 / 30 / 30
Platformer - Angled / 30 / 60 / 60
Platformer - Angled PHYSICS / 20 / 60 / 60
Platformer - Basic / 30 / 60 / 60
Platformer - Basic PHYSICS / 20 / 60 / 60
Platformer - Sonic Finale / 30 / 30 / 30
RotateConstrainStoryboard / 30 / 30 / 30

Performance was even good when the average FPS occasionally dropped to 22 on the Castle Demo on the HTC Desire, which mostly occurred near the animated water tiles when not on basement level. Any visual lags at these points were negligible and certainly didn’t interrupt gameplay or enjoyment. If the FPS were not output to screen I doubt I would have even noticed.

I tested the 2 physics demos in both “hybrid” (MTE default) and “normal” draw mode. On the HTC Desire the average FPS were 20 for each in both modes and while it obviously wasn’t as smooth as the HTC One X it was still perfectly playable. It’ll be interesting to see how physics performance progresses with future updates.

So, overall I’m very impressed - not to mention happy and relieved! I’ll certainly be targeting all 3 in future game development with MTE.

Hopefully all that will prove useful to someone besides me. :slight_smile:
 

I appreciate the kudos, AppDeveloperGuy! 

I also much appreciate the performance testing you’ve done. A lot of people have asked for Android performance and, given the range of devices and manufacturers, the more numbers we have the better.

CastleDemo, SonicFinale, and RotateConstrainStoryboard are configured to run at max 30fps in certain situations, for example if the detected device is not an iPad, or if it is an Android device. If you’d like to test your newer devices against 60fps in these apps you can alter the fps selection in each app’s config.lua file. The samples were designed to run properly at both framerates. SonicFinale in particular is a treat at 60fps.

There is currently no function for retrieving MTE’s sprite array lukestirk, but I will add this to the todo list for the next release.

That’s a good question, cjc83486, one I haven’t considered before. When you say spawner, are you looking to turn the tile into a sprite, or is the tile spawning many unrelated sprites as time passes, as an example? Is the spawner meant to be active when the tile is offscreen, or only when it becomes visible? What is the way you came up with to achieve your desired effect?

Hi, I’ve now done this. Results below…

0v844 Demo / HTC One X / Asus Transformer Prime
CastleDemo / 50 / 50
Platformer - Sonic Finale / 50 / 50
RotateConstrainStoryboard / 50 / 50

Both devices: Mostly smooth as before but occasionally drop to around 42 avg FPS, at which point a slight visual lag is noticable in the background movement. In CastleDemo and RotateConstrainStoryboard it’s barely noticable since the character plods around at a steady pace but on Sonic it is more so. It’s still very fast and smooth but I think the occasional momentary lags were just noticable enough to warrant sticking with a cap of 30 FPS for now.

Spawning unrelated sprites.  For me personally, I’d like the spawner to work on a level based basis.  Thus if player.level == tile.level then spawn().  (I’d like to use this to both create characters at the load map phase and spawn monsters continually throughout gameplay.)

Perhaps the nicest functionality for mte users would be to make a function that collects all tiles with a user-made property.

For instance:

getTilesWithProperty(key,value,level,layer)

-the only required param would be key.

-the key and value refer to the key-value pair in Tiled for properties

This is a lot more useful than a spawn function… since a spawn function should be easy to make from the getTilesWithProperty function: getTilesWithProperty(character,monster,1) —> SpawnMonsters(onthosetiles)

HI Dyson122 - re whether this is for me can I ask:

a) I have a horizontal scrolling game I’m working on which may go to say 3-6 screens wide, a 2-3 screens high at times.  With this limited number of scenes (assuming I use sprites for background & images) do you see any need for a solution that will do occlusion culling for it?   Or in other words from your experience, how many screens wide/tall does a level need to be before you think it really needs occlusion culling?   

b) is MTE basically just the script engine?  i.e. is there a Mac app that lets you draw/position objects within a level?  or do you need to use Tiler or something like this?

c) does it handle different scaling approaches within Corona - like the http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

d) can it handle images (or sprites) allocated to various places on the map?  or is it really just tiles (same dimension tiles/images/sprites)

e)  I thought I read somewhere Corona does do culling now itself?  Is this correct?   What does your engine do here?  Turn on/off visibility for display objects off screen? (not sure if this helps much), or moreso totally removing when not on scree?

Hello greg886,

A) Corona SDK will only efficiently handle a certain number of display objects at a time, depending on the device in use. In general, culling becomes important once you pass a few thousand tiles on modern devices. As you approach the performance limits you will have less and less available for other tasks in your app, such as running AI or calculating movement. If your tiles are scaled such that 10 x 15 fit onscreen, a map 3 screens high and 6 screens wide could contain as many as 2700 tiles. Many current devices would have trouble with such a map without the use of culling. 

B )Yes, MTE is the tiling engine, Tiled is the app in which you design the actual maps.

C) The display scale of maps is set by the blockScale parameter sent to goto(). BlockScale is a pixel value relative to Corona’s content scaling. As long as the width and height properties in the config.lua stay the same, the map will display with the same scale across all screen sizes. If 10 x15 tiles filled in an iPhone screen, 10 x 15 tiles would fill a 7 inch tablet screen (assuming identical aspect ratios). 

I have not explicitly tested the dynamic content scaling using “@2x”, “@3x”, etc, myself, however other MTE users have used it successfully.

D) The primary focus of MTE is displaying and managing tile maps, however as a BETA product it continues to evolve and change. With the release of version 0.844 developers can position tiles with pixel precision in the tile map by using Tiled Objects with the correct properties, so long as those objects are configured to load as Physics Objects at runtime. As the engine grows it will support more and more flexible functionality.

Sprites can be any size or shape you desire. You can move them on a tile-by-tile basis like older RPG’s, or you can move them with pixel precision like newer RPG’s, Zelda, platforming games like Mario, and so forth.

E) Corona’s graphical culling simply avoids rendering offscreen objects, but those objects continue to occupy memory and continue to require a certain overhead simply because they are there (even if you hide them, even if they don’t move). If you have a thousand display objects, or ten thousand, or a hundred thousand, you require more and more memory and resources to maintain all that. In my experience this form of culling is insufficient for the kinds of tile maps MTE was built to handle. The Million Tile Engine entirely removes the tile display objects when they leave the screen. There is no residual overhead left to handle, no load on the CPU, because the display objects cease to exist. 

The Million Tile Engine is more than a simple tool for throwing tiles on a screen. A lot goes on behind the scenes to simplify and remove problems which developers would otherwise have to tackle themselves. For example, say you set up movement through a map with a tile scale of 32. If you decide you’d rather display the map with a scale of 72, normally you would have to go through and alter all of your movement code to match the new scale. The Million Tile Engine knows the true scale of the tiles and always moves the sprites and camera accordingly. Changing the display scale of a map is as easy as changing the blockScale parameter. 

You can setup your map so that map layers appear “closer” to the camera to create a pseudo-3D effect. Movement in MTE takes account of this. If a certain command moves a sprite by 1 tile in 1 second, it will always move by 1 tile in 1 second, whether that tile appears huge on the screen or tiny, near or far. 

For it’s price you’re getting 12,000 lines of code packed with features and functionality, and you’re buying into a product which continues to grow more powerful.

tks - getting back to C, just to double check re when you say “As long as the width and height properties in the config.lua stay the same”:  I’m using the config.lua file from http://www.coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/ which does actually change the “width” and “height” based on if/then’s against device type.  So would MTE support this?  Could I assume:

a) you would have 3 different resolutions of your TileSet images, and dynamic content scaling would work, then

b) you would also when you create the level in your own code, call the MTE code using the blockScale to ensure it matches the resolution for the device.  In other words it would go like:

 - mycode: enter the “enterScene” method 
 - mycode: get the current screen width/height & work out scaling ratio in relation to the actual device, so the actual ratio would be either 1 or slightly higher/lower than 1 as the ratio.  Would work out the ratio based on screen height and scale to fit the screen height for a horizontal scrolling game

 - mycode: call MTE with the blockScale set the ratio from above

 - MTE code: creates effectively a displayObject or group that gives you the map for which the height will match the current device height?

actually can I also ask:

F) What’s the optimal tile size do you think for Corona games/targeted devices?

G) Background - If you have/want a background that isn’t just a color (e.g. moreso pattern) do you just put this as a tile?  Or is there a better technique noting it would be possible to have much larger tile sizes here, to limit the amount of display objects?   It’s almost as if you would want another map for this with larger tile sizes, but then tie the two together in terms of camera/movement…