Million Tile Engine Beta Release

Two weeks down and the first and second scenes of the sidescroller/platformer sample project are finished. The first scene in my previous post is comprised of a simple map in which tiles are either completely solid or completely passable, and the collision detection and movement code needed for the player sprite to act accordingly.

This newly completed second scene demonstrates one possible way to detect and collide with sloped surfaces; tiles can be completely solid or completely passable, or they can have a line segment transcribing them defined in tile properties. Upon a coliision the code calculates whether the player sprite is intersecting this imaginary line and moves it accordingly.

[media]http://www.youtube.com/watch?v=C5l-4aRRV2c[/media]

I’ll be working on the third, last scene of the sample project next week. This last scene will be an extension of the second; each individual tile will be very large, but they will contain many collide-able surfaces defined in their properties. 

The next update to MTE is also in the works, thanks in no small part to the optimizations involved in making platformer movement work fluidly at 60fps on older devices. While it is perfectly possible to make a platforming game with the current release, the next release will incorporate  numerous performance improvements and a few helpful ease-of-use tweaks.

I’ve been playing around with this and so far like what I’ve found, but can’t seem to get it to do something I think is simple. I want to scroll the viewport as a user moves their finger ( as well as use velocity scrolling ).

I’ve got the velocity, etc., but can’t seem to get the mte window to move correctly. It appears I can either call mte.goto() or mte.moveCameraTo(). 

moveCameraTo is throwing errors that honestly don’t make sense given my simply map so I’ve been focused on goto. It appears goto only moves by the size of my grid? Is that correct? So if I want to shift the viewport by 10 pixels and my grid is 32 I have to move by 32?

Should I be using moveCamera?

This is for a top down 2D strategy type game, not a scroller.

Any suggestions would be appreciated.

MTE’s movement functions move the map relative to the native size of the map. If your tiles are 32x32, you call goto() with a blockScale of 64x64, and you call moveCamera(2,0) the map will appear to move 4 pixels across the screen. I’d never thought of it from the perspective of moving the map with a finger swipe, but now that you mention it you would have to compensate for this difference.

I threw something together to see just what might be necessary to scroll a map via touch. This is just one way to go about doing it. You’re correct that moveCamera would be best in this situation. Anytime you need to move the camera or a sprite on a per-frame basis, moveCamera() and moveSprite() are the preferred functions. moveCameraTo() and moveSpriteTo() are meant for longer motions taking many frames, during which the movement can’t be modified. None of the movement functions will appear to do anything unless you call mte.update() in an enterFrame event.

local scaleFactor = blockScale / 32 --The ratio of the blockScale to the native size of your tiles local startX, startY, currentX, currentY local isDragging = false local drag = function(event) if event.phase == "began" then startX = event.x startY = event.y currentX = event.x currentY = event.y isDragging = true end if event.phase == "moved" then currentX = event.x currentY = event.y end if event.phase == "ended" or event.phase == "cancelled" then startX, startY = nil, nil currentX, currentY = nil, nil isDragging = false end end local gameLoop = function(event) if isDragging then mte.moveCamera((startX - currentX) / scaleFactor, (startY - currentY) / scaleFactor) startX = currentX startY = currentY end mte.update() end Runtime:addEventListener("touch", drag) Runtime:addEventListener("enterFrame", gameLoop)

And here’s the result, using the platformer test level because it was on hand. Sorry about the weird compression artifacts. The ground texture really seems to confuse Quicktime.

[media]http://www.youtube.com/watch?v=wwhuMGtgU2g[/media]

Speaking of the platformer/sidescroller sample project, it’s coming along nicely. When finished there will be three little test maps, each in a seperate storyboard scene, each demonstrating more complicated movement and collision detection then the last. The first map will feature collision detection against entire tiles- each tile is either completely solid or completely passable. That is just about finished and you can see it in the video below. The second map will add sloped ground to the mix. The third will demonstrate how to go about making freeform ground surfaces within a tile using tile properties. 

[media]http://www.youtube.com/watch?v=jMqPHjnKhYw[/media]

I’ve been making incremental improvements to the Million Tile Engine as well. The next update will bring greatly improved convert() performance. 

Thanks for the detailed response. I was just about to post that I figured out moveCamera was the way to go and got it working. I was missing the call to update on enterFrame.

Tried to buy but apparently SellBox sucks. The PayPal window never shows up. 

You may be missing more sales – not everyone says something when the payment processor doesn’t work,

 Jay

Jay, do you use Chrome? It silently blocks all pop-ups regardless of trust level. (?!) Basically you just need to allow Paypal in this instance; I believe there is a little red icon somewhere on the right side of the URL box.

Thanks for bringing this to my attention, Jay. A cursory internet search shows others having problems buying through Sellbox on Chrome and occasionally Firefox as well. Not good news given the popularity of these browsers. I’ll look into the problem and see if I can find another more Chrome/FF-friendly storefront. 

In the meantime I’d be interested to know whether richard9’s suggestion works. 

Just tried it again and it works for me (manually re-enabling the specific popup). A real bummer that there’s no popup notification on Chrome though.

No, I’m using Safari on my Mac. Just tried again in case it was a temporary glitch – no joy.

 Jay

I couldn’t make it work with Safari either. I’ve fired off an email to Sellbox. In the meantime I’ll be looking for an alternative storefront.

Hi

 Is any schedule to support isometric tiles  ?

That will be pretty cool

For payment processing I’ve heard good thins about gumroad.com - and apparently they have a system for sending out software updates. Not used them myself but heard good things about them.

Thanks for the suggestion binarymoon. I’ve sent inquiries about software updates to both Gumroad and Quixly. Gumroad is interesting in that it takes credit card payments while Quixly takes PayPal. I can see advantages and disadvantages to both, but software updates will probably be the deciding factor.

EDIT: Actually, whether they work in all popular web browsers will be the deciding factor.

MTE is now available through Gumroad! The relevant links have been updated. 

http://gum.co/staO

Codingcake: I do plan on adding isometric tile support, however given the complexity of the addition I have as yet no idea how long it will take to complete. I’ll have a better idea after I finish the current update / platforming sample and begin working on it.

Quick question - I’ve been looking at the Open Source Corona Tiled library that a couple of guys are developing. However I am interested in the MTE. I need to use A* pathfinding and for this I need a 2D array of the tiles. Currently CT doesn’t have that built into the data structure so was wandering whether this is the case for MTE?

Quick synopsis - I’ve made a simple tile engine in a 2D array, storing the tile and relevant properties. A* library then runs through this 2D array to calculate shortest path. I do however want the luxury of maps designed via Tiled - hence why I’m lloking at CT and MTE.

Any answers would be appreciated…

I’m actually in the process of doing this right now. This isn’t the most efficient approach, but what I’ve done so far is take the map and create an pathing array:

[lua] 

local map = mte.getMap() 

     mapArray ={}

        local mapH  = map.height

        local mapW = map.width

        for i = 1, mapH do

                mapArray[i -1] = {}

            for j = 1, mapW do

                mapArray[i-1][j-1]=1

            end 

            

        end 

[lua]

Now I set a flag in the object layer when a path is clear so the first step basically sets everything as non traversable. Next step run through the object layer setting values appropriately. My object layer items have x/y so it is simple:

[lua]

local objLayer = mte.getObject({ layer=OBJ_LAYER})

        for x = 1, #objLayer do

            mapArray[objLayer[x].x][objLayer[x].y] =0

        end

[lua]

Note that I’ve just set this up and haven’t tested it yet :slight_smile:

I’ve got A* working perfectly - however it relies on having that 2D array structure. I’m assuming that, from your comments, MTE doesn’t provide this structure, so have to do a workaround as I’m doing with Corona Tiled?

Thanks for the info…

Hello SegaBoy,

You can access the 2D world arrays using mte.getMap(). For example:

local mapData = mte.getMap() print(mapData.layers[4].world[7][15]) --access tile index at (7,15) on layer 4

Regarding tiles for A* and other pathfinding… (I’m using Lime for my current project, but I don’t think the tile engine matters in this case.)

I’m not using A*, but the Jumper library from Roland Yonaba (https://github.com/Yonaba/Jumper) and it wants a 2D array to know where the path can be.

In Tiled I created a tile layer that’s at the bottom of the list (tiles in there are drawn first, everything else is drawn on top of those) and named it walkable.

On that layer I just placed tiles in every location that was NOT walkable – walls, crates, etc. I ended up with a layer of lots of zeros and some other things. Jumper sees zeros as empty locations where it can place the path.

When you export that layer as Lua you get a table of data that’s easy to change into what Jumper needs:

Original:

[lua]

data = {

1,0,0,0,1,

1,1,0,0,1,

1,1,0,0,0

} [/lua]

New:

[lua]

data = {

{1,0,0,0,1},

{1,1,0,0,1},

{1,1,0,0,0}

} [/lua]

Creating a utility to tweak the exported data automatically wouldn’t be hard, but doing it by hand (even on a large map) takes less than a minute.

 Jay

Hi Jay - thanks for the info.

The process I have at the moment is to build a simple 2D array and add attributes to the tile - A* then checks tiles and looks for any tiles with .isObstacle = true to discover the shortest path without obstacles.

I’m planning to have plenty of logic in the environment (interactive items, scent based pathfinding, etc…), but trying to build maps by hand is an absolute nightmare - hence why I want to use Tiled and a tiling engine that will allow all of this.

@dyson122 - thanks for the info, that pretty much sells MTE for me :slight_smile: