Million Tile Engine Beta Release

Thanks, Txarly! Physics really opens up the realm of possibilities using Corona and MTE. I’m still on track for a friday release containing the work completed thus far.

Thanks, John! I don’t think I’ve done anything with .Net directly, but I did tinker with Microsoft XNA a few years ago and quite enjoyed using it. It’s a shame Microsoft hasn’t seen the value in continuing to support and develop the framework.

The Million Tile Engine continues to evolve as developer feedback comes in, so if either of you see an area in need of improvement or a feature you’d like included, feel free to let me know.

Dyson… awesome engine! I brought it the other day and have only run the demos so far. they run really well on Google Nexus 7.

Thanks so much!

The demos are great - there are several ideas that I want to develop and the engine is just a perfect fit for all of them!

I can’t wait for the isometric integration (looks amazing) and physics.

What an awesome contribution to the Corona community!

I’ll just say what everyone is thinking: When is Corona going to start paying Dyson to work full time.  haha

@cjc83486 - True.

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?

lol … Whatever happens please just keep up the great work on MTE! :stuck_out_tongue:

I have just started to use this all today. I am kind of stuck. Is there going to be some youtube tutorial? Things don’t seem to ba making much sense to me. I am reading the “MTE Tilesets, Map Structure, Getting Started.pdf” document.

The tileset that is exported from TexturePacker is different in layout to my original tileset. In GIMP I have things nicely laid out and can see groups of tiles. In TexturePacker it seems to just place my blocks at random so when I open that tileset in Tiled… I see a random flipping collection of blocks that are totally unusable.

What am I doing wrong here? I really need to see in Tiled my tiles in the same order as they were in GIMP.

Ah yes, TexturePacker can do some strange things to the orders of tiles. I’m assuming here that you used Gimp to slice your tileset into individual tiles so that TexturePacker could extrude them for you and output a new tileset. Three things to keep in mind are the naming of your tiles, the algorithm setting in TexturePacker, and the max size settings in TexturePacker.

Usually Gimp’s slice command names tiles as slice_0_0, slice_0_1 and so on. This is a format TexturePacker works well with. However if the names are in the format of slice1, slice 2… slice10, you’ll run into a problem. In this case slice10 will often immediately follow slice1. The solution is to pad the numbers with zeroes so that slice1 is slice01, slice2 is slice02, and so forth.

In TexturePacker, under Layout, you want the Algorithm set to Basic and the Sort By set to Name. Further down you should make sure Allow Rotation and Enable Auto Alias are unchecked, and Trim is set to None.

TexturePacker will fill the allotted Max Size from left to right, top to bottom. If fewer tiles will fit across the image than in your source tileset, the row will be truncated, as will the next and the next in a cascading fashion until your tiles appear scrambled. The solution is to alter your Max Size settings until everything fits. Count the number of tiles in one row of your source tileset and then check the number of tiles in one row in TexturePacker. If Fewer tiles fit in a row in TexturePacker than increase the Max Size W: setting until the correct number fits. Do the opposite if too many tiles are present in the row. Eventually everything should snap into place as it should be.

So awesome.

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.

Don’t worry nicholasclayg, physics support is coming! I’ve finished working on the functionality to be included in the Friday release and I’m moved on to converting some of the samples. The update will include separate Physics versions of the Platformer - Basic and Platformer - Angle sample projects. The physics versions of Sonic Finale and CastleDemo will come in a later update as I flesh out the physics integration. 

sweeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeet.

Thanks for that Dyson. I kinda figured that out myself last evening. It seems that GIMP doesn’t have any method of padding the names with zeros and I have 512 tiles currently. Instead of manually renaming 512 tiles (yawnnnn) I figured I better make a program to do the tedious work for me.

I made a program last evening in VB.Net and it works really well so now my frustration level is back to it’s normal high level :slight_smile:

I am guessing that others have this issue as well? If so I am happy to share my program.

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…

I’ve used this powershell script to do the same:

########################################################### # AUTHOR : Marius @ Hican - http://www.hican.nl - @hicannl # DATE : 23-04-2012 # COMMENT : This script renames all .jpg files to the # name of the .jpg parent folder recursively, # extended with an increasing number. # Put the script in the root of the folders' # parent folder. # NOTE: This script can also be used for renaming # other / multiple files, just adjust the filter! ########################################################### $path = Split-Path -parent $MyInvocation.MyCommand.Definition Function renameFiles { # Loop through all directories -Recurse $dirs = dir $path | Where { $\_.psIsContainer -eq $true } #Foreach ($dir In $dirs) #{ # Set default value for addition to file name $i = 00222 # $newdir = $dir.name + "\_" $Invocation = (Get-Variable MyInvocation -Scope 1).Value $dir = Split-Path $Invocation.MyCommand.Path "current dir is $dir" # Search for the files set in the filter (\*.jpg in this case) $files = Get-ChildItem -Path $dir -Filter \*.png | sort -property Name -descending Foreach ($file In $files) #-Recurse { # Check if a file exists If ($file) { # Split the name and rename it to the parent folder $split = $file.name.split("Submarine\_A\_") # $replace = $split[0] -Replace $split[0],($i + ".png") $replace = "Submarine\_A\_00" + $i + ".png" # Trim spaces and rename the file $image\_string = $file.fullname.ToString().Trim() "$split renamed to $replace" Rename-Item "$image\_string" "$replace" $i++ } } #} } # RUN SCRIPT renameFiles "SCRIPT FINISHED"

Nice script :slight_smile:

Alright, I ran a few tests and found that MTE works quite well with the ultimate config.lua file, even with it’s variable width and height parameters. Dynamic content scaling works properly as well. The easiest way to match the height of your level to the height of the screen is to represent the height in number of tiles and go from there. For example, if you always want the display area to be ~10 tiles in height;

local blockScale = display.viewableContentHeight / 10 --tiles mte.goto({ locX = 53, locY = 40, blockScale = blockScale})

When you call goto() MTE creates a master group containing groups for each of the layers, each of which contains the tile display objects for your map. It then manages their positions as you send movement commands, performing culling and it’s other functions on them.

Optimum tile sizes become less important when the engine scales them for you, but I personally prefer sticking to the tried and true 32 x 32 or 64 x 64 pixel tiles, sometimes a little larger or smaller, always divisible by 2 (or 4 if possible). Most of the sample projects included with MTE use 32x32 tiles. 

At the moment backgrounds are assembled from tiles. You can scale those tiles up and apply a parallax effect to the layers to produce the desired results, but you are limited to tiles of the same native resolution as the rest of the map. I will add more flexibility to address this through updates, though I don’t have a firm ETA on that.

A technique I use in the platforming sample projects is to take a screen capture of a background layer in Tiled, create a nice clean PNG of the whole layer, and load that as a sprite, however this does not efficiently use texture memory and the possible size is limited to the max texture size of the devices (1024x1024 or 2048x2048).

MTE v0.844 - http://gum.co/staO

The Million Tile Engine grows ever more feature-rich! The plan moving forward from 0.820 was to release the next two mega-features, Physics and Isometric Maps, in two huge updates spaced many months apart. This plan lacked flexibility. The new plan is to release these new features incrementally as they are ready so that I can respond to developer feedback and address reported bugs.

With MTE version 0.844, layers, tiles, and objects can have physics properties used by the engine to create physics bodies automatically when a map loads. This significantly streamlines the process of creating collision detection for a wide variety of game genres and reduces the complexity of code required from the developer.

The engine handles physics body creation intelligently and manages their states as the map view moves. Static tiles are created and culled. Dynamic bodies fall and bounce and roll until they leave the map view, at which point they go to sleep and wait for the camera to return. Add tiles to a map which transform themselves into sprites, or place Tiled Objects with pixel-perfect precision to create platforms and terrain free from the positional constraints of the tile grid. 

A good place to start is the Reserved Tiled Properties and the API documentation. There are many new properties and function calls to see. Follow up with a gander at the “Platformer - Angled PHYSICS” sample project, see how simple it’s code has become in comparison to it’s non-physics predecessor. This sample includes two slightly different maps, one standard, another showing off collision filtering between map layers. It’s a lot of fun to watch and move through.

This is not the end of the work on Physics. I’ll be looking forward to hearing what you- the developers- still need, what you would like to see added. One thing I know already: multi-body objects. You can already create these from sprites, but they will be coming to Tiled properties in one form or another as well.

As Physics fleshes out I’ll start looking more towards the second mega-feature; Isometric Maps, and a few more exotic treats I’ve teased in this forum thread.

Enjoy!

anyone have a sample project they could post showing now to use MTE with dynamic image selection - I have a support email question to dyson122 but depending on his availability if someone could post I could start looking at…in particular:

  • how many tiler maps/json files are required (just one, or one for each resolution?)

  • what is the code to setup the map (e.g. what json file and PNG file names do you refer to)

  • config.lua extract just to see what you have

  • so ideally the smallest little sample that when you change what device you’re viewing from it starts accessing the higher resolution tile images to create the map