|
[Bikeshedding]Does a HUD element hold its value? |
weapon_S
Member #7,859
October 2006
|
This is the problem: there is a game-stat, and that game-stat is displayed to the player on the HUD. OO speaking, how should the graphic element and value element relate to each other? References
|
Bruce Perry
Member #270
April 2000
|
You said it in the square brackets. Also remember it'll be easy to change later if you need to[1]. Get back to work References
-- |
weapon_S
Member #7,859
October 2006
|
Bruce Perry said: unless you over-engineer it. I think this is the essential part. Thanks for mentioning that. When I start thinking, I don't stop thinking. I then sort of over-engineer out of insecurity. |
Thomas Fjellstrom
Member #476
June 2000
|
weapon_S said: if you can't think of a better solution, don't try to make a better solution I like that a lot. I lawled. Also, sigged. -- |
james_lohr
Member #1,947
February 2002
|
To me, the natural design would be as follows: The actual value of the stat is owned by the primary object that it relates to (e.g. the player object). Anything else that wishes to use this stat interfaces to the object that owns it. Lets suppose you wanted to re-skin your game: if you have a clear interface to the underlying stats, it becomes easy to write a whole new HUD from scratch that uses the same interface. I'm also in favour of totally decoupling the core game logic from pure "eye candy". A good example being what you just mentioned: the score. The actual value of your score should sit in the core game logic, but eye candy (such as spinning up the score when it changes) should exist in the "front-end" logic. I think that's pretty much what you're doing in 1), and think it's a far better OO design than the other options. weapon_S said: giving up speed We're talking about a few bytes/referenced here, so you shouldn't even be thinking about speed.
|
l j
Member #10,584
January 2009
|
I would just keep a reference to the actual value in the HUD element object.
|
weapon_S
Member #7,859
October 2006
|
Thomas Fjellstrom said: I like that a lot. I lawled. Also, sigged. Cool, cool, cool. taronĀ said: Dereferencing is surely less expensive than passing messages around. That's what I was talking about. And of-course: once you have an almighty design pattern you have to subjugate all your hard-working code to it. That might actually impact how fast things go. |
|