Dusk Engine

Yeah, I know about many sidescrollers that have slopes and the characters just normally walk on them.

Idk maybe they don’t use tiles for collisions at all and they just make paths where the character can walk.

Maybe they’re using some similar system to that png2box2d…not sure.

Anyways, glad I could help.

@Tilen.curin:

True, there are several (paid) software solutions to make side scrollers with correctly masked tiled. I hope Dusk Engine will ever support it. 

Seeing the forum I would think you’ve done much with the Dusk Engine yourself. Would you care to share what you’ve made? 

I’m actually using Dusk engine only for platforms and enviroment where character can collide.

Backgrounds are just scrolling images.

So far I have only one simple map where I can test character movements and sprite animations, cause there are other things I plan to implement before going into level design.

But I may soon upload some footage of my game. Maybe here on this thread as an example of how well Dusk does.

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.

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.

Hi, I’m having problem when I remove the object from map (for example box)

with event.other:removeSelf() or display.remove(event.other)

then i move “camera” out  to the right and when i come back that “box” appear back on a map

@luistheworm:

A good question… That’s because of the culling system. Every time a tile goes out of the screen, it’s completely deleted. No physics, no nothing. You have a number of options that will solve that:

  1. If your maps are small (1-2 screens optimal), you can completely turn of culling

[lua]

dusk.setPreference(“enableTileCulling”, false)

[/lua]

  1. You can lock tiles from being erased

[lua]

map.layer[1].lock(x1, y1, x2, y2, “draw”) – This means the chunk of tiles from x1,y1 to x2,y2 will never be erased

[/lua]

  1. If your maps are moderately small, you can use objects for physical things (they’re not culled)

@dima1:

That’s also because of culling. Not only does culling erase tiles when they’re no longer visible, but it also draws them when they enter the screen. You’ll likely need to lock them.

[lua]

map.layer[1]._lockTileDrawn(x, y) – A core method that locks a single tile at an x,y tile position

[/lua]

For example, if you need to lock a single tile that is at 55,3 tile XY, you’d use this:

[lua]

map.layer[1]._lockTileDrawn(55, 3)

[/lua]

  • C

Sorry if i’m missing the obvious…

When using map.setCameraFocus(player) the player is always in the center of the screen.

I want the player to x number of pixels from the left… Is it possible ? 

Ah, yea I’ve been thinking about that as well.

I haven’t been peeking at Dusk files that much, but if you go to Dusk—>dusk_core—>run , you can find a .lua file named “camera”.

That is probably where the main camera code is written.

I’ve tried reading the code there and it’s well commented, so if you take some time, you’ll understand it eventually (it’s just lua).

At line 232, you’ll see a comment " Get/ Set Viewpoint".

It looks like this:

 function map.setViewpoint(x, y) tprint.add("Set Camera Viewpoint") local x, y = getXY(x, y) camera.viewX, camera.viewY = x, y tprint.remove() end

If you want to center the camera a bit left from the player, you should change this line:

camera.viewX, camera.viewY = x -100, y

In this case I moved it 100 pixels to the left.

You can add more or less, whatever suits your game.

Same for y value.

Sorry for late reply.

This has worked for me…there may be other ways to do it, but I haven’t taken enough time to understand all the code yet.

Caleb P will know for sure.

Anyways I hope this helped…

First of all thanks for the help Tilen.

So trying to set the player to be a third into the screen, I did the following

camera.viewX, camera.viewY = x + (display.contentCenterX - (display.contentWidth / 3)), y

this caused a problem with the beginning of the level starting a third of a screen in and also the level ending to show a third of a screen extra at then end, so I modified the setCameraBounds

map.setCameraBounds({xMin = display.contentCenterX - (display.contentCenterX - (display.contentWidth / 3)),yMin = display.contentCenterY,xMax = map.data.width - display.contentCenterX - (display.contentCenterX - (display.contentWidth / 3)),yMax = map.data.height - display.contentCenterY})    

This is all well and good but surely there must be a better way to do this using one of the map methods…