Dusk Engine

Well…the map in .lua format is in the game directory AKA same folder where the main.lua and everything is.

The path that I have provided to dusk.buildMap is correct. It’s the name of the map only, since the map file is located in the same folder as main.lua.

If the properties that I add to layers work then that is probably not the problem.

Properties you’re adding to tiles aren’t working? Can you file a test case, please, in the GitHub issue tracker? It’s working for me (*sigh*… the most frustrating kind of error).

  • Caleb

Yes, I have added physics:enabled  property to a certain layer, and physics are working.

But when I added bodyType property to some tiles on that layer, it doesn’t work. I set the body type to static, but it didn’t work. Seems like they still have some sort of “default” body type, or whatever Corona uses when you don’t specify the body type.

Just gimme a minute to sign up to GitHub and take some screenshots to post.

Should I just copy the .lua file of my map and paste it there?

Yes, please - better would be if you have DropBox (or another file sharing system), you can just post the link there.

  • Caleb

Issue posted. I have also added the dropbox link to the whole map file.

Let me know if you need anything else.

Can I ask how can you make the camera stick to the player?

In that maze example game, it looks like the player is actually moving (by using setLinearVelocity), and the camera just follows.

There are 2 lines of code that look like they have something to do with the camera:

map.setCameraFocus(player)

map.setTrackingLevel(0.1)

I’m not completely sure what they do.

I have tried to make the camera follow the character in my game, using setCameraFocus and setTrackingLevel.

Seems like the character was only placed in the center of the screen, but the camera won’t follow.

Is there something else that you must do to make the camera stick to player?

Ok, here goes.

map.setCameraFocus() sets the object that the camera will move to follow. You can use this to make the camera follow your player, move the camera to something that just happened (“Look! The door disintegrated!”), whatever.

map.setTrackingLevel() sets the “fluidity” of the camera. That’s the measure of how “smooth” the camera’s tracking is. Try playing around with it in the sample and seeing the result. Higher values (those approaching 1.0) make the camera more rigid and tight, while lower values (approaching 0.0) make the camera slower and more “buttery”.

What you’re looking for is map.updateView(). That tells Dusk to position the camera according to the focus’s position, cull off unneeded tiles, draw new ones - really, the best way to put it is the name of the function: update view. This should be called once every frame (in your game loop). If you look at the Bob sample, you’ll find the updateView() call in the enterFrame listener.

  • C

The camera now follows the player, but something wierd has happened- tile bodies have moved. They are not where the tiles are displayed.

The character doesn’t stop where the tiles are. As if physic bodies of the tiles were “offset” from them.

I wonder what’s the problem…

Are you using custom physics shapes? What do you see with physics.setDrawMode(“hybrid”) or physics.setDrawMode(“debug”)?

  • C

Hmmm…looks like the physic bodies of tiles move along with the camera.

As the character moves left or right, he’s getting closer to the edge of the screen (the character is not always at the center of the screen, not sure why that is happening either).

The character stops at the point, where physic bodies of tiles are positioned at the screen.

Ahh… Make sure you’re inserting the player into your map.

[lua]

map.layer[“some layer”]:insert(player)

[/lua]

  • C

Ok, yeah works great now. Thanks.

Sorry for so many questions. I was checking the Dusk engine docs- index.html and those api, but they don’t seem offer much info for now.

Oh, one more thing…I couldn’t help but to notice that maps have those little gaps between tiles. I saw that in that Bob maze game, as well as in my game.

Why exactly is that happening?

I guess it’s just because Dusk is still in beta, and it’s gonna get handled later.

It’s not a problem to me for now. I have other stuff to add to my game before it’s finished.

But it may be a problem if that would be happening when my game is done.

Sorry about the docs - I’ve got a lot on my plate (a complete rewrite of CBEffects, upkeep for Dusk while it’s in the early phase, plus a few personal projects) :slight_smile:

You can alleviate the tile gaps some by using this:

[lua]

display.setDefault(“minTextureFilter”, “nearest”)

display.setDefault(“magTextureFilter”, “nearest”)

[/lua]

To completely get rid of it, I’d say the only way would be to extrude your tileset sides and have each tile slightly overlap the others.

  • C

I’ll try that.

Hi there! I’m very new, but I had a quick question about the camera bounds. I understand that it takes a bounds object, so you have to the xMin, xMax, etc. but are the x values in pixels or is it in tile coordinates? I’m having huge issues trying to figure out how to stop the screen from scrolling once it reaches the edges of the map. Do you have any suggestions for what I should make my values in order to set my bounds equal to the size of my map? Thanks!

Also (sorry!) is there a way to keep my player in the center of the screen? So far I have the player inserted in a tile layer with the camera set on them. The camera automatically moves so that the player is in the center of the y axis but a bit to the left of center for the x, but I would rather the character be center, and when I move the character up or down, the map won’t start moving until the character is practically off the screen (it’s not to it’s bounds yet) but it works fine when I move my character right to left. Any help would be appreciated!

@bridgettekuehn:
The xMin coordinates are in pixels, xMax are in tiles, yMin are in the default font point size for your platform, and yMax are in inches :smiley:
 
Not really; the coordinates for the bounds are all in pixels :). To set the bounds to the size of your map, it’ll be something like this (assuming your map’s top-left corner is at the top-left corner of the screen): 
[lua]
map.setCameraBounds({
xMin = display.contentCenterX,
yMin = display.contentCenterY,
xMax = map.data.width - display.contentCenterX, – Use map.data.width because that’s the “real” width of the map - map.width changes when culling kicks in
yMax = map.data.height - display.contentCenterY – Same here
})
[/lua]
As for your “player-in-center-of-screen” problem, are you scaling individual layers?

Edit: Sorry, it seems the forum software isn’t formatting my code correctly…

  • C

Ok, I couldn’t get the tiles to overlap each other, because of the grid in Tiled.
 
Here’s the image of how I’ve solved the gaps-between-tiles problem.

It may look like a cheap trick, and it may take some time to finish if you have a lot of tiles, but it gets rid of the gaps completely.

Nice thinking :slight_smile:

Side note: You can get tiles to overlap by making the tilewidth of the map 32 (or your normal width), and load your tileset as having 34 width (with an extruded image). Then, you paint with the bigger tiles and it should work.

  • C