removed some compiler warnings

changed variables to float where appropriate
This commit is contained in:
techdragon.nguyen@gmail.com
2010-11-05 08:07:50 +00:00
parent 91cf0c8d37
commit 8908e86857
15 changed files with 100 additions and 80 deletions

View File

@@ -18,8 +18,8 @@ class MenuItem: public JGuiObject
bool mHasFocus; bool mHasFocus;
WFont *mFont; WFont *mFont;
string mText; string mText;
int mX; float mX;
int mY; float mY;
int updatedSinceLastRender; int updatedSinceLastRender;
float lastDt; float lastDt;
@@ -31,7 +31,7 @@ class MenuItem: public JGuiObject
public: public:
MenuItem(int id, WFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false); MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleQuad, bool hasFocus = false);
~MenuItem(); ~MenuItem();
virtual void Render(); virtual void Render();
virtual void Update(float dt); virtual void Update(float dt);

View File

@@ -18,7 +18,7 @@ protected:
float mY; float mY;
float start; float start;
int timer; int timer;
int minimumItems; size_t minimumItems;
vector<string> strings; vector<string> strings;
unsigned int currentId; unsigned int currentId;
@@ -29,7 +29,7 @@ public:
void Add(string text); void Add(string text);
void Reset(); void Reset();
void setRandom(int mode = 1); void setRandom(int mode = 1);
TextScroller(int fontId, float x, float y, float width, float speed = 30, int scrollerType = 0, int _minimumItems = 2); TextScroller(int fontId, float x, float y, float width, float speed = 30, int scrollerType = 0, size_t _minimumItems = 2);
void Render(); void Render();
void Update(float dt); void Update(float dt);
virtual ostream& toString(ostream& out) const; virtual ostream& toString(ostream& out) const;

View File

@@ -354,7 +354,7 @@ void GameStateDeckViewer::Update(float dt)
//Prevent screen from updating. //Prevent screen from updating.
return; return;
} }
hudAlpha = (float) 255-(last_user_activity * 500); hudAlpha = 255 - ((int) last_user_activity * 500);
if (hudAlpha < 0) hudAlpha = 0; if (hudAlpha < 0) hudAlpha = 0;
if (subMenu){ if (subMenu){
subMenu->Update(dt); subMenu->Update(dt);
@@ -1029,7 +1029,7 @@ void GameStateDeckViewer::renderOnScreenMenu(){
sprintf(buffer, ((*countPerCostAndColor)[i][j]>0)?_("%i").c_str():".", (*countPerCostAndColor)[i][j]); sprintf(buffer, ((*countPerCostAndColor)[i][j]>0)?_("%i").c_str():".", (*countPerCostAndColor)[i][j]);
font->DrawString(buffer, 64 + leftTransition + j*15, posY); font->DrawString(buffer, 64 + leftTransition + j*15, posY);
} }
r->FillRect(77.f + leftTransition + (Constants::MTG_NB_COLORS-2)*15, posY + 2, (*countPerCost)[i]*5, 8, graphColor); r->FillRect(77.f + leftTransition + (Constants::MTG_NB_COLORS-2)*15.0f, posY + 2.0f, (*countPerCost)[i]*5.0f, 8.0f, graphColor);
posY += 10; posY += 10;
} }
@@ -1309,10 +1309,10 @@ void GameStateDeckViewer::renderCard(int id, float rotation){
float right_border = SCREEN_WIDTH - 20 ; float right_border = SCREEN_WIDTH - 20 ;
float x_center = x_center_0 + cos((rotation + 8 - id)*M_PI/12)*(right_border-x_center_0); float x_center = x_center_0 + cos((rotation + 8 - id)*M_PI/12)*(right_border-x_center_0);
float scale = max_scale/ 1.12 * cos((x_center-x_center_0)*1.5/(right_border - x_center_0) ) + 0.2 * max_scale * cos (cos((x_center-x_center_0)*0.15/(right_border - x_center_0) )); float scale = max_scale/ 1.12f * cos((x_center-x_center_0)*1.5f/(right_border - x_center_0) ) + 0.2f * max_scale * cos (cos((x_center-x_center_0)*0.15f/(right_border - x_center_0) ));
float x = x_center; // ; float x = x_center; // ;
float y = (SCREEN_HEIGHT)/2 + SCREEN_HEIGHT*mSlide*(scale+0.2); float y = (SCREEN_HEIGHT_F)/2.0f + SCREEN_HEIGHT_F * mSlide * (scale + 0.2f);
int alpha = (int) (255 * (scale + 1.0 - max_scale)); int alpha = (int) (255 * (scale + 1.0 - max_scale));
@@ -1357,7 +1357,7 @@ void GameStateDeckViewer::renderCard(int id, float rotation){
} }
quadAlpha = 255 - quadAlpha; quadAlpha = 255 - quadAlpha;
if (quadAlpha > 0){ if (quadAlpha > 0){
JRenderer::GetInstance()->FillRect(x - scale* 100 ,y - scale * 142.5,scale* 200,scale*285,ARGB(quadAlpha,0,0,0)); JRenderer::GetInstance()->FillRect(x - scale * 100.0f ,y - scale * 142.5f , scale * 200.0f, scale * 285.0f, ARGB(quadAlpha,0,0,0));
} }
if (last_user_activity < 3){ if (last_user_activity < 3){
int fontAlpha = alpha; int fontAlpha = alpha;

View File

@@ -23,7 +23,7 @@ static const char* GAME_VERSION = "WTH?! 0.13.1 - by wololo";
#define DEFAULT_ANGLE_MULTIPLIER 0.4f #define DEFAULT_ANGLE_MULTIPLIER 0.4f
#define MAX_ANGLE_MULTIPLIER (3*M_PI) #define MAX_ANGLE_MULTIPLIER (3*M_PI)
#define MIN_ANGLE_MULTIPLIER 0.4f #define MIN_ANGLE_MULTIPLIER 0.4f
static const double STEP_ANGLE_MULTIPLIER = 0.0002; static const double STEP_ANGLE_MULTIPLIER = 0.0002f;
enum ENUM_MENU_STATE_MAJOR enum ENUM_MENU_STATE_MAJOR
@@ -102,7 +102,7 @@ void GameStateMenu::Create()
for (int i=0;i<5;i++){ for (int i=0;i<5;i++){
for (int j=0;j<2;j++){ for (int j=0;j<2;j++){
sprintf(buf,"menuicons%d%d",i,j); sprintf(buf,"menuicons%d%d",i,j);
mIcons[n] = resources.RetrieveQuad("menuicons.png", 2 + i*36, 2 + j*36, 32, 32,buf); mIcons[n] = resources.RetrieveQuad("menuicons.png", 2 + i * 36.0f, 2.0f + j * 36.0f, 32.0f, 32.0f, buf);
mIcons[n]->SetHotSpot(16,16); mIcons[n]->SetHotSpot(16,16);
n++; n++;
} }
@@ -517,17 +517,17 @@ void GameStateMenu::Update(float dt)
if (yW <= 55) if (yW <= 55)
{ {
if (mEngine->GetButtonState(JGE_BTN_PRI)) angleMultiplier += STEP_ANGLE_MULTIPLIER; if (mEngine->GetButtonState(JGE_BTN_PRI)) angleMultiplier += STEP_ANGLE_MULTIPLIER;
else angleMultiplier *= 0.9999; else angleMultiplier *= 0.9999f;
if (angleMultiplier > MAX_ANGLE_MULTIPLIER) angleMultiplier = MAX_ANGLE_MULTIPLIER; if (angleMultiplier > MAX_ANGLE_MULTIPLIER) angleMultiplier = MAX_ANGLE_MULTIPLIER;
else if (angleMultiplier < MIN_ANGLE_MULTIPLIER) angleMultiplier = MIN_ANGLE_MULTIPLIER; else if (angleMultiplier < MIN_ANGLE_MULTIPLIER) angleMultiplier = MIN_ANGLE_MULTIPLIER;
if (mEngine->GetButtonState(JGE_BTN_CANCEL) && (dt != 0)) if (mEngine->GetButtonState(JGE_BTN_CANCEL) && (dt != 0))
{ {
angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1 - angleW) / dt; angleMultiplier = (cos(timeIndex)*angleMultiplier - M_PI/3.0f - 0.1 - angleW) / dt;
yW = yW + 5*dt + (yW - 45) *5* dt; yW = yW + 5*dt + (yW - 45) *5* dt;
} }
else else
angleW = cos(timeIndex)*angleMultiplier - M_PI/3 - 0.1; angleW = cos(timeIndex)*angleMultiplier - M_PI/3.0f - 0.1f;
} }
else else
{ {
@@ -538,7 +538,7 @@ void GameStateMenu::Update(float dt)
scroller->Update(dt); scroller->Update(dt);
if((currentState & MENU_STATE_MINOR) == MENU_STATE_MINOR_FADEIN){ if((currentState & MENU_STATE_MINOR) == MENU_STATE_MINOR_FADEIN){
currentState = currentState ^ MENU_STATE_MINOR_FADEIN; currentState = currentState ^ MENU_STATE_MINOR_FADEIN;
mParent->DoAnimation(TRANSITION_FADE_IN,.15); mParent->DoAnimation( TRANSITION_FADE_IN, 0.15f );
} }
} }

View File

@@ -282,7 +282,7 @@ int GameStateShop::purchasePrice(int offset){
if(!pricelist || !srcCards || (c = srcCards->getCard(offset)) == NULL) if(!pricelist || !srcCards || (c = srcCards->getCard(offset)) == NULL)
return 0; return 0;
float price = (float) pricelist->getPurchasePrice(c->getMTGId()); float price = (float) pricelist->getPurchasePrice(c->getMTGId());
float filteradd = srcCards->Size(true); int filteradd = srcCards->Size(true);
filteradd = ((filteradd - srcCards->Size())/filteradd); filteradd = ((filteradd - srcCards->Size())/filteradd);
switch(options[Options::ECON_DIFFICULTY].number){ switch(options[Options::ECON_DIFFICULTY].number){
@@ -290,7 +290,7 @@ int GameStateShop::purchasePrice(int offset){
case Constants::ECON_HARD: filteradd *= 2; break; case Constants::ECON_HARD: filteradd *= 2; break;
default: break; default: break;
} }
return (int) price + price * (filteradd*srcCards->filterFee()); return (int) (price + price * (filteradd * srcCards->filterFee() ));
} }
void GameStateShop::updateCounts(){ void GameStateShop::updateCounts(){
for(int i=BOOSTER_SLOTS;i<SHOP_ITEMS;i++){ for(int i=BOOSTER_SLOTS;i<SHOP_ITEMS;i++){
@@ -390,7 +390,7 @@ void GameStateShop::Update(float dt)
if (menu && menu->closed) if (menu && menu->closed)
SAFE_DELETE(menu); SAFE_DELETE(menu);
srcCards->Update(dt); srcCards->Update(dt);
alphaChange = (500 - (rand() % 1000)) * dt; alphaChange = (500 - (int)((rand() % 1000)) * dt);
lightAlpha+= alphaChange; lightAlpha+= alphaChange;
if (lightAlpha < 0) lightAlpha = 0; if (lightAlpha < 0) lightAlpha = 0;
if (lightAlpha > 50) lightAlpha = 50; if (lightAlpha > 50) lightAlpha = 50;
@@ -587,13 +587,13 @@ void GameStateShop::Render()
float elp = srcCards->getElapsed(); float elp = srcCards->getElapsed();
//Render the card list overlay. //Render the card list overlay.
if( bListCards || elp > LIST_FADEIN){ if( bListCards || elp > LIST_FADEIN){
char alpha = 200; int alpha = 200;
if(!bListCards && elp < LIST_FADEIN+.25){ if(!bListCards && elp < LIST_FADEIN+.25){
alpha = 800 *(elp-LIST_FADEIN); alpha = 800 *(elp-LIST_FADEIN);
} }
r->FillRoundRect(300,10, 160, SHOP_SLOTS * 20 + 15,5,ARGB(alpha,0,0,0)); r->FillRoundRect(300,10, 160, SHOP_SLOTS * 20 + 15,5,ARGB(alpha,0,0,0));
alpha+=55; alpha += 55;
for(int i=0;i<SHOP_SLOTS;i++){ for(int i = 0; i < SHOP_SLOTS; i++){
if (i == shopMenu->getSelected()) if (i == shopMenu->getSelected())
mFont->SetColor(ARGB(alpha,255,255,0)); mFont->SetColor(ARGB(alpha,255,255,0));
else else

View File

@@ -17,7 +17,7 @@ GuiAvatars::GuiAvatars() : active(NULL)
GameObserver::GetInstance()->players[0], this)); GameObserver::GetInstance()->players[0], this));
Add(opponent = NEW GuiAvatar (0, 0, false, GameObserver::GetInstance()->players[1], GuiAvatar::TOP_LEFT, this)); Add(opponent = NEW GuiAvatar (0, 0, false, GameObserver::GetInstance()->players[1], GuiAvatar::TOP_LEFT, this));
opponent->zoom = 0.9; opponent->zoom = 0.9f;
//opponenthandveiw button //opponenthandveiw button
Add(opponentHand = NEW GuiOpponentHand(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, false, GameObserver::GetInstance()->players[1], this)); Add(opponentHand = NEW GuiOpponentHand(-30 + GuiAvatar::Width * 1.2 - GuiGameZone::Width / 2, 35 + GuiGameZone::Height - 10, false, GameObserver::GetInstance()->players[1], this));
//opponenthandveiwends //opponenthandveiwends
@@ -44,23 +44,37 @@ GuiAvatars::~GuiAvatars()
void GuiAvatars::Activate(PlayGuiObject* c) void GuiAvatars::Activate(PlayGuiObject* c)
{ {
c->zoom = 1.2; c->zoom = 1.2f;
c->mHasFocus = true; c->mHasFocus = true;
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c)|| (opponentHand == c) ) if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponent == c)|| (opponentHand == c) )
{ opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 128; active = opponent; opponent->zoom = 1.2;} {
opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 128.0f;
active = opponent;
opponent->zoom = 1.2f;
}
else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c)) else if ((selfGraveyard == c) || (selfLibrary == c) || (self == c))
{ selfGraveyard->alpha = selfLibrary->alpha = 128; self->zoom = 1.0; active = self; } {
if (opponent != c && self != c) c->alpha = 255; selfGraveyard->alpha = selfLibrary->alpha = 128.0f;
self->zoom = 1.0f;
active = self;
}
if (opponent != c && self != c) c->alpha = 255.0f;
} }
void GuiAvatars::Deactivate(PlayGuiObject* c) void GuiAvatars::Deactivate(PlayGuiObject* c)
{ {
c->zoom = 1.0; c->zoom = 1.0;
c->mHasFocus = false; c->mHasFocus = false;
if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c)) if ((opponentGraveyard == c) || (opponentLibrary == c) || (opponentHand == c) || (opponent == c))
{ opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0; opponent->zoom = 0.9; active = NULL;} {
opponentGraveyard->alpha = opponentLibrary->alpha = opponentHand->alpha = 0;
opponent->zoom = 0.9f;
active = NULL;}
else if ((selfGraveyard == c) || (selfLibrary == c) ||(self == c)) else if ((selfGraveyard == c) || (selfLibrary == c) ||(self == c))
{ selfGraveyard->alpha = selfLibrary->alpha = 0; self->zoom = 0.3; active = NULL;} { selfGraveyard->alpha = selfLibrary->alpha = 0;
self->zoom = 0.3f;
active = NULL;
}
} }
int GuiAvatars::receiveEventPlus(WEvent* e) int GuiAvatars::receiveEventPlus(WEvent* e)

View File

@@ -65,7 +65,7 @@ void GuiHandOpponent::Render()
{ {
(*it)->x = x; (*it)->x = x;
(*it)->y = 2; (*it)->y = 2;
(*it)->zoom = 0.3; (*it)->zoom = 0.3f;
(*it)->Render(quad); (*it)->Render(quad);
x += 18; x += 18;
} }
@@ -92,42 +92,46 @@ void GuiHandSelf::Repos()
float y = 48.0; float y = 48.0;
if (Closed == state && OptionClosedHand::VISIBLE == options[Options::CLOSEDHAND].number) if (Closed == state && OptionClosedHand::VISIBLE == options[Options::CLOSEDHAND].number)
{ {
float dist = 180.0 / cards.size(); if (dist > 20) dist = 20.0; else y = 40.0; float dist = 180.0f / cards.size();
if (dist > 20)
dist = 20.0;
else
y = 40.0;
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it) for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
{ {
(*it)->x = ClosedRowX; (*it)->y = y; (*it)->x = ClosedRowX; (*it)->y = y;
y += dist; y += dist;
} }
} }
else else
{ {
bool q = (Closed == state); bool q = (Closed == state);
if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number) if (OptionHandDirection::HORIZONTAL == options[Options::HANDDIRECTION].number)
{
y = SCREEN_WIDTH - 30;
float dist = 240.0 / cards.size(); if (dist > 30) dist = 30; else y = SCREEN_WIDTH - 15;
for (vector<CardView*>::reverse_iterator it = cards.rbegin(); it != cards.rend(); ++it)
{ {
y = SCREEN_WIDTH - 30; (*it)->x = y;
float dist = 240.0 / cards.size(); if (dist > 30) dist = 30; else y = SCREEN_WIDTH - 15; (*it)->y = SCREEN_HEIGHT - 30;
for (vector<CardView*>::reverse_iterator it = cards.rbegin(); it != cards.rend(); ++it) y -= dist;
{ (*it)->alpha = (q ? 0 : 255);
(*it)->x = y;
(*it)->y = SCREEN_HEIGHT - 30;
y -= dist;
(*it)->alpha = (q ? 0 : 255);
}
backpos.x = y + SCREEN_HEIGHT - 14;
} }
backpos.x = y + SCREEN_HEIGHT - 14;
}
else else
{
float dist = 224.0 / ((cards.size() + 1) / 2); if (dist > 65) dist = 65;
bool flip = false;
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it)
{ {
float dist = 224.0 / ((cards.size() + 1) / 2); if (dist > 65) dist = 65; (*it)->x = flip ? RightRowX : LeftRowX;
bool flip = false; (*it)->y = y;
for (vector<CardView*>::iterator it = cards.begin(); it != cards.end(); ++it) if (flip) y += dist;
{ flip = !flip;
(*it)->x = flip ? RightRowX : LeftRowX; (*it)->alpha = (q ? 0 : 255);
(*it)->y = y;
if (flip) y += dist;
flip = !flip;
(*it)->alpha = (q ? 0 : 255);
}
} }
}
} }
} }

View File

@@ -637,8 +637,8 @@ int MTGCardInstance::toggleDefenser(MTGCardInstance * opponent){
setDefenser(opponent); setDefenser(opponent);
didblocked = 1; didblocked = 1;
if(opponent && opponent->controller()->isAI()){ if(opponent && opponent->controller()->isAI()){
opponent->view->actZ += .8; opponent->view->actZ += .8f;
opponent->view->actT -= .2; opponent->view->actT -= .2f;
} }
if(!opponent) didblocked = 0; if(!opponent) didblocked = 0;
return 1; return 1;

View File

@@ -4,7 +4,7 @@
#include "GameOptions.h" #include "GameOptions.h"
#include "Translate.h" #include "Translate.h"
MenuItem::MenuItem(int id, WFont *font, string text, int x, int y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y) MenuItem::MenuItem(int id, WFont *font, string text, float x, float y, JQuad * _off, JQuad * _on, const char * particle, JQuad * particleTex, bool hasFocus): JGuiObject(id), mFont(font), mX(x), mY(y)
{ {
mText = _(text); mText = _(text);
updatedSinceLastRender = 1; updatedSinceLastRender = 1;

View File

@@ -22,19 +22,19 @@ PlayGuiObject::PlayGuiObject(float desiredHeight, const Pos& ref, bool hasFocus)
void PlayGuiObject::Update(float dt){ void PlayGuiObject::Update(float dt){
if (mHasFocus && mHeight < defaultHeight * 1.2) if (mHasFocus && mHeight < defaultHeight * 1.2)
{ {
mHeight += defaultHeight*0.8f*dt; mHeight += defaultHeight * 0.8f * dt;
// fprintf(stderr, "increasing size to %f - %d", mHeight, GetId() ); // fprintf(stderr, "increasing size to %f - %d", mHeight, GetId() );
if (mHeight > defaultHeight * 1.2) if (mHeight > defaultHeight * 1.2f)
mHeight = defaultHeight * 1.2; mHeight = defaultHeight * 1.2f;
} }
else if (!mHasFocus && mHeight > defaultHeight) else if (!mHasFocus && mHeight > defaultHeight)
{ {
mHeight -= defaultHeight*0.8f*dt; mHeight -= defaultHeight * 0.8f * dt;
if (mHeight < defaultHeight) if (mHeight < defaultHeight)
mHeight = defaultHeight; mHeight = defaultHeight;
} }
wave = (wave +2 * (int) (100 * dt) ) % 255; wave = (wave +2 * (int) (100 * dt) ) % 255;
for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it) for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
(*it)->Update(dt); (*it)->Update(dt);

View File

@@ -6,7 +6,8 @@
Pos::Pos(float x, float y, float z, float t, float a) : actX(x), actY(y), actZ(z), actT(t), actA(a), x(x), y(y), zoom(z), t(t), alpha(a) {} Pos::Pos(float x, float y, float z, float t, float a) : actX(x), actY(y), actZ(z), actT(t), actA(a), x(x), y(y), zoom(z), t(t), alpha(a) {}
void Pos::Update(float dt) void Pos::Update(float dt)
{ {
if (dt > 0.05) dt = 0.05; if (dt > 0.05f)
dt = 0.05;
actX += 10 * dt * (x - actX); actX += 10 * dt * (x - actX);
actY += 10 * dt * (y - actY); actY += 10 * dt * (y - actY);
actT += 10 * dt * (t - actT); actT += 10 * dt * (t - actT);

View File

@@ -157,7 +157,8 @@ void SimpleMenu::Update(float dt){
stars->Update(dt); stars->Update(dt);
selectionT += 3*dt; selectionT += 3*dt;
selectionY += (selectionTargetY - selectionY) * 8 * dt; selectionY += (selectionTargetY - selectionY) * 8 * dt;
stars->MoveTo(mX + kHorizontalMargin + ((mWidth-2*kHorizontalMargin)*(1+cos(selectionT))/2), selectionY + 5 * cos(selectionT*2.35) + kLineHeight / 2 - kLineHeight * startId); stars->MoveTo(mX + kHorizontalMargin + ((mWidth-2 * kHorizontalMargin) * (1+cos(selectionT))/2),
selectionY + 5 * cos( selectionT * 2.35f ) + kLineHeight / 2 - kLineHeight * startId);
if (timeOpen < 0) { if (timeOpen < 0) {
timeOpen += dt * 10; timeOpen += dt * 10;
if (timeOpen >= 0) { timeOpen = 0; closed = true; stars->FireAt(mX, mY); } if (timeOpen >= 0) { timeOpen = 0; closed = true; stars->FireAt(mX, mY); }

View File

@@ -368,12 +368,12 @@ StoryDialog::StoryDialog(TiXmlElement* root, StoryFlow * mParent):StoryPage(mPar
if (element) { if (element) {
string sX = safeAttribute(element, "x"); string sX = safeAttribute(element, "x");
float x = atof(sX.c_str()); float x = atof(sX.c_str());
if (x>0 && x < 1){ if (x > 0 && x < 1){
x = SCREEN_WIDTH_F * x; x = SCREEN_WIDTH_F * x;
} }
string sY = safeAttribute(element,"y"); string sY = safeAttribute(element,"y");
float y = atof(sY.c_str()); float y = atof(sY.c_str());
if (y>0 && y < 1){ if (y > 0 && y < 1){
y = SCREEN_HEIGHT_F * y; y = SCREEN_HEIGHT_F * y;
} }
string align = safeAttribute(element,"align"); string align = safeAttribute(element,"align");

View File

@@ -150,7 +150,7 @@ void Task::setExpiration(int _expiresIn) {
void Task::passOneDay() { void Task::passOneDay() {
expiresIn--; expiresIn--;
reward = (int) getReward() * 0.9; // Todo: degradation and minreward constants reward = (int) (getReward() * 0.9); // Todo: degradation and minreward constants
if (reward < 33) { if (reward < 33) {
reward = 33; reward = 33;
} }
@@ -417,13 +417,13 @@ void TaskList::Update(float dt) {
mElapsed += dt; mElapsed += dt;
if(mState == TASKS_IN && vPos < 0){ if(mState == TASKS_IN && vPos < 0){
vPos = -SCREEN_HEIGHT+(SCREEN_HEIGHT*mElapsed/.75); //Todo: more physical drop-in. vPos = -SCREEN_HEIGHT+(SCREEN_HEIGHT*mElapsed/0.75f); //Todo: more physical drop-in.
if(vPos >= 0){ if(vPos >= 0){
vPos = 0; vPos = 0;
mState = TaskList::TASKS_ACTIVE; mState = TaskList::TASKS_ACTIVE;
} }
}else if(mState == TASKS_OUT && vPos > -SCREEN_HEIGHT){ }else if(mState == TASKS_OUT && vPos > -SCREEN_HEIGHT){
vPos = -(SCREEN_HEIGHT*mElapsed/.75); vPos = -(SCREEN_HEIGHT*mElapsed/0.75f);
if(vPos <= -SCREEN_HEIGHT) if(vPos <= -SCREEN_HEIGHT)
mState = TASKS_INACTIVE; mState = TASKS_INACTIVE;
} }
@@ -639,7 +639,7 @@ int TaskDelay::computeReward() {
} }
void TaskDelay::randomize() { void TaskDelay::randomize() {
afterTurn = rand()%2; afterTurn = rand()%2 == 1;
turn = afterTurn ? rand()%15 + 20 : 15 - rand()%9; turn = afterTurn ? rand()%15 + 20 : 15 - rand()%9;
Task::randomize(); Task::randomize();
} }

View File

@@ -11,7 +11,7 @@ enum {
}; };
TextScroller::TextScroller(int fontId, float x, float y, float width, float speed, int scrollerType, int numItems ): JGuiObject(0), fontId(fontId){ TextScroller::TextScroller(int fontId, float x, float y, float width, float speed, int scrollerType, size_t numItems ): JGuiObject(0), fontId(fontId){
mWidth = width; mWidth = width;
mSpeed = speed; mSpeed = speed;
minimumItems = numItems; minimumItems = numItems;
@@ -65,7 +65,7 @@ void TextScroller::Update(float dt){
ostringstream scrollerText; ostringstream scrollerText;
if ( timer == 0 ) if ( timer == 0 )
{ {
size_t nbItemsToDisplay = ( static_cast <unsigned> (minimumItems) < strings.size() ? minimumItems : strings.size()); //MIN(minimumItems, strings.size()) size_t nbItemsToDisplay = ( minimumItems < strings.size() ? minimumItems : strings.size());
for ( size_t idx = 0; idx < nbItemsToDisplay; idx ++ ) for ( size_t idx = 0; idx < nbItemsToDisplay; idx ++ )
{ {
scrollerText << strings[currentId + idx]; scrollerText << strings[currentId + idx];
@@ -73,7 +73,7 @@ void TextScroller::Update(float dt){
currentId++; currentId++;
if ( currentId >= (strings.size()-1) ) if ( currentId >= (strings.size()-1) )
currentId = 0; currentId = 0;
mText = wordWrap( scrollerText.str(), mWidth ); mText = wordWrap( scrollerText.str(), (int) mWidth );
} }
timer = ++timer % ((int) mSpeed); timer = ++timer % ((int) mSpeed);
} }