Million Tile Engine Beta Release

Please forget my last post.

After I retried with your latest MTE release (0v980-9), this problem does not exist.

The heightMap system stores tile images in shape objects and deforms the shape by altering it’s path, which requires Corona’s Premium Graphics in Pro or Enterprise. I’m glad Corona at least lets people test in the Simulator! That is good to know.

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 thanks for the reply,

I didn’t think it was MTE, the transparency problem was just with the tileset software I was using even though I set black to the transparent color in Tiled somehow it was still showing so I had to manually remove all the extra areas to make transparency in photoshop (for anyone whose wondering).

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:

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.

Hello Dyson, 

I am new to Corona SDK and buy your product just yesterday. According to the instructions in your documentation and reference on the forum. I want to make an RPG game like hayday but there are some issues I do not understand. 

Can you write some examples of how to use the camera functions via touch events to move (drag) map like Hayday game? 

Here is my code: 

display.setStatusBar(display.HiddenStatusBar) local mte = require("mte").createMTE() mte.loadTileSet("myTileSet","mytilesets.png") mte.toggleWorldWrapX(false) mte.toggleWorldWrapY(false) mte.loadMap("mymapfile.json") mte.setCamera({locX = 8, locY = 6}) local mapObj = mte.getMapObj() function mapObj:touch( event ) if event.phase == "began" then self.markX = self.x -- store x location of object self.markY = self.y -- store y location of object elseif event.phase == "moved" then local x = (event.x - event.xStart) + self.markX local y = (event.y - event.yStart) + self.markY self.x, self.y = x, y -- move object based on calculations above end return true end local gameLoop = function(event) mte.update() end mapObj:addEventListener( "touch", mapObj ) Runtime:addEventListener("enterFrame", gameLoop)

I want to drag the map is no longer black like the picture attached.

j5vk.png

Look forward to receiving your help 

sorry for my bad english :slight_smile:

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.

Hello kiendaden. Examples are coming eventually, for a variety of things. Another user suggested that I integrate touch scroll and punch zoom directly into MTE, and I’m looking into the possibility of that. In the meantime I recommend checking the CastleDemo sample project. You’ll find touch scroll and pinch zoom code in main.lua, starting at about line 301. Simply uncomment the code block to test it out. 

I also have a new update for everyone.

MTE 0v980-12 - https://gum.co/staO

This is a minor update correcting reported bugs.

  • Fix for MTE trying to read non-existent width and height properties of object groups in Tiled map TMX files.

  • Fix for MTE setting width and height properties of object groups to 0, causing the Simulator to hang.

  • Fix for constrainScreen causing errors if the camera is not focused on a sprite.

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 Dyson, 

Thanks for your quick reply and the example you give is great. I watched carefully about the code that you write about zooming and scrolling map. and I realized that if I use the

mte.toggleWorldWrapX(false) mte.toggleWorldWrapY(false)

 are still happening around the black when dragging the map. 

So how to solve the problem is no longer about a black background for my game only 1 single map (not wrap map). I mean the first point of the map will always be in the first position of the screen even drag the map down or right. 

Look forward to receiving guidance and your help

zmvd.png

Oh sorry about that, I completely missed the second part of your question! Just call mte.constrainCamera() after setCamera() and the camera won’t scroll into the black edges of the map anymore.

Hello Dyson,

Oh, oh, That’s great!  Thank for your quick reply :smiley:

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?