I am trying to create a simple rectangular board that consists of individual cells.
I am following tutorial projects as examples.
Config file made it easy to create a board of cells:
[Cells]
Position = (0, 0, 1.0); <= We place our first vertical wall
Graphic = CellGraphic;
Repeat = (22, 17, 1); tile graphic (x, y, 0) times on axis
Scale =
@Cells.Repeat;
Body = WallBody
Then I display this object:
orxObject_CreateFromConfig("Cells");
I then set event callback:
orxCLOCK *pstClock;
pstClock = orxClock_FindFirst(orx2F(-1.0f), orxCLOCK_TYPE_CORE);
/* Registers our update callback */
orxClock_Register(pstClock, Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);
And here is my update callback that changes the color of the object. I expected to pick an individual cell, but the entire collection of cells changes the color.
I think there is nothing wrong with that, but now I am stuck and can't figure out how to select just one object. I suspect that one INI section name is one object. If that's the case, then I assume I have to create objects inside Init function and I don't know how to do that. I am sorry, it must be trivial, but I want to make sure I don't do something stupid.
Thanks
Comments
I create objects in Init function based on the configuration file section:
here is a loop inside Init to create objects:
and now clicking highlights the object. It is just perfect. I wrote a small game in OpenGL and I remember dealing with the same issue. It was hard as I don't work day to day with this kind of staff.
I really like the system so far. I don't mind choice of C. In fact, I prefer it.
Also, I'm glad that you enjoy orx so far.
As for this specific code, let me suggest you an alternative that would take advantage of the config system, letting you adjust things directly from config without having to recompile.
INI:
C: