Files
wagic/projects/mtg/src/PlayGuiObject.cpp
wrenczes@gmail.com a06558be55 Some warning cleanup involving (seemlingly unintended) bool to int conversions. It seems that the original design intent was to pass down IDs to the base class JGuiObject, but certain classes broke the pattern with their constructors.
(One could argue that this ID is completely meaningless and could be entirely ripped out, as the IDs obviously never made it to their intended target...)
2011-06-02 05:33:45 +00:00

51 lines
1.4 KiB
C++

#include "PrecompiledHeader.h"
#include "PlayGuiObject.h"
using namespace std;
PlayGuiObject::PlayGuiObject(float desiredHeight, float x, float y, int inID, bool hasFocus)
: JGuiObject(inID), Pos(x, y, 1.0, 0.0, 255)
{
defaultHeight = desiredHeight;
mHeight = desiredHeight;
mHasFocus = hasFocus;
type = 0;
wave = 0;
}
PlayGuiObject::PlayGuiObject(float desiredHeight, const Pos& ref, int inID, bool hasFocus)
: JGuiObject(inID), Pos(ref)
{
defaultHeight = desiredHeight;
mHeight = desiredHeight;
mHasFocus = hasFocus;
type = 0;
wave = 0;
}
void PlayGuiObject::Update(float dt)
{
if (mHasFocus && mHeight < defaultHeight * 1.2f)
{
mHeight += defaultHeight * 0.8f * dt;
// fprintf(stderr, "increasing size to %f - %d", mHeight, GetId() );
if (mHeight > defaultHeight * 1.2f) mHeight = defaultHeight * 1.2f;
}
else if (!mHasFocus && mHeight > defaultHeight)
{
mHeight -= defaultHeight * 0.8f * dt;
if (mHeight < defaultHeight) mHeight = defaultHeight;
}
wave = (wave + 2 * (int) (100 * dt)) % 255;
for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
(*it)->Update(dt);
Pos::Update(dt);
}
void PlayGuiObject::Render()
{
for (vector<Effect*>::iterator it = effects.begin(); it != effects.end(); ++it)
(*it)->Render();
}