It looks like you're new here. If you want to get involved, click one of these buttons!
[SolidTileObject]
Graphic = WALL
[TilesGraphic]
Texture = ../../data/scenery/tiling-map.png
TextureSize = (64, 64, 0)
[WALL@TilesGraphic]
TextureCorner = (0, 0, 0)
[GRASS@TilesGraphic]
TextureCorner = (64, 0, 0)
[MapLevel]
Map = WALL #WALL #WALL #GRASS
Comments
Either done in config or in code. If it's in config, you can get the info by pushing the object section and looking for the key Graphic. If it's linked in code, when you link it, simply push its name in the object's config section, this way you can easily find it back later.
Would that work for you?
it's a very strange way to define your map tiles...
dont't be cheap on Config sections
[WallObject]
Graphic = WALL
[GassObject]
Graphic = GRASS
[MapLevel]
Map = WallObject # WallObject # WallObject # GrassObject
Btw: consider using Scroll and ScrollEd.
And override the OnCollide() callback to decide what to do
So because it's in code @iarwain & @grey, then I can push a custom variable (the name) here to retrieve later. I like this idea.
Many thanks.
@lydesik, yep cheap I suppose but it works, and I can change common values within a base of "TilesGraphic". Not quite ready for scroll right now. I'd like to stick closer to the metal for a little while longer.
Is there no way using an orxStructure that I can get the graphic name currently assigned to an object?
Sorry if I am missing the obvious.
[TilesGraphic]
Texture = ../../data/scenery/tiling-map.png
TextureSize = (64, 64, 0)
[WALL@TilesGraphic]
TextureCorner = (0, 0, 0)
[GRASS@TilesGraphic]
TextureCorner = (64, 0, 0)
this is perfectly fine, and a good way to define your tiles graphics.
I don't have a solution for what you are looking for ( retrieve the Graphic name used by an Object at runtime ).
But i propose you with a simple alternative to achieve what your are trying to do ( filter game logic base on Graphics, via the Objects names ). Tell me if I'm wrong.
so your loop become
but now you can filter the behavior with player collisions based on the object name.
Another options would be to push the GUID of your object as a section and store there the name of the property you want to track (in your case the graphic's name).
GUIDs are unique per structure instances and can be retrieved at runtime using orxStructure_GetGUID().
I forgot that I am already using Object names for different tiles already. So while I said I had an object name of "SolidTileObject", I also have others like "StickyTileObject".
So I really wanted subsets of those objects to identify as well (which are the graphic names).
So to avoid having to refactor how I use the config, I've fallen back to a nice solution of having a simple tile class and connecting them to objects with SetUserData (I love this thing). I store the names there.
.h file
.cpp file
In my map painting loop
In my collision detection
as a side note, orxString_Compare() is not really efficient, you should try to call it once, and then, store a flag (bit field or boolean variable) in your class.
so your subsequents test will be based on this flag, which is much more efficient.
ofcourse there is the two programmer rules:
1) dont optimize now
2) dont optimize yet
and maybe you are not doing these tests very often in your game loop
But yep, Lydesik's right, don't optimize before knowing it needs optimization! Which reminds me I should optimize the render plugin. ^^