Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Dusk Engine
Started by Caleb P Dec 13 2013 12:22 PM

490 replies to this topic
dusk engine tilemap game engine opensource
[TOPIC CONTROLS]
« Page 19 of 20 17 18 19 20
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#451

kumarks102

[GLOBAL: userInfoPane.html]
kumarks102
  • Enthusiast

  • 71 posts
  • Corona SDK

Thanks Caleb,

 

I have already solved above issue which i was facing in MTE. I hope we will be experimenting the Dusk Engine in our next game. 

Thank you for your response.

 

~Kumar KS.



[TOPIC: post.html]
#452

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

@kumarks102:

1. I think any tile engine would have issues with 10x10 tiles. It's just that there are so many more tiles than there are with, say, a 32x32 map. Rounding 32x32 down, there are approximately nine 10x10 tiles for every 32x32 tile, so if you have a map completely filled with tiles that fills an iPad screen with 32x32 tile dimensions (32x24 or 768 tiles) and you switch to 10x10, you'll have almost 8000 tiles on the screen. Moving the map will result in a frame drop because you're drawing and erasing tiles as needed, and, again, you're drawing and erasing a lot more tiles than you are with a 32x32 map. Potentially, when I complete the tilemap shader, you'll be able to move some of your tiles to a shader layer and they'll render much faster. You can follow the progress of the tilemap shader here: https://forums.coronalabs.com/topic/59174-making-a-tilemap-shader/

2. 1000 tiles is by no means to much for Dusk to handle. The most I've ever done is twenty-five million, so you're good ;).

3. Integrating Spine and other libraries isn't so much a "can Dusk do it" as a "can I do it". Dusk just builds the framework for you, and you're left to make the rest of the game. Spine objects can be inserted into Dusk layers, if that's what you're asking - I'm doing that in my game.

 

@carlos.rafael:

"some layer" will be the name of the layer. Also, custom properties on tiles will be placed in the "Tile properties" window in Tiled. Dusk then loads them and you can access them on the tile.

 

- Caleb

Thank you @Caleb, I access the name of the layer using this: print("testando", map.layer.teste.name) //meaning "teste" the map.name, and "name" the property I set on Tiled.

 

I also set a name for the tile on TILED, so I can check if the player is colliding with it or not. My question now is, how would I access this name? 

Because I was trying to check collisions using event.object1.name and event.object2.event, but the object2 is giving me null, so I don't know how to access the name of the tile.

 

Hope you undersatnd my question, and thank you for the fast response last time.

 

 



[TOPIC: post.html]
#453

touchdowngames

[GLOBAL: userInfoPane.html]
touchdowngames
  • Observer

  • 23 posts
  • Enterprise

Hi Caleb,

 

I have a question, how would I approach changing the tilesets images programmatically?

For example, I have a map that enables the users to change it's skin (using other images as the tilesets).

 

I was thinking to edit the "image" property from "tilesets" (in the "data" variable) that gets loaded in core.loadMap and replace the image I need in there.

What would you recommend?

 

Thanks,

Radu



[TOPIC: post.html]
#454

geiganax

[GLOBAL: userInfoPane.html]
geiganax
  • Observer

  • 6 posts
  • Corona SDK

So I'm now having a problem with getting the camera to focus on my player's sprite. When I add in the code to have it follow the player the map's collision starts behaving as if it were in a slightly offset location. Also the camera doesn't keep him centered on screen and will even allow him to fall off the edge of the screen, though it will continue skewing downwards. I noticed someone earlier in this thread mentioned a similar issue, though I have some slightly different symptoms and the solution you mentioned for him (inserting the sprite into the map) didn't seem to affect it.

I define it as follows:

	sprite = display.newImageRect( "guy.png",64,96)
	sprite.x, sprite.y = 160, 100
	sprite.rotation = -2.5
	physics.addBody(sprite, {density = 1, friction = 5, bounce=0})
	map.layer["player"]:insert(sprite)
	sprite.isFixedRotation = true
	sprite.bodyType = "dynamic"

	
	map.setCameraFocus(sprite)
	map.setTrackingLevel(1.0)

I also have a runtime listener and a function to updateView() every frame. 

 

Any ideas on what I'm missing?



[TOPIC: post.html]
#455

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,786 posts
  • Enterprise

I've moved this to Caleb's own forum "Gymbyl Coding". Might I suggest starting new threads for specific questions regarding the Dusk engine instead of continuing this very long and multi topic forum thread.

 

Thanks

Rob



[TOPIC: post.html]
#456

Dr Brian Burton

[GLOBAL: userInfoPane.html]
Dr Brian Burton
  • Enthusiast

  • 74 posts
  • Corona SDK

Nice job on Dusk Caleb!

I started playing with Dusk this evening by converting one of my previous games from Lime to Dusk. In less than 30 minutes I had the map loading.  Still have some more to do, but it looks like you have built a solid tool.

 

I am starting the process of updating one of my textbooks and will be switching the tool use for the chapter on tile-based games to Dusk.



[TOPIC: post.html]
#457

dsukabela

[GLOBAL: userInfoPane.html]
dsukabela
  • Observer

  • 2 posts
  • Corona SDK

Can anyone give me info how to load a tile map,

I trying but, show nothing in simulator, also in terminal dosnt show any issue,

maybe i missed something, please help !!!! :( 



[TOPIC: post.html]
#458

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

@carlos.rafael:

All Dusk does to load properties is process the value, which converts it to a number, Boolean, table, etc., and add it to the object with the exact same key as was specified in Tiled. So if you add a property called "name" to a tile in Tiled, each tile will have that property. If you're not picking up the property in your collision listener, all I can say is that your collision listener is acting up. Here's a working collision function (global because it seems that's what you're using):

local function onCollision(event)
  local tile, object = event.object1, event.object2
  if not tile.tileX and not tile.tileY then
    tile, object = object, tile -- We mixed the tile and the object up; switch them
  end

  -- Use tostring() in case the name of either object is nil
  print("The tile's name is " .. tostring(tile.name) .. ", and the object's name is " .. tostring(object.name))
end
Runtime:addEventListener("collision", onCollision)

@touchdowngames:

Yay, a use case for plugins! I've been on the fence with them for a while. I just pushed a commit to the dev branch which actually calls plugin callbacks (previously, you could add plugins all you wanted, but they did absolutely nothing :D). What you'll do now is this:

local tilesetChanger = {} -- Create the plugin table

tilesetChanger.onLoadMap = function(data, stats)
  -- In here, 'data' will look approximately the same as Tiled exported map data. The only difference is that Dusk adds some extra properties in.
  -- Look at your map file to see the structure.
  data.tilesets[1].image = "../blahblahblah.png" -- Notice that the path is relative to the map file, not the root.
end

-- Later somewhere, BEFORE you load your map
dusk.registerPlugin(tilesetChanger)

Notice that this will only work with the dev branch (I really need to get a stable release out!).

 

@geiganax:

I know you said it's not, but this seriously sounds like a prime case of object-not-in-map-layer. Are you sure you're not inserting the object into something else after you insert it into the layer? Corona only allows objects to be in a single display group, so any insertions remove it from the previous group and insert it into the new one. I ask because I know someone who had this same problem - all the symptoms of notinmapitis, but they were inserting the object into the map correctly. It turned out that later they inserted it into another display group, so it was getting removed from the map after all.

 

@Dr Brian Burton:

Wow, great! Let me know if you need any help at any time.

 

- Caleb



[TOPIC: post.html]
#459

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

@carlos.rafael:

All Dusk does to load properties is process the value, which converts it to a number, Boolean, table, etc., and add it to the object with the exact same key as was specified in Tiled. So if you add a property called "name" to a tile in Tiled, each tile will have that property. If you're not picking up the property in your collision listener, all I can say is that your collision listener is acting up. Here's a working collision function (global because it seems that's what you're using):

local function onCollision(event)
  local tile, object = event.object1, event.object2
  if not tile.tileX and not tile.tileY then
    tile, object = object, tile -- We mixed the tile and the object up; switch them
  end

  -- Use tostring() in case the name of either object is nil
  print("The tile's name is " .. tostring(tile.name) .. ", and the object's name is " .. tostring(object.name))
end
Runtime:addEventListener("collision", onCollision)

@touchdowngames:

Yay, a use case for plugins! I've been on the fence with them for a while. I just pushed a commit to the dev branch which actually calls plugin callbacks (previously, you could add plugins all you wanted, but they did absolutely nothing :D). What you'll do now is this:

local tilesetChanger = {} -- Create the plugin table

tilesetChanger.onLoadMap = function(data, stats)
  -- In here, 'data' will look approximately the same as Tiled exported map data. The only difference is that Dusk adds some extra properties in.
  -- Look at your map file to see the structure.
  data.tilesets[1].image = "../blahblahblah.png" -- Notice that the path is relative to the map file, not the root.
end

-- Later somewhere, BEFORE you load your map
dusk.registerPlugin(tilesetChanger)

Notice that this will only work with the dev branch (I really need to get a stable release out!).

 

@geiganax:

I know you said it's not, but this seriously sounds like a prime case of object-not-in-map-layer. Are you sure you're not inserting the object into something else after you insert it into the layer? Corona only allows objects to be in a single display group, so any insertions remove it from the previous group and insert it into the new one. I ask because I know someone who had this same problem - all the symptoms of notinmapitis, but they were inserting the object into the map correctly. It turned out that later they inserted it into another display group, so it was getting removed from the map after all.

 

@Dr Brian Burton:

Wow, great! Let me know if you need any help at any time.

 

- Caleb

Heelo @Caleb. It just worked really well. 

I just would like to understand how the var dusk know that tile.name will get exactly the name of the Tile on my map, I don't know if it is a clear question. How tile.name is not set to null but for the tile's property on my map.

 

Also, can I keep improving this function to deal with other types of tiles?

Thank you in advance 



[TOPIC: post.html]
#460

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

@carlos.rafael:

Dusk reads the map data from the file exported from Tiled, and builds the map accordingly. Tiled includes the tile properties you set in the data. Thus, when Dusk reads the data, it knows that tile #xxx in the tileset gets the property "name" set to "blahblahblah" or whatever. Each tile in a layer is a separate display object, so when Dusk builds the tile, it adds that property.

 

For an alternative way of looking at it, imagine that you're creating ten rectangles in your app, each of which has a different 'name' property. When a rectangle collides, you want to print out its name. That's all Dusk is really doing - creating a bunch of little objects, each of which has different properties according to what you set in Tiled.

 

You should be able to just check for other names to deal with other types:

if tile.name == "flamingSpikesOfDeath" then
  -- Player dies
elseif tile.name == "friendlyCloudWithTeeth" then
  -- Player looks quizzically at it
elseif tile.name == "portraitOfNapoleon" then
  -- Player reflects on French history
end

- Caleb



[TOPIC: post.html]
#461

burnsj002

[GLOBAL: userInfoPane.html]
burnsj002
  • Contributor

  • 212 posts
  • Corona SDK

@Caleb P,
can you check the Bang notation to add collision filters. This is the property I added in the Tiled app but it doesn't seem to work.
physics:filter = !!! categoryBits: 4 maskBits: 1
This is a screenshot of the property I added in Tiled so you can see if I did it right:
https://www.dropbox.com/s/0fv0za2jhdaflm4/Screenshot%202015-10-05%2016.53.27.png?dl=0

I know I got the CategoryBits and the Bitmask right because I tried the collision filter between the player, bullets, and a static crate image and it works.

[TOPIC: post.html]
#462

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Should be fixed. Try the new master branch or just add "filter = true" to the physicsKeys tables on lines 44 and 41 of objectlayer.lua and tilelayer.lua, respectively.

 

- Caleb



[TOPIC: post.html]
#463

geiganax

[GLOBAL: userInfoPane.html]
geiganax
  • Observer

  • 6 posts
  • Corona SDK

@geiganax:

I know you said it's not, but this seriously sounds like a prime case of object-not-in-map-layer. Are you sure you're not inserting the object into something else after you insert it into the layer? Corona only allows objects to be in a single display group, so any insertions remove it from the previous group and insert it into the new one. I ask because I know someone who had this same problem - all the symptoms of notinmapitis, but they were inserting the object into the map correctly. It turned out that later they inserted it into another display group, so it was getting removed from the map after all.

 

Edited, realized mistaken assumption:

That was it, I was trying to insert the sprite into the composer scene group even though I'd already inserted it into the map. Thanks!



[TOPIC: post.html]
#464

burnsj002

[GLOBAL: userInfoPane.html]
burnsj002
  • Contributor

  • 212 posts
  • Corona SDK

Thanks Caleb! It works perfect now :)



[TOPIC: post.html]
#465

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

@carlos.rafael:

Dusk reads the map data from the file exported from Tiled, and builds the map accordingly. Tiled includes the tile properties you set in the data. Thus, when Dusk reads the data, it knows that tile #xxx in the tileset gets the property "name" set to "blahblahblah" or whatever. Each tile in a layer is a separate display object, so when Dusk builds the tile, it adds that property.

 

For an alternative way of looking at it, imagine that you're creating ten rectangles in your app, each of which has a different 'name' property. When a rectangle collides, you want to print out its name. That's all Dusk is really doing - creating a bunch of little objects, each of which has different properties according to what you set in Tiled.

 

You should be able to just check for other names to deal with other types:

if tile.name == "flamingSpikesOfDeath" then
  -- Player dies
elseif tile.name == "friendlyCloudWithTeeth" then
  -- Player looks quizzically at it
elseif tile.name == "portraitOfNapoleon" then
  -- Player reflects on French history
end

- Caleb

Thank you a lot for the clarification  @Caleb,
I wonder if Dusk is compatible with the composer framework, or should I create my own game framework when working with dusk? 

 

If we can work with composer and dusk simultaneously, is there any tutorial on how to do it?

 

Thank you again!  



[TOPIC: post.html]
#466

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Dusk works great with Composer - remember that a map is just a glorified display group with a bunch of extra functions and behaviors. With that in mind, all you need to do to get Dusk working with Composer is insert the map into the Composer scene group.

self.view:insert(map)

- Caleb



[TOPIC: post.html]
#467

Painconfess

[GLOBAL: userInfoPane.html]
Painconfess
  • Enthusiast

  • 49 posts
  • Corona SDK

Hello again Caleb!

 

I just made a moving enemy object with physics. Everything works fine, until the enemy (child object from your addObjectType function) goes off screen. Obviously enemy falls because of tile culling destroys the floor where it is walking :D

 

I don't want the tile culling disabled, so I was thinking 2 options:

 

1. Set gravity off when enemy(child object) off screen. 

Question for this option: is there a method to check if child object off screen? 

 

2. Set tile culling begin for example half of the screen later (in a specific tile layer would be nice).

Question for this option: how do I do that?

 

Or do you have much better method for this? :)



[TOPIC: post.html]
#468

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Would you mind opening a new topic so we can get started with that approach to new questions :)?

 

- Caleb



[TOPIC: post.html]
#469

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

Dusk works great with Composer - remember that a map is just a glorified display group with a bunch of extra functions and behaviors. With that in mind, all you need to do to get Dusk working with Composer is insert the map into the Composer scene group.

self.view:insert(map)

- Caleb

Thank you a lot for the clarification @Caleb



[TOPIC: post.html]
#470

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

@soggybag:

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

map:scale(2, 2)
map.updateView() -- Make sure you do this when scaling or you'll get a slight jitter

 

@PewPewNinja:

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

local enemy = display.newImage("myEnemy.png")
enemy.whizzbang = 53
enemy.moose = "Mushroom"
 
map.layer[whatever]:insert(enemy)

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:

Tiled Properties:
enemyPositions.1          :          !json! [10, 20]
enemyPositions.2          :          !json! [30, 31]

Then, when you create the enemy:

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

 

@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

 

Hello @Caleb, I am trying to implement enemis in my game based on what you said but there are somethings I could not understand.

 

The best way to implement enemies in a game that uses dusk is positioning the enemies from within Tiled?

If so, I guess the right steps to do it would be:

 

1- create the enemy on the map (would it be an object on the  object layer or would it be just one normal tile?)

2- Set some properties (what is that Json positions you posted on the property on tiled?) 

3- create the enemy on the code and import the properties from tiled to the code.(I would equal the enemy var with the object var on Tiled?(How would I do that?))

4- make the enemy move (should I treat the move of the enemy in the same function for every enemy I have on the game?)

 

Is that right? Sorry for the ammount of questions.

Thank you in advance!!!



[TOPIC: post.html]
#471

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Please open a new topic for this :)

 

- Caleb



[TOPIC: post.html]
#472

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

Please open a new topic for this :)

 

- Caleb

Thank you, I opened another topic for the question @Caleb



[TOPIC: post.html]
#473

PLAYCUBE

[GLOBAL: userInfoPane.html]
PLAYCUBE
  • Enthusiast

  • 43 posts
  • Corona SDK

do we have any updates for isometric mapping? i tried isometric map from tile editor to corona using dusk and it looks like a chess board :(



[TOPIC: post.html]
#474

Caleb P

[GLOBAL: userInfoPane.html]
Caleb P
  • Corona Geek

  • 1,424 posts
  • Corona SDK

Unfortunately, no, Dusk does not currently support isometric maps. Once I roll out version 1.0 (yes, it's technically not even out of beta!), with documentation, bug-free-ness (or as close as I can get to that), and other basic foundation stuff like that, I'll think about adding isometric maps. If you happen to be an isometric wizard, feel free to try adding isometric maps and submit a pull request.

 

- Caleb



[TOPIC: post.html]
#475

carlos.rafael

[GLOBAL: userInfoPane.html]
carlos.rafael
  • Observer

  • 28 posts
  • Corona SDK

@Aatos Media:

You can insert the scrolling background into an empty layer of the map, then set the layer's xParallax/yParallax as needed. That way, it'll move exactly in the same way as the rest of the map.

 

Q1: Just make sure your remove() function doesn't fail if the object is already removed, then call it to remove the object when you want to. Then, when the host object is culled, the remove function will be called but nothing will happen. The addObjectType code adds a listener for the type, so you could technically set the type of the object to something else (I think?), but a much easier and safer way is to just set a flag for something specific about the host object, like position or name. Here's an example for position, built on the idea that no two host objects in a layer will have the same position and object type.

local dontComeBackOrIllShoot = {} -- Table to hold references to destroyed objects


-- Yackety yack


-- Inside an object's destroy function (when your bullet hits it or whatever)
local specialKey = object.x .. "|" .. object.y -- Make a magical key to identify the host object; it's important to note that 'object' here refers to the host object, not the child object

dontComeBackOrIllShoot[specialKey] = true -- Set the flag in the destroyed objects table


-- Yackety yack


-- Inside the objects build function
local specialKey = event.object.x .. "|" .. event.object.y
if dontComeBackOrIllShoot[specialKey] then
  return -- Never mind, this one's already been destroyed
end

Q2: I don't really understand this question :(. Can you explain some more please?

 

Q3: The way Painconfess did it works. You can put the object types into separate modules, then require() them and add the object types to the map. Alternatively, you can do it how I do it and make a separate module for each object type:

-- types/movingPlatform.lua

local objectType = {}

objectType.build = ...

objectType.remove = ...

return objectType
-- types/floorSwitch
local objectType = {}

objectType.build = ...

objectType.remove = ...

return objectType

Then, in your game file:

addObjectType(require("types.movingPlatform"))
addObjectType(require("types.floorSwitch"))

And yes, I did use "called once" to mean "called once per object type".

 

- Caleb

Hello @Caleb, based on the first answer you gave to @Aatos I am implementig this part of code where if the child object has been removed and the player goes offscreen, when he comes back, this child object must not be displayed. You said we have to set the properties of the host object, but how do I reference the host object? I can set and change properties of the child object using the object."something"..., but I don't know how to do it for the host object. 

 

Could you help me?

 

 

Thank you in advance!!!




[topic_controls]
« Page 19 of 20 17 18 19 20
 
[/topic_controls]