Million Tile Engine Beta Release

Hi Dyson,

This might be silly question , but i am confused with this. How Do i find the current position of the Sprite object.

Thanks,

kumar KS.

Hi kumarks,

Maybe there are better ways but you could give this a try:

local prop = mte.getSprites(sprite)

if prop then 

    print(“locX,locY :”…prop[1].locX,prop[1].locY)

end

Finding the current position is in the getSprites sample code, and other useful tools.

Hi, Dyson

I am having troubles accessing objects from Tiled that are given a type or name that can be influenced through collision handler.

I created a pot through MTE (object 1 layer following demo code) with name of pot1 and type pots, after in my code I get the object, I gave it a type because the type in Tiled wasn’t working for me either.

local potObject = mte.getObject({name = “pot1”})[1]
potObject.type = “pot”

After in my collision code I give it for the pot (the code works fine for everything else)

elseif (agro.type == “player” and hit.type == “pot”)…but I can never get it to detect the pot, been trying multiple different ways and nothing works

Hansman, collision detection in CastleDemo is handled programmatically in main.lua, on lines 95 to 106:

--DETECT OBSTACLES ------------------------------------------------------------ local obstacle = function(level, locX, locY) local detect = mte.getTileProperties({level = level, locX = locX, locY = locY}) for i = 1, #detect, 1 do if detect[i].properties then if detect[i].properties.solid and i == 1 then detect = "stop" player:pause() return detect end end end end

On the line “if detect[i].properties.solid and i == 1 then” the “and i == 1” restricts the collision detection to the first layer of the level (or the first layer containing a tile at the given location). You can check all tiles on the level by removing the “and i == 1” from the code:

--DETECT OBSTACLES ------------------------------------------------------------ local obstacle = function(level, locX, locY) local detect = mte.getTileProperties({level = level, locX = locX, locY = locY}) for i = 1, #detect, 1 do if detect[i].properties then if detect[i].properties.solid then detect = "stop" player:pause() return detect end end end end

As for the issue with the exposed culling margin at the edge of the screen, I’ll need to look at your files to find the cause. I’ll shoot you a PM with my email address if you don’t already have it. The size of the tiles doesn’t matter, the engine was designed to compensate for that automatically.

Hello Phoenixongogo,

Simply include those PNG files in your project folder where the standard-size tileset PNGs are stored. Corona will automatically load the larger images to match the screen resolutions defined in your project’s config.lua file.

Hello Kumarks,

If you created the sprite programmatically you can just access sprite.x, sprite.y, sprite.locX, and sprite.locY as you would any displayObject property. If the sprite was generated from a Tiled object you’ll have to use Phoenixongogo’s suggestion to retrieve the sprite object first.

Hello Azmar,

MTE 0v984-7 doesn’t add the object type to the sprite created by drawObjects(). I’ll add that to the current development build. You can add it by going to line 6534 of mte.lua. Beneath sprites[spriteName].bounds = nil add the following:

sprites[spriteName].type = object.type

The reason your original code wasn’t working was that you were setting type = “pot” in the Tiled object after creating the sprite from it. You would have had to set type = “pot” for the object before calling drawObjects() for that to work. The above code addition to mte.lua removes the need for all that so you can just check for type == “pot” in your collision code.

Hello I am looking to make a Zelda-Link to the Past type game, would the Million Tile Engine be able to handle a game like that? If so, what would it be good at doing and bad at doing? So when I program I can be aware of it.

Works perfectly now with that new line of code, now I am having troubles actually removing the object on touch…I did end up using the type from Tiled to get it to work properly. But when I enter collision which works fine, I try to remove the object on touch as:

mte.removeObject(“pot1”, 4)            

– 4 being my first object layer on where it was created and the “pot1” is the name from Tiled designated it, its not giving me back any errors when I do this, nothing happens…but if I change the name or layer it will give errors saying it doesn’t exist. It is detecting that it exists but does nothing.

Side note: the debug command on side says Memory: “stuff”…is that the amount of memory used? I know I read that android should keep total tiles below 1000 on screen but any direction you could send me for that memory part on what amount we should stay away from?

Now that I’m back I’ll start working through all the questions asked over the last four days. There’s been quite a bit of customer support activity, so it may take me a little bit to reach a specific question, but I’ll get there.

Kumarks, if you could email me your project, or a representative example of the problem you’re having, I’ll look into it for you. I need to see your code in order to troubleshoot this problem.

Azmar, running a game like Link to the Past would be trivial for MTE. I can’t think of anything in that game the engine would have trouble with. It really is one of those best-case scenarios I planned for from the beginning; a retro 16-bit style RPG. One thing to keep in mind however is that MTE is a tile engine, it does not handle things like dialog and combat mechanics; that will be up to you.

The removeObject() function removes a Tiled object from the map data. It sounds to me like you really want to remove the sprite representing the object. I know this can get confusing what with Corona using the term displayObjects for onscreen sprites and images, and Tiled using Object for, well, Tiled Objects. Any MTE function with the word Object in it is meant to manipulate Tiled object data in the map file. What you’ll want to do in this case is retrieve the sprite using mte.getSprites({name = “pot1”}) and then destroy it. Keep in mind that getSprites() always returns a table, so in this case the object will be at index 1 of that table.

I would like to say I solved this by now, but sadly still having troubles with it :frowning: I still have it in Tiled as an inserted object tile (layer 4 with identifier name = pot1 and type pot

local potObject = mte.getSprites({name = “pot1”})
print(potObject)                                                         – show that I got something
mte.removeSprite(potObject[1], true)

–mte.removeObject(potObject[1], 4)

I’m assuming I should be calling removeSprite but whenever I try to do this it keeps throwing me an error: attempt to index local ‘sprite’ a nil value mte.lua:1241

I understand now that before I was just removing the object box and not the actual image

Thank you for the very quick response! As far as combat mechanics and dialog, should I be building those from scratch or are there other 3rd party tools that help support that? I got the Physics Editor and if from scratch Corona SDK can handle that?

Combat mechanics you’ll probably have to build from scratch, as it’s the kind of thing that will be very specific to your game versus everyone else’s. 

For dialog you could try looking for examples in the code exchange, http://code.coronalabs.com, or ask for help here on the forums. Dialog is something just about everyone who’s built an RPG or Adventure game will have had to tackle. As an engine developer I haven’t looked into it much myself. Other than that I would check out Widget Candy, http://www.x-pressive.com/WidgetCandy_Corona/. For Zelda it may be overkill, but I imagine it could be quite useful for RPG’s with stats and equipment screens and the like. They also sell Particle Candy, which is pretty popular for handling effects, http://www.x-pressive.com.

IS it possible to build a map dynamically?  I noticed that all of the demos load maps rather than use anything dynamically.

I mainly bought this as a basis for a rogue-like game with dynamically generated levels, rather than loaded levels.

Is this possible?

Thanks!

Dyson, nice work on the map stitching!

I bought MTE in the early days and beside playing with your demos, I haven’t had time to start making a game with it yet unfortunately.

However the more time that goes by, the more I see MTE evolve. Can’t wait to eventually use it one day!

PS: what happened to the raycasting engine? Is that still in the works?

Hope you are keeping well!

Sure, ookami, you can dynamically generate maps if you want. You’ll need to create an empty map template in tiled so MTE can import the tilesets you’ll be using. What you do is create a map file in Tiled, add your tilesets to it, and place one tile from each set somewhere on the map. In the corner, for example. You can remove or overwrite those tiles later. Ideally you should decide on the number of map layers you need ahead of time, and the width and height of the map. 

Once that is loaded you can fill the empty layers with data however you like. MTE does include a perlin noise function which you may find useful. I recommend checking out the Sledge sample project. It loads an empty map file and uses perlin noise to procedurally generate terrain.

Thanks for the Gremlin, I look forward to seeing what you come up with! The raycasting engine was a victim of limited time, I’m afraid. I’d love to keep working on it, but for now it’s relegated to smoldering away on the back burner.

I’ve had a lot of people report that their physics object sprites are getting caught on the edges where different map tiles meet. This video demonstrates what I believe to be the best solution to the problem so far- to bevel the edges of the physics body- which I first saw mentioned by rgreene_dub elsewhere in the MTE forum. 

I recommend watching this video on youtube.com, with the player enlarged, at 480p or above so that you can see the smaller details I talk about.

[media]https://www.youtube.com/watch?v=OMiQPYFJCWw[/media]

Would you have any interest in teaming up on the raycasting engine project? I don’t like to hear that it is smouldering away. I want it burning dude! :slight_smile: If your interested, lets talk.

PS: I’m Danny, ex Corona labs. We spoke about this project previously if you recall :slight_smile:

Thanks for the reply Dyson.

Looking at some of the examples, I wondered if that might be the answer.  So, I will need to load a blank map, then procedurally fill it based dungeon that I generate.  I’m assuming if I want to use that 3D look - which is really cool by the way - that I’ll need to take that into account and fill multiple layers, correct?

Also, is it possible to change tilesheets on the fly?  All tilesheets would basically be identical other than the textures themselves, so a door in one tilesheet would match a door in all tilesheets.

Basically, when I generate a dungeon, I want to randomly choose the theme - cave, dungeon, lava, etc.  Is it possible to have one blank map and dynamically change the tilesheet, or will I need to have map for each tilesheet?

Thanks!

Hi Everyone,

This is my code ,

mte.moveSpriteTo 

{

sprite = self._BombSprite, 

time = 0,

– easing = “linear”,

levelPosX = params.x,

levelPosY = params.y,

onComplete = function ()

self._BombSprite.isVisible = true

print(self._BombSprite.isMoving)

mte.moveSpriteTo 

{

sprite = self._BombSprite, 

time = self:getTransitionConstant(),

– easing = “linear”,

levelPosX = params.Destx,

levelPosY = params.Desty,

onComplete = function ()

print(“In onComplete”)

self._BombSprite.isVisible = false

end

}

end

}

At first both the onComplete Function is executing , but later on for the second time on wards the second onComplete Function  its not at all working , whats the problem. Is anything wrong with the code. 

Thanks,

kumar KS.

I’ll have to look into whether I even have time to team up on it, Danny. I’m in the middle of a job hunt and things are hectic. I’ll be in a better position to do this sort of thing in a month or two, hopefully.

Ookami, you can use the loadTileSet function to overwrite one tileset with another, provided the images have the same resolution and the same number of tiles. You can even do this on a map you’ve already loaded if you want and call refresh() to redraw using the new tiles. 

@dyson122 i can understand your situation. I would be happy to work away at it alone while you are busy, learn the source, improve and add features as I go along.

Then when you have time we can sync up. If that suits you then I am game :slight_smile:

If not, I can naturally hold out until you are ready. Just thought I would offer an alternative.

Cheers