Dusk Engine

@tilen.curen:
You can try what Azmar said (though you’ll need to be careful; objects are not culled like tiles are). I think what he means is, instead of making each tile physical, make them just tiles and draw objects to work as the walls. Then, you won’t “stuck” on the boundary between tiles (if that’s what’s happening). If your player is actually moving into the tiles, it’s probably happening (if you’re setting the velocity each frame) because the collision isn’t stopping the player. In that case, I’d set up a “collided” flag for walls and stop setting the velocity if the player is hitting a wall.

I’m going to go a bit “underwater” for a while, as I’ve got a deadline on a personal project I’ve got to finish. I’ll be a bit less active for a while; though I won’t be completely silent, I won’t be available to help quite as much as usual.

  • C

@Caleb P:
The flicker problem is not the flicker inbetween tiles, that is a problem too and the  display.setDefault(“minTextureFilter”, “nearest”)display.setDefault(“magTextureFilter”, “nearest”) does not fix it enough. There is a new flicker with giant black lines on edges of screen that only starts when you create an object layer which makes no sense. I would like to send you a file report but its a pain to recreate it without sending my entire project… because the camera/movement/tiled file/engine/images is needed to recreate it. If I delete all object layers it goes away, but obviously I need my object layers. Oddly enough after hours of trying to fix it, if I have the object layer as my first and bottom layer it will still do its physics job, won’t be seen by the program… but the flicker problem is completely removed. I’ve remade multiple maps and fiddled with my code a lot of different ways to figure out where the problem was, I’m pretty sure this is a bug?

I think I spoke too soon. That bounce issue is still giving me problems. I will eventually find a way around every time, but it’s starting to annoy me, that pretty much every time I implement something new to my game, this bounce issue is causing glitches with it!

Let me explain exactly what I mean by this “bounce issue”.

My character’s body is wider than one tile. Sometimes it stands/ collides on more tiles (the entire width of the body is standing on tiles), but sometimes only about half of the body width is colliding/ standing on tiles, while the other half is not (that other half is standing in air).

Here is the example of my character landing with a part of the width on the tile, and the other part in air.

If the character lands, with the entire body width on tiles, there is no bounce.

But if the character lands like on this image, then he slightly bounces up, in this case triggering the jumping sprite sequence while he appears on ground (standing sprite sequence should be playing at this time).

I really don’t know what is causing this bounce. Physics bounce is set to 0 on both the character’s body as well as on all the tiles.

I thought that it might be, because gravity scale is increased to 5.0 on the chracter’s body, but I’ve tried setting it back to default (1.0), and the bounce was still there.

Could it be somehow else connected to tiles?

I don’t know, I’m out of ideas here…

If anyone knows what could be causing this bounce, then please tell me, cause it’s a really annoying problem.

  1. Is the bounce noticeable to you, or is it only detectable because of the animation that is playing?

  2. How are you triggering the player’s jump animation?

  3. Does the player have .isFixedRotation = true? (I can’t see how you couldn’t…)

Here’s what I think is happening:

  1. Your player moves down to the tile at a fast speed

  2. The tiles don’t have enough force to counteract the player (only half of his physics body is on the tiles)

  3. He penetrates into the Box2D shape a bit

  4. The next frame, he has to be moved out…

  5. So he accelerates slightly upward

  6. Voila! The bounce.

You could try fixing this by making your jump animation only play when the jump button (or similar event) is pressed. Don’t know how you’re doing it, but it’s worth a try :slight_smile:

  • C

The bounce isn’t noticeable to the eye, you can’t spot it.

But it is there, cause the output terminal says that the character is moving up, it’s a really small bounce, that always lasts for 4 frames (at 30fps).

How do I know when the character is moving up? I’m using a function similar to the one that you’ve helped me with when I was looking for ways to check if the character is moving down. (the function that makes character.prevY- a made up variable same as character.y- actual y value , and then compares them, and when character.y is smaller or larger than character.prevY, it detects).

That function is okay though.

Yes, character does have .isFixedRotation = true.

The jump animation is triggered when the character moves up, and only allowed when the player hits the jump button, and the character is standing on the ground. 

However, if the character bounces up, and if the player hits the jump button right at that time, the animation will trigger, but the character won’t jump.

It’s a glitch that I noticed when I was playing around with the game on my phone.

Yes, I will most likely fix this by adding some boolean variables (true/ false), but I’d rather get rid of this bounce, as it will most likely give me more problems in the future.

  1. Your player moves down to the tile at a fast speed

  2. The tiles don’t have enough force to counteract the player (only half of his physics body is on the tiles)

  3. He penetrates into the Box2D shape a bit

  4. The next frame, he has to be moved out…

  5. So he accelerates slightly upward

I remmeber this was happening all the time, before I started using tiles. When my character was just walking and jumping on a rectangle that was serving as ground. I can’t remmember what were the physics properties of that rectangle though.

Can I get rid of this bounce by changing physics properties of tiles or character’s body?

Increase the density of tiles or something?

You might try setting player.isBullet = true; it might solve the issue.

If that doesn’t work, I don’t believe you can fix it with Box2D. You can, however, modify your animation playing code to either check for a large enough Y-change (if player.x - player.prevX >= xyz), or do what I said above and use a completely different approach… I’d opt for the check first, so you don’t have to completely change your code.

If you’re feeling adventurous, you could always just roll your own physics approach, and not use Box2D at all. There are a number of Lua-based physics engines from LÖVE you can port to Corona, or you can Google “how to write a physics engine”. Admittedly a drastic step, but you could fix the bounce issue :slight_smile:

  • C

.isBullet = true didn’t solve the problem.

Well I’ll just make the jumping animation play under one more condition- it can only be triggered when the player’s y value isn’t dropping or increasing (if character.y == character.prevY).

That should work.

EDIT: Turns out it doesn’t work. Didn’t trigger at all.

I just made my code detect that slight bounce as if the character was normally standing, so it triggers the standing animation. Solved now.

I’ll definitely check out more physics engines, so thanks for that. If this issue is gonna be a problem for more things (not just the edge tiles), then perhaps I’ll try some other engine.

Writing my own physics engine sounds interesting, but it would prolly consume a lot of my time, so I think I’ll stick with currently existing engines.

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

I’m having issues when using this Engine, the map is always cut off, it seems like it’s always being cut around the same size of the device size.

@tilen.curin:

Glad you’ve got it fixed :slight_smile:

@luistheworm:

Can you give some more info? Make sure you’re calling map.updateView() every frame.

  • Caleb

Hi,

Thanks for replying I’ve used the code map.updateView() on my main function that is being called every frame.

Here I’m attaching a screnshoot so you have a better idea, this is taken from the example that comes with it.

Here is the screenshoot

Some code or more info, please :)?

  • Caleb

I took the code from https://github.com/GymbylCoding/Dusk-Engine

I use the program Tiled map editor to edit everything.json as you can see from the screenshoot, I increased the size and added new content.

But once you load it into corona you see it cut off.

All the code is from that link, the only modification i did was to the map to make it bigger.

Whoops! That was an edit I had made for later development… Fixed :slight_smile:

Download the new version and it should work fine.

  • Caleb

You are the jedi! Thanks a lot, now it works perfect

Out of curiosity what was the problem?

Long story short, I changed the command format for drawing and erasing, and it wasn’t recognized by the actual command executer.

I could go further into it, but without a clear understanding of the internal workings of the culling system, it won’t make much sense :slight_smile:

  • C :slight_smile:

Hey, one more question, how to make sure everything happening outside what you can see keeps updated because It seems like when ever something is out of the “camera” physics fail.

Ok, I’ve found out that it is possible to get coordiantes of tiles on your map.

By using  map.tilesToPixels

@lvl9hero: thanks for asking, the answer was useful for me as well  :)

Basically, when you add map properties to your map in Tiled, it looks like this:

name/ value

playerLocation/ !json! {“x” : 5, “y” :11}

Those X and Y values are units in Tiled AKA tiles. 5 means 5 tiles from left and 11 means 11 tiles from top.

Corona doesn’t know what tiles are, so you have to convert those values to pixels.

Luckily, Dusk does that for you, by using map.tilesToPixels.

For example- If your tiles have a size of 80x 80, 1 tile is converted to 80x 80 pixels.

This is how I’ve solved the problem with my character getting stuck between vertical tiles.

I removed the physic bodies from my current wall tiles, as well as disabled physics for them (so that they don’t fall down).

Then I’ve displayed objects to serve as walls (yes, thank you for recommending it to me).

And then, you just insert that object into one of the map layers, so that it doesn’t follow around when your character moves.

Correct me if I’m wrong, but I think I understand this now.

@Azmar:
Yes, that does seem to be a bug :frowning:

If it surfaces again, you can try filing a bug report on GitHub and I’ll see what I can do. I’d like to ask, though: Have you seen it on any other maps (i.e. create a new blank map, add a tileset, make objects, and run it and the problem appears)?

@tilen.curin:
That’s right :slight_smile:

One thing off-topic that I’d mention is that because the properties “playerLocation” and “finishLocation” are prefixed with !json! , Dusk knows to send the rest of the property to the JSON reader. Thus, it creates a table according to the JSON notation that follows.

You could just as easily do this, because of the way Dusk (by default; it can be disabled if you need dots to be read literally) treats the dot character:
[lua]
playerLocation.x = 5
playerLocation.y = 11
[/lua]

(another thing off-topic I’d like to mention is that I’ve written a notation parser for a future version of Dusk that takes notation in the exact form as a Lua table: {abc = 123, [“something else”] = 64.388} so as to remove the gap between properties and Lua code. I’ve also completed a fully-featured math solver with a complete implementation of the Shunting-Yard algorithm and variables; imagine this for a property: someWeirdValue = sin(map.width) * 64 + (map.height / cos(layer.alpha)))

  • C