Million Tile Engine Beta Release

MTE 0v984-7 - https://gumroad.com/l/staO/

This update expands on some of the content and features included in the last update and brings the Million Tile Engine up to date with current Corona SDK API’s. 

  • All MTE function calls now use the new 0-1 range. All code in all samples has been refactored to use the new 0-1 color range instead of the old 0-255 color range. If you’ve used any of MTE’s reserved Tiled properties you’ll have to convert them over to the 0-1 range. 

  • The pos table parameter of constrainCamera() is now levelPos. 

  • MTE’s touchScroll and pinchZoom routines now fire off an event named mteTouchScrollPinchZoom when they receive touch input. You can use this event and the data it passes to you to trigger your own code, for example by stopping gameplay when the map is being dragged. 

  • CastleDemo now includes mte.enablePinchZoom() and mte.enableTouchScroll(), commented out at the bottom of main.lua, instead of the old external code. The sample project also demonstrates the new mteTouchScrollPinchZoom event.

  • RotateConstrainStoryboard is now RotateConstrainComposer; it now uses Corona’s new Composer library. The Composer library is available in the current public build of Corona SDK.

  • IsometricStoryboard is now IsometricComposer.

I’ve also made a number of minor bug fixes to the engine. Work on the video tutorials continues, as does work on Map Stitching. 

Enjoy!

Speaking of the sample projects, I did a test recording of one of them and could use feedback and suggestions. Is it easy enough to follow? How is the pacing and presentation? Is the text in the video legible? The tutorial is hosted on youtube at the moment because it seemed to be the most convenient place to hang a large 720p video, but is another distribution method preferable? Let me know what you think.

I highly recommend clicking the YOUTUBE button on this video and watching it in 720p HD on youtube.comhttps://www.youtube.com/watch?v=WC_ITk9UiSI

The tutorial text: https://docs.google.com/document/d/1X0y_FnTmr1Rc1ojhJvYSoQmYt1U1aPa-zVzE0-m4zuM/edit?usp=sharing

I’ve written up the next two tutorials as well. The three of them are really three parts of an overall getting started tutorial.

Part2: https://docs.google.com/document/d/1AA7i6xqC1oixeaXoa1Gk-NNUqtpdYXHj9CdahPV0Qyg/edit?usp=sharing

Part3: https://docs.google.com/document/d/1u1Ik19DPGR1eFS1eUtjfv2JX_BWH0FRq-_Xfzo5YmlQ/edit?usp=sharing

Hey dyson,

Just bought it, I love the way you using for collision detection in sonic project, it solved my long ago riddle to figure out platform detection with optimized performance! 

Thanks for your excellent work!   :slight_smile:

Hi Dyson,

isSimulator = system.getInfo(“environment”) == “simulator”

application = {

content = {

width = 640,

height = 960, 

scale = “letterBox”,

fps = 60,

–[[

        imageSuffix = {

   ["@2x"] = 2,

}

–]]

},

This s my Config.lua, the Total Tiles count when there is lag is around 800. More over now i changed the fps in config to 60, so its very much better than compared to previous . But still i couldn’t get the smoothness in my project. I am using three layers in my map. Tile size is 32x32 and the map size is  1760 x 1248. 

In my original project i am using spine , when my character moves, at that time fps value is not printing in the screen, but when there is no movement its printing.  Every problem mostly  happens inside the constrain camera movement. I hope i will get a good solution.

Thanks,

Kumar KS. 

I’m glad the Sonic sample project helped you Phoenixongogo! Coding a custom movement engine is harder than using Corona’s built in physics, but it definitely has its advantages in certain situations.

Hi Dyson,

I’m in the process of upgrading from version 958 to 984 and hit a problem with loadMap that’s rather odd.

I have a fairly big map that’s a little to slow to load, so my solution has been to load it in scene 1 where I create my menu and its under the menu out of sight (I know preloadMap would be better here).  When I go to the next scene to load the map it’s in memory and loads very quickly no matter how often I switch back and forth from the menu or other scenes.  When I moved to 984 the loading went back to the long load time, it doesn’t seem to stay in memory across scenes now.  I’ve tried preload but that’s the same.  

I thought that perhaps my code was the issue somehow but I then tried the same thing using your sample project isometricstoryboard. In this I replaced your map with mine and tested this code using version 958 and then 984 and it gave the same issue.  I loaded the map main.lua first time and then again in scene to replicate the effect.  Below are the timings for both versions to demonstrate:

here it is for version 0v958

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 2    

Reference Layer: 1    

Map Load Time(ms): 2505.475    

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 3    

Reference Layer: 1    

Map Load Time(ms): 31.309    

 

 

And here it is for version 0v984

 

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 2    

Reference Layer: 1    

Map Load Time(ms): 2688.818    

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 2    

Reference Layer: 1    

Map Load Time(ms): 2513.703    

My thoughts on how preloadMap would help is that I could use that in an early scene when the user is doing other things and doesn’t notice the load time.  I can see preloadMap working on version 984 in your example code called loadMap but that’s all happening in the main.lua and there’s not an example of this using storyboard.

Any ideas why this has changed and how I can recover the feature?

Thanks

Apologies, I was using 984-1 rather than the latest 984-7.  Trouble is that now the map loading time has increased as well for some reason.

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 2    

Reference Layer: 1    

Map Load Time(ms): 4135.575    

map/map1.json loaded    

World Size X: 416    

World Size Y: 500    

Levels: 2    

Reference Layer: 1    

Map Load Time(ms): 3985.57    

Hmm, my first thought was that something had slipped out of json map support, and after that I thought it had to do with reloading a map in the same scene, but neither of them appears to cause the problem you’re having. Could you email me your project or the Isometric sample you modified to run your map, along with the map itself? 

Hi Dyson,

thanks for resolving this.  Just for other’s benefit I thought I’d add your comments here on this that resolved the issue which was down to my lack of expertise:

"You’re seeing a side-effect of how MTE instances work. Instances are entirely isolated from each other. In main.lua you create an instance of MTE (using createMTE()) and load the map. In scene.lua you create a NEW instance of MTE and load the map again. You can fix the problem by making the following change in main.lua:

 

local composer = require(“composer”)

–local mte = require(“MTE.mte”).createMTE()      --commented out/removed

local myData = require(“mydata”)

myData.mte = require(“MTE.mte”).createMTE()

 

And change scene.lua as well to load the MTE instance from myData:

 

local composer = require( “composer” )

local scene = composer.newScene()

–local mte = require(“MTE.mte”).createMTE()      --commented out/removed

local json = require (“json”)

local myData = require (“mydata”)

local mte = myData.mte

I’ve also been having some trouble with getting zoom out (e.g. less than 1) to work on a map within a different scene.  I have a section where the map first loads and I wanted to set it to zoomed out at the start.  I’ve added in your code for pinch zoom in the same scene.lua file so the user could then move the map around from the initial zoom level.

So at the start I’m using mte.zoom(…) and later using the touch controls.  As part of setting up the touch controls you may wish to set in the enterScene section min and max zoom levels for instance mte.maxZoom = 4,  mte.minZoom = 1.  

This was what I eventually found was stopping me.  I couldn’t zoom out because that would be less than 1 and this was overriding the mte.zoom(…) command.  I hadn’t thought to try zooming bigger than 1 which may have helped me spot this sooner.

so just to note that mte.maxZoom and mte.minZoom constrain all zooming commands within a file, not just the pinchzoom controls.

Azmar, MTE converts any Tiled object into a Sprite if it has properties defining its visual appearance. For example, if you make an ellipse object and give it a lineWidth property that ellipse will be drawn as a white shape with the lineWidth specified. That visible shape is a sprite. If you set the name of the object in Tiled the sprite will be assigned the same name, and you can retrieve it with getSprites({name = name}). That said, the engine doesn’t have any built-in functions for created fully animated sprites from Tiled Objects. 

You’ll have to set the category bits and mask bits of your physics objects on each layer so that they only interact with their current layer. You can see an example of category bits and mask bits in use in the Platformer - Angled PHYSICS 0v984-7 sample project, in the AngledPhysics2.tmx and AngledPhysics3.tmx maps. These are features native to Corona Labs’ physics implementation.

The lighting system is resource intensive. If you’re using physics objects and obstacles you should look into physics.castRay() http://docs.coronalabs.com/api/library/physics/rayCast.html as an alternative. 

Kumarks, the FPS value not printing at any time indicates an error is occurring. I suggest you start Corona Simulator by clicking on Corona Terminal; this will start the simulator and also display a terminal it will use to print errors and other debug messages. If you’d like to email your project to me I’ll have a look at it and see if I can’t figure out why its running so poorly for you.

WELL, it has been quite a while it seems since I updated MTE and I haven’t been quite as present here as I have been in the past. The reason for this is my ongoing job hunt and the demands it places on my time. That said, I have not been idle either! When faced with time constraints I’ll usually spend less time talking to you folks and more of the time on coding or working on customer support issues.

So, what have I been up to? I’ve been hard at work on MTE 0v990. Changes and additions so far:

  • forceDefaultPhysics layer property: if true, all tiles on the layer will use the default physics data stored in mte.physicsData.
  • managePhysicsStates MTE parameter: boolean enabling or disabling MTE’s management of sprite physics states. Setting mte.managePhysicsStates = false will prevent MTE from overriding sprite.isAwake and sprite.isBodyActive for ALL sprites.
  • managePhysicsStates sprite parameter: boolean setting whether MTE manages the physics state of the sprite. Setting sprite.managePhysicsStates = false will prevent MTE from overriding sprite.isAwake and sprite.isBodyActive for that sprite.
  • physicsSourceScale tileset property: used to set the scaleFactor of PhysicsEditor data imported into MTE. Applies to all tiles in the tileset.
  • physicsSourceScale tile property: used to set the scaleFactor of PhysicsEditor data imported into MTE. Applies only to that tile.
  • Support for Tiled Object rotation in Tiled v0.9.1-243.
  • mte.expandMapBounds(parameters): Increases the size of the map in any direction.
  • mte.appendMap(src, dir, locX, locY, layer): Inserts data from the a map file into the current map, adding layers and expanding the map bounds if necessary.
  • mte.drawObjects now takes a single boolean argument, new, which sets whether the function should redraw all objects or only draw new objects, for example the objects added by appendMap.
  • Fixed offscreenCulling: sprites will no longer fall through the world under certain circumstances.
  • Tiled Objects with physics bodies attached will no longer switch off while they are only half-way off the screen.
  • Tiled Object Culling: setting the cull property of the object or the cullObjects property of the object layer will cull those objects just as MTE culls tiles!

At the moment I’m working on improved culling for large tiles- tiles larger than the tile size of the map- so they aren’t culled before fully leaving the screen. After that I’ll have to do a few passes to make sure all these new systems are working together. 

Ah yes, I’ll update the docs to explicitly state that maxZoom and minZoom effect all zoom operations. 

A few updates on what I’m working on; one thing I love about Lua is how it handles tables and arrays. There are no arrays; just tables disguised as them. So where another language would balk at a negative table index, Lua shrugs and takes it in stride. This has tremendously simplified the task at hand! I would have had to either restrict map expansion to only the right and bottom edges so the indexes remain positive, or maintain four seperate arrays for each quadrant around the origin 0,0. Instead I can just expand in every direction like a plague. A plague of maps. 

I was able to append a map onto another today with the current state of the code, but there’s still plenty to do to get the nuts and bolts of the system set up. That’ll come next week. This is probably going to be a longer three or four week update cycle.

I’ll keep everyone informed on progress moving forward.

Hi Dyson,

just an idea you might be interested at some point down the line.  When I setup pinch scroll zoom code for my large map (before I started using yours) I added a feature that a double tap on the screen centred back on the player and reset the zoom to the starting zoom.  It meant I could scroll away a long distance without losing myself.  It may be too specific a feature though, but thought I’d share the idea. 

Hello!

Is this engine graphics 2.0 compatable?  I’d like to create a game similar to the NES and/or SNES Zelda game… your product seems like a good choice.  Let me know.

Hello Scottadelman,

Yes, the current version of MTE is compatible with graphics 2.0. Let me know if you have any other questions. It’s always great to see another NES / SNES Zelda fan- games like that were among the original impetus for MTE’s creation.

I have a important question because I am completely new ^^; I would really prefer if you was to contact me through email: nataszbaker@gmail.com, because I am sure no one else will benefit from my questions. 

What programming language does this use and can it only be used for mobile games? 

I like the idea, but it’s too specific. This is something other devs can implement easily enough on their own.

Hi dyson,

I’m wondering to know, how could we build the tile system which players can add/remove tiles dynamically like Terraria with MTE?

It seems like besides “setTileProperties” we also need an API like “changeTile”.

Do you have any tricks?

Hello phoenixongogo,

You’re looking for updateTile()  :wink:

updateTile(parameters)

Changes a map tile.

 

parameters:    (table) Describes the change to be made and where.

 

Format for parameters

 

locX:                The X coordinate of the tile’s location.

 

locY:                The Y coordinate of the tile’s location.

 

layer:               (number) A layer in the tile map.

 

tile:                   (optional) The new tile index. Use 0 to remove the tile from the map and display.

 

levelPosX:       (optional) The X coordinate of the tile’s position.

 

levelPosY:       (optional) The Y coordinate of the tile’s position.

           

           

Example:         mte.updateTile({locX = 21, locY = 19, tile = 7, layer = 1})