Game Development Community

Second blog post!

by Daniel Buckmaster · 09/01/2007 (1:40 pm) · 0 comments

Yes, it worked this time.

In my last blog, I mentioned a few changes to GuiCrossHairHud. To sum it up, imagine the Advanced Crosshair resource but more of a blank canvas. The crosshair will remember GameBase-derived objects you look at, and fire off one of two script-side callbacks when you look away or look at a different object.
Basically, the changes I had made back then were roughly correct, but sharply messed up. The crosshair would shoot off 'object selected' callbacks as long as you kept your crosshair on the same object, and sometimes it missed out 'object deselected' ones. Tonight, I sat down with a piece of paper and a pen and went through what the code should do, and how I would make it do this.
This is something I can not reccoment highly enough for anyone beginning any sort of programming. You have a problem, so work it out on paper first. It's much easier to find errors in your own logic rather than errors in logic after translating it into code.
Anyway. Like I said, I cleaned up the code substantially, and as a bonus, I even made it work! So now I'm almost ready to release another resource based on this which I reckon could be pretty useful. There's just one problem, which has to do with object IDs. I made a forum post, so I won't derail the blog with it. But keep your head down, 'cause there's a storm coming... hah. Hah.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!