Win a copy of Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Icon change color when Player is online

Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Guys,

I am trying to find a way that will change the color of the player icon depending on his status.
Can anyone explain that to me?
Posts: 978
Netbeans IDE Oracle MySQL Database Tomcat Server C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

this type of things i usually put under "how clever are you?"  you have to build a state diagram for what you want to consider and check for overlapping areas and choose which you will give preference to, then build a small state machine into your icon object for your character--depending on how you are handling that it could be for your character itself, but then that is up to you and "how clever you are".

so if i have 4 different states i want to represent, then i have to make 4 different ways of updating the icon, that could be as simple as changing the intensity of the icon, or xor-ing a pattern for each state through the icon or maybe 4 different icons--that is up to you also.

So once you have the 4, arbitrary number i chose here, states that you want to represent, then you need to build a state machine, my chosen way to implement clearly defined states aka defining conditions.  that would be done with a "case statement" or a series of "if then else statements", once again--how clever are you?

now comes the twist of things: do you want your defining condition to be mutually exclusive in their representation or do you perhaps want then to overlap?  So you have 4 states, does that mean you have 4 different things to represent? State 0, 1, 2, 3 or does that mean that you want then to be able to simultaneously express--that would be a binary flag with 4 positions or a singe hex digit--0 through F?  in the later case you need to have some "or operations" to express the changes that will undergo with the icon.  so you could be something like on-line, male, has sound, has video... all combinations of those selections offer 16 different states--4 bits of a binary flag aka 1 hex digit.

the mechanics of what you do to make those representations is up to you--i tend to, in the case the the binary flag (simultaneous representations of states), to have separate and distinct operations that will uniquely modify the icon--the image portion of it--and then incorporate that into the game (pass it to your player character object).

so i've given you somethings to thinks about, the reason i call this "how clever are you" is that there are multiple ways of doing the same things--it depends on what you want and what you see.  design has an artistic element that is merged with engineering and there is where "how clever are you" is born.

So--what do you want to do, and "how clever are you"?

Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic