C++ code help please. [message #416861] |
Wed, 06 January 2010 09:02 |
Raptor RSF
Messages: 210 Registered: July 2007 Location: Netherlands
Karma: 0
|
Recruit |
|
|
Hello everyone,
Last days i have been working on the RSF HUD and while programming a feature for this hud i encountered an error.
Feature that i am programming. ( my goal is to have it fade, the very same as the MiniAmmoHUD and MiniHealthHUD)
.\reticlehealthhud.cpp(224) : error C2220: warning treated as error - no 'object' file generated
.\reticlehealthhud.cpp(224) : warning C4244: '=' : conversion from 'float' to 'unsigned int', possible loss of data
I tried many thing to convert the variable or something, But i am still a noob at coding c++.
Does anybody know a solution for this problem?
void ReticleHealthHUDItemClass::Render()
{
if (!Enabled) return;
// RETICLEHEALTHHUD_flash
GameObject *obj = Get_Vehicle_Return((GameObject *)(*TheStar)->obj);
float current_health = Commands->Get_Health(obj);
unsigned int current_time = *SyncTime;
if (current_health != LastHealth)
{
EndFlashTime = current_time + HealthInfoFlashDuration;
FlashActive = true;
}
float flash_percentage = 1.0f;
if (FlashActive && (current_time < EndFlashTime))
{
flash_percentage = float(EndFlashTime - current_time) / float(HealthInfoFlashDuration);
}
else if (FlashActive)
{
flash_percentage = 0.0f;
}
// RETICLEHEALTHHUD_color
float health = 0;
float maxhealth = 0;
if (Get_Vehicle(obj))
{
health = Commands->Get_Health(Get_Vehicle(obj));
maxhealth = Commands->Get_Max_Health(Get_Vehicle(obj));
}
else
{
health = Commands->Get_Health(obj);
maxhealth = Commands->Get_Max_Health(obj);
}
float healthpercent = (health / (maxhealth / 100));
unsigned int color = 0;
color = ReticleHealthHUDColor;
for (unsigned int i = 0;i < ReticleHealthHUDColorCount;i++)
{
if (healthpercent <= (*ReticleHealthHUDColors)[i]->Value)
{
color = (*ReticleHealthHUDColors)[i]->ColorValue;
unsigned int alpha = color >> 24;
alpha = flash_percentage; // <<<<< "alpha" is an integer and "flash_percentage" is a float. This is the issue.
color = (color & 0x00FFFFFF)| (alpha<<24);
break;
}
};
Render2D->Reset();
Render2D->Shader.ShaderBits = 0x000984B3;
Render2D->Set_Texture(BackgroundTextureFile);
if (Render2D->Texture->Initialized == false)
{
Render2D->Texture->Init();
};
RectClass background_location;
background_location.Top = BackgroundPosition.Y;
background_location.Left = BackgroundPosition.X;
background_location.Bottom = BackgroundPosition.Y + BackgroundSize.Y;
background_location.Right = BackgroundPosition.X + BackgroundSize.X;
Render2D->Add_Quad(background_location, BackgroundUV, color);
Render2D->Render();
LastHealth = current_health;
};
-
Attachment: RSF_HUD.png
(Size: 745.64KB, Downloaded 304 times)
Rencom server Fan - Marathon#1
[Updated on: Wed, 06 January 2010 09:11] Report message to a moderator
|
|
|
|
|