Dusk Engine

After many, many pages of comments on the original forum post, the Dusk Engine is now live on GitHub.
 
From the readme:
 
The Dusk Engine (concept version named CoronaTiled; pre-beta named Ceramic Tile Engine) is a fully featured game engine for Corona SDK. It’s designed to help you “weed out” extra code for level creation and let you focus on the game mechanics, instead of the level makeup.  
 
That pretty much sums up what Dusk is.
 
You can get it here: https://github.com/GymbylCoding/Dusk-Engine
 
Documentation can be found here: https://github.com/GymbylCoding/DuskEngineDocs
 

  • Caleb

Someone replace the Lime forum with this in the Tools & Services forum group!!!

Great, just dowloaded this will try and make something tonight. Thanks!

Everything looks amazing with the new engine! Only my second week into corona and lua, after testing your old engine I am trying to bring everything over from my old game with the new engine. When I load up my map and insert it into the gui, only the bottom layer stays on the map but any multiple layers in the .json file all fall off the screen right when I start the program. I tried making them static in the tiled program (the other layers), or insert each layer into the back.gui but those did not work.

Edit: I tried doing gravityScale = 0 to the layers and that did not work, adding objects to the screen work fine doing that method just not with multiple layers in Tiled.

Are you sure you’re using the right layer properties?

Here’s the correct approach (where the first is what you enter into the “name” field, and the second is the “value” field).

For an object layer:

[lua]

objects:bodyType          =          static

[/lua]

For a tile layer:

[lua]

tiles:bodyType          =          static

[/lua]

  • Caleb

Just started playing with this. I’ll have to rebuild my last project, it’s not a drop in replacement. No big deal, I needed to rewrite everything it was getting sloppy. 

I ran into a problem with setCameraBounds() which, now takes a bounds object. This is what I came up with for bounds to keep the map in the viewable area of the screen. 

map.setCameraBounds( { xMin = map.data.width - map.data.width \* 0.5, xMax = map.data.width - map.data.width \* 0.5, yMin = display.contentHeight \* 0.5, yMax = map.data.height - display.contentHeight \* 0.5 } )

I noticed a few things. It seems you can now set physics properties, in Tiled, without the prefix: physics.  For example: bodyType = static, seemed to work fine. 

Here’s a Tiled question. What options are available for Image layers? I’d like to add more than one image layer and position the image on the layer. It seems if I load an image the image is always on the left. 

I suppose this could be handled with large tiles? Or I could move the image with code in my program. 

I ran into a problem with setCameraBounds()

What problem did you have :)?

I noticed a few things. It seems you can now set physics properties, in Tiled, without the prefix: physics.  For example: bodyType = static, seemed to work fine. 

No, the only reason bodyType = static works is because bodyType is a Corona property, not a physics value:

[lua]

physics.addBody(myObj, “static”, {}) – Sets bodyType = static

myObj.bodyType = “dynamic” – Sets it to dynamic, this is the only property (except for isSensor) that this can be done with

[/lua]

Here’s a Tiled question. What options are available for Image layers? I’d like to add more than one image layer and position the image on the layer. It seems if I load an image the image is always on the left. 

Not many :slight_smile: Tiled image layers don’t currently have many abilities. Basically all Tiled enables you to do is display an image in the top left corner. You can, of course, use Dusk to position it with properties like so (representing the Tiled properties dialog for the image layer):

[lua]

x          :          55

y          :          103.8314

[/lua]

A better solution than that (this should work with the camera) would count on the fact that the actual image object is created as layer.image:

[lua]

image.x          :          55

image.y          :          103.8314

[/lua]

  • Caleb

Liking the new engine, seems to be working well so far. Is it possible to scale stiles up? For example I have some 32 by 32 pixel tiles that I would like to display at 64 by 64 pixels. I like the pixel look and the smaller tiles would take up less file space.

Caleb im moving from lime to dusk engine and i wonder what is the best way to implement enemies,

How can I erase a tile (or change its alpha value etc) from a layer permanently? I might be doing something totally wrong, but I tried to fiddle with tile alpha and also tried layer.erase() with proper x&y positions. Everything works ok as long as the modified tile stays in the camera view. But when I move the view so that the modified tile is out of bounds and then re-enter, the erased tile is drawn to the view again.

@soggybag:

There isn’t a built in function; try this:

[lua]

map:scale(2, 2)

map.updateView() – Make sure you do this when scaling or you’ll get a slight jitter

[/lua]

@PewPewNinja:

I’d create your enemies separately and then add them to the map:

[lua]

local enemy = display.newImage(“myEnemy.png”)

enemy.whizzbang = 53

enemy.moose = “Mushroom”

map.layer[whatever]:insert(enemy)

[/lua]

If you want to position your enemies from within Tiled, you can do that as I did with the Bob sample: create a property value for the enemies’ position (nested tables would be best if multiple enemies exist) and position them when you load your level. Dusk’s property entry with dots ability makes this easy:

[lua]

Tiled Properties:

enemyPositions.1          :          !json! [10, 20]

enemyPositions.2          :          !json! [30, 31]

[/lua]

Then, when you create the enemy:

[lua]

enemy.x, enemy.y = map.layer[whatever].tilesToPixels(map.enemyPositions[1][1], map.enemyPositions[1][2])

[/lua]

@Sape:

I’ll add this as soon as I can. There isn’t a built-in way to do this yet (other than erasing it each time it gets drawn, which could get hairy).

  • Caleb

@Sape:

Just pushed a commit that enables this. For any tile layer, now, to lock a single tile, use this:

[lua]

map.layer[1]._lockTileDrawn(35, 21) – Now this tile will never get erased

[/lua]

[lua]

map.layer[1]._lockTileErased(35, 21) – Now this tile will never get drawn

[/lua]

[lua]

map.layer[1]._unlockTile(35, 21) – Remove any locks from a tile

[/lua]

You can also lock a section with the lock command, which works like draw or erase:

[lua]

map.layer[1].lock(1,23, 1,23, “drawn”) – Last one can either be “drawn” or “d”; “erased” or “e”; or “unlock” or “u”

[/lua]

  • Caleb

Thanks Caleb for the fast commit, _lockTileErased does exactly what I need.

There seems to be a small issue in the camera.lua update function, viewY seems to be be calculated using xParallax instead of yParallax?

Just committed that issue, too :slight_smile:

  • C

I been fiddling with the code more, still using the base dusk code example folder I decided to add onto it  with a player sprite sheet based off a character. Added a player:setSequence(“moveDown”) when he is moving down in the pointInRect part. And also added a new flag for when he stops animation in the direction he chose he stays “still” in the direction he was facing so moving right he stays right still. I modified the code a bit to get rid of rotation.
The problem I am having is sometimes during any movement phase he will “slide” while still moving just the animation won’t change, this happens sometimes when changing directions or after going in same direction after a few seconds. Any way to fix this? I can post code as its just adding onto the dusk example.

Another side problem is sometimes a black line occurs on screen and its usually a black line vertically coming down? I think this a problem with the camera? I updated it to (1) to follow the character better to always center him.

Thanks for the help, amazing new engine, very clean and easy to understand!

I think I’ll have to see your code, as I don’t quite get what you mean :slight_smile:

As for the lines, are you speaking of the quick flickers that sometimes go across the screen? If you are, I’m not sure how to fix them. Possibly extrude the tileset?

  • Caleb

I just learnt today about this new map library. It looks pretty cool.

Two questions:

(1) Is there any document I can read in order to use it?

(2) Is it possible to use it for this kind of game: http://goo.gl/uLCzUc

  1. Yep - here: https://github.com/GymbylCoding/DuskEngineDocs. Sorry for not posting that originally.

  2. Hm… Difficult question. You can simulate *something* like it by changing the appearance of your tile images. Currently, though, Dusk doesn’t support “full” isometrics.

  • C

There seems to be an issue with layer iterators, as all the layers seem to be added to the layerList.tile instead of proper ones (object & image).

Anyways, I was wondering why are there two copies of each layer in the map.layer table (Or atleast so it seems)? There seems to be a layer with number/index as its key, and other with the actual layer name. And also the tiles seem to be in the tile tables two times. So for example after loading the map and iterating through each object layer to find a tile with a certain unique properties, two layers contain two objects that match the properties that I’m searching. I can handle this and only do my stuff to the first object that meets my search criteria, but was was wondering is this as intended?