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 3 of 20 1 2 3 4 5 »
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

Yes, I was flipping tiles. Didn't think that would be a problem.

 

Nice, thanks for the update. I'll download it right away.



[TOPIC: post.html]
#52

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

I was looking at that example game (bob), trying to figure out how to make the player collide with tiles and saw that you've added some properties to some tiles in Tiled (bodyType, physics:bounce and physics:enabled).

Is there anything else that you must do to add physics bodies to tiles?

I've also noticed that you have added some map properties (player and finish locations) with value !json! followed by the coordinates.
What should I do if I'm using .lua format for my map? In the api it says that Dusk supports .lua maps.



[TOPIC: post.html]
#53

soggybag

[GLOBAL: userInfoPane.html]
soggybag
  • Contributor

  • 256 posts
  • Corona SDK

I want to get the tile at an x and y on a map. Using map.layer["a"].tile( 10, 10 ). It seems tiles don't exist when they are culled, so you can't get at a tile if it's off screen. This is not a big deal, but it would be great if you could get the data about this tile that was loaded from the map.json. I could load this data, but it seems that it's already in Dusk, so the info is already there. Is it posible to get to this? 

 

I'm working on a platform type game. I'm running into trouble using physics. So I thought I'd give a go at creating getting this working without physics. To get this working I'd need to know which tile is at any x and y position on the map. 



[TOPIC: post.html]
#54

soggybag

[GLOBAL: userInfoPane.html]
soggybag
  • Contributor

  • 256 posts
  • Corona SDK

Poking around I find a tile has these properties:

 

2013-12-29 20:10:23.081 Corona Simulator[1544:507] _proxy    userdata: 0x7fb83ebf7c28

2013-12-29 20:10:23.082 Corona Simulator[1544:507] _class    table: 0x7fb83e6ba790

2013-12-29 20:10:23.082 Corona Simulator[1544:507] tileY    18

2013-12-29 20:10:23.082 Corona Simulator[1544:507] tileX    5

2013-12-29 20:10:23.083 Corona Simulator[1544:507] props    table: 0x7fb83bd78bf0

 

Props looked pretty promising but seems to be empty. There doesn't seem to be any way to add properties to tile in Tiled. There must be some way to identify the frame number of each tile. 



[TOPIC: post.html]
#55

Caleb P

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

  • 1,424 posts
  • Corona SDK

@tilen.curin:

Physics support (Box2D) is done by first adding physics:enabled = true. Then, any properties you want to go in the addBody physics table:

                                Physics table
                                      |
                                      V
physics.addBody(object, {bounce = 0.5, friction = 0.1})

Is simply prefixed with physics:. For example, if you want your object's density to be set, you'd use physics:density. If radius, it'd be physics:radius. BodyType is a special property; it's not added via the physics table. Instead, you set it "outside" the call:

physics.addBody(object, {bounce = 0.5, friction = 0.1})
object.bodyType = "static"

You can normally also add bodyType inside it, as the second argument, but that's not the way Dusk does it.

 

As for the !json! prefix, that's just a flag that says to Dusk, "Hey, Dusk! This property here I want you to treat as JSON notation. What follows will be a table." That means you can create tables quite easily from within Tiled - simply prefix it with !json! and it'll fire up the JSON parser that's built into Corona. It'll work equally with Lua or JSON maps.

 

@soggybag:

There isn't a way to get a tile that doesn't exist. I'll try adding this into the next release.

 

The props table is for "hot" properties; those that Corona interprets as having a special meaning - x, y, alpha, xScale, etc. Adding them to the props table does nothing to the object itself. To add something to the props table, prefix it with props:. For example, props:x will evaluate to obj.props.x, and consequently not modify the position of the object.

 

- Caleb



[TOPIC: post.html]
#56

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

Okay...so I have 3 layers of tiles, 1st contains background tiles, 2nd are supposed to be walkable tiles (the player must not fall through them) and 3rd layer are supposed to be wall tiles (the player must not walk through them).

 

Can I just add properties to layers, or must I add properties to each individual tile?

 

I was thinking of adding properties like these to layers:

 

name/value

 

-bodyType static

-physics:enabled true

etc

 

would these properties apply to all tiles on the layer?

 

EDIT:

tried it out myself. Seems like you can add properties like physics:enabled, but you can't set bodyType for the entire layer of tiles.



[TOPIC: post.html]
#57

Caleb P

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

  • 1,424 posts
  • Corona SDK

Physics properties will be added to the tiles or objects automatically. Other properties (like bodyType) must either be added to each tile (long and tedious) or be added with the prefix tiles: or objects:, for tile layers and object layers, respectively. In other words, values prefixed with tiles: are added to tiles within the layer, and objects: for objects.

 

So your example would translate to this:

physics:enabled = true
tiles:bodyType = static

 

- Caleb



[TOPIC: post.html]
#58

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

Now I just gotta find out why my tiles just fall down, even though I have set their bodyType to static in the properties :/

 

Static bodies usually just float there, not affected by the gravity or velocity as far as I know.

 

Don't know why my tiles just fall down.

 

EDIT:

 

I just noticed that whatever properties I try to add to seperate tiles won't be applied. Nothing.

Properties that I add to layers will work, but if I add properties to seperate tiles, it won't work.

 

What could be the reason for that? 



[TOPIC: post.html]
#59

Azmar

[GLOBAL: userInfoPane.html]
Azmar
  • Contributor

  • 140 posts
  • Corona SDK

Now I just gotta find out why my tiles just fall down, even though I have set their bodyType to static in the properties :/

 

Static bodies usually just float there, not affected by the gravity or velocity as far as I know.

 

Don't know why my tiles just fall down.

 

EDIT:

 

I just noticed that whatever properties I try to add to seperate tiles won't be applied. Nothing.

Properties that I add to layers will work, but if I add properties to seperate tiles, it won't work.

 

What could be the reason for that? 

I had this problem too....and its a silly embarrassing mistake (at least mine was). If you are adding the properties or anything and nothing is working when you export it to your game, a possible solution is not in the programming but on where you export it to. Be very careful on where it says you are exporting the files to and where its reading it from, you probably have it set to your old game folder and not the correct one.

If that doesn't fix it, maybe some other people are having this problem lol :)



[TOPIC: post.html]
#60

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.



[TOPIC: post.html]
#61

Caleb P

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

  • 1,424 posts
  • Corona SDK

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



[TOPIC: post.html]
#62

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.



[TOPIC: post.html]
#63

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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



[TOPIC: post.html]
#64

Caleb P

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

  • 1,424 posts
  • Corona SDK

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

 

- Caleb



[TOPIC: post.html]
#65

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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

Let me know if you need anything else.



[TOPIC: post.html]
#66

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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?



[TOPIC: post.html]
#67

Caleb P

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

  • 1,424 posts
  • Corona SDK

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



[TOPIC: post.html]
#68

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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...



[TOPIC: post.html]
#69

Caleb P

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

  • 1,424 posts
  • Corona SDK

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

 

- C



[TOPIC: post.html]
#70

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.



[TOPIC: post.html]
#71

Caleb P

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

  • 1,424 posts
  • Corona SDK

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

map.layer["some layer"]:insert(player)

 

- C



[TOPIC: post.html]
#72

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.



[TOPIC: post.html]
#73

Caleb P

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

  • 1,424 posts
  • Corona SDK

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) :)

 

You can alleviate the tile gaps some by using this:

display.setDefault("minTextureFilter", "nearest")
display.setDefault("magTextureFilter", "nearest")

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



[TOPIC: post.html]
#74

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.

I'll try that.



[TOPIC: post.html]
#75

tilen.curin

[GLOBAL: userInfoPane.html]
tilen.curin
  • Enthusiast

  • 99 posts
  • Corona SDK

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.

 

Attached File  no_gaps.jpg   30.4KB   55 downloads

 

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.




[topic_controls]
Page 3 of 20 1 2 3 4 5 »
 
[/topic_controls]