Multiple bars
by Tahitian Lucas-box · in Torque Game Engine · 12/01/2004 (5:20 am) · 4 replies
I have had the engine now for about three weeks and ive had time to mess around with the engine core and recompile it. I have followed a thread that explained how to make multiple bars such as hunger, thirst. this example was good but had mistakes in it. I have gotten so far as to define a new variable called mHunger, with the neccessary changes to shapebase.h, shapebase.cc and guiHealthBarHUD in order to store and return mHunger, and then to display on the Health bar in the gui. I have three functions, getHunger, setHunger and a setHunger console function. i have no problem with showing and setting the hunger value, but when i try to alter the value using the sethunger function nothing happens on the HUD. Any suggestions as to what i might be doing wrong?
About the author
#2
Also, make sure that you take advantage of bit masks to limit transmission of your updates. So, when you make a change to mHunger you call setMaskBits with something like VitalStatsMask and then in pack/unpackUpdate you would only bother sending updates when the value changes.
I'm starting to get into the nitty gritty, so I'll stop here. But that is most likely your problem...
- Brett
PS: shapeBase is really such a messy class to work with... I would recommend going back to gameBase if you can and working up from there. I know, for a lot of people, this would mean re-coding a lot of stuff but it would clean out so much cruft.
12/01/2004 (5:52 am)
Yeah, as Jackie says you need to look into the packUpdate and unpackUpdate methods to make sure that values that need to be visible on the client are transmitted. Remember, your entire environment (whether multiplayer or single player) are run as a Client/Server app. In single player, the server and client are the same machine and the networking is just run in loopback.Also, make sure that you take advantage of bit masks to limit transmission of your updates. So, when you make a change to mHunger you call setMaskBits with something like VitalStatsMask and then in pack/unpackUpdate you would only bother sending updates when the value changes.
I'm starting to get into the nitty gritty, so I'll stop here. But that is most likely your problem...
- Brett
PS: shapeBase is really such a messy class to work with... I would recommend going back to gameBase if you can and working up from there. I know, for a lot of people, this would mean re-coding a lot of stuff but it would clean out so much cruft.
#3
m
12/05/2004 (3:05 pm)
Why doya suggest gamebase? ive been hackin shappebase a lot, but i'm goin t refactor soon, so...m
#4
ive added 3 f32 vars to shapebase w/ get n set. everything is peachy(seems t be), but ive got code i dont understand.
in gamebase.h, i guessed at some values. correct bit values? what is PublicConstants for?
---
enum PublicConstants {
ThreadSequenceBits = 6,
MaxSequenceIndex = (1 << ThreadSequenceBits) - 1,
JumpLevelBits = 6, // ACT
FireLevelBits = 6, // MJW
TeamTypeBits = 6, // MJW
EnergyLevelBits = 5,
DamageLevelBits = 6,
DamageStateBits = 2,
// The thread and image limits should not be changed without
// also changing the ShapeBaseMasks enum values declared
// further down.
MaxSoundThreads = 4, ///< Should be a power of 2
MaxScriptThreads = 4, ///< Should be a power of 2
MaxMountedImages = 4, ///< Should be a power of 2
MaxImageEmitters = 3,
NumImageBits = 3,
ShieldNormalBits = 8,
CollisionTimeoutValue = 250 ///< Timeout in ms.
};
---
good?
and-----
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
JumpMask = Parent::NextFreeMask << 8,
FireMask = Parent::NextFreeMask << 9,
TeamMask = Parent::NextFreeMask << 10,
SoundMaskN = Parent::NextFreeMask << 11, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
----
so, did i guess correctly and what are these for? (actually, i understand the mask, but not the enum)
m
12/05/2004 (4:09 pm)
Hmm, this is related, so maybe yall can direct me...ive added 3 f32 vars to shapebase w/ get n set. everything is peachy(seems t be), but ive got code i dont understand.
in gamebase.h, i guessed at some values. correct bit values? what is PublicConstants for?
---
enum PublicConstants {
ThreadSequenceBits = 6,
MaxSequenceIndex = (1 << ThreadSequenceBits) - 1,
JumpLevelBits = 6, // ACT
FireLevelBits = 6, // MJW
TeamTypeBits = 6, // MJW
EnergyLevelBits = 5,
DamageLevelBits = 6,
DamageStateBits = 2,
// The thread and image limits should not be changed without
// also changing the ShapeBaseMasks enum values declared
// further down.
MaxSoundThreads = 4, ///< Should be a power of 2
MaxScriptThreads = 4, ///< Should be a power of 2
MaxMountedImages = 4, ///< Should be a power of 2
MaxImageEmitters = 3,
NumImageBits = 3,
ShieldNormalBits = 8,
CollisionTimeoutValue = 250 ///< Timeout in ms.
};
---
good?
and-----
enum ShapeBaseMasks {
NameMask = Parent::NextFreeMask,
DamageMask = Parent::NextFreeMask << 1,
NoWarpMask = Parent::NextFreeMask << 2,
MountedMask = Parent::NextFreeMask << 3,
CloakMask = Parent::NextFreeMask << 4,
ShieldMask = Parent::NextFreeMask << 5,
InvincibleMask = Parent::NextFreeMask << 6,
SkinMask = Parent::NextFreeMask << 7,
JumpMask = Parent::NextFreeMask << 8,
FireMask = Parent::NextFreeMask << 9,
TeamMask = Parent::NextFreeMask << 10,
SoundMaskN = Parent::NextFreeMask << 11, ///< Extends + MaxSoundThreads bits
ThreadMaskN = SoundMaskN << MaxSoundThreads, ///< Extends + MaxScriptThreads bits
ImageMaskN = ThreadMaskN << MaxScriptThreads, ///< Extends + MaxMountedImage bits
NextFreeMask = ImageMaskN << MaxMountedImages
};
----
so, did i guess correctly and what are these for? (actually, i understand the mask, but not the enum)
m
Torque 3D Owner Jackie Hayes