Dusk Engine

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

Is it possible to get coordiantes of individual tiles on your map?

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?

Thanks for the input - I just committed the fix for that :slight_smile:

There are two copies so that you can have the easiest access:

[lua]

map.layer[1] – Will always point to the first layer

map.layer[“name”] – Or you can do it from the name

[/lua]

As for the tiles in the tables twice… Can you please expand a bit? That doesn’t sound so good :frowning:

[EDIT] I think I’ve got what you mean, actually - you mean the object layer’s objects? They’re the same:

[lua]

layer.object[1] – For for i = 1, #layer.object iteration

layer.object[“name”] – For easier object access

[/lua]

  • C

Yep, that was exactly what I meant. I was a bit confused when iterating through the objects and they seemed to be there twice.

Thanks for the quick answer.

For the reference, using layer.objects() should always go through the objects but once; you can use it for iterating:

[lua]

for object in map.layer[1].objects() do

  – Whatever

end

[/lua]

  • C

I created an object layer in Tiled. Named it platform, and assigned the following properties:

bodyType = static

collisionType = platform

physics:bodyType = static

physics:enabled = true

I was expecting this to make all objects on the layer physics static bodies. For line objects I couldn’t see them. For boxes the objects were dynamic. 

Setting properties on each object worked. Though,

physics:bodyType = static

did not set the body type, while:

body=static 

Did set the body type to static. 

Is it possible to set the properties for all objects on a layer in one place? Seems like this worked in the pervious version?