buttons shows when ever the cursor is in the button
This commit is contained in:
+12
-2
@@ -9,6 +9,8 @@ Button::Button(const std::string & text, Vec2f position, float width, float heig
|
|||||||
this->height = height;
|
this->height = height;
|
||||||
this->planePosition = position;
|
this->planePosition = position;
|
||||||
|
|
||||||
|
cursorOnButton = false;
|
||||||
|
alfa = 0.5f;
|
||||||
background = Vec3f(10, 10, 10);
|
background = Vec3f(10, 10, 10);
|
||||||
//foreground = Vec3f(255, 255, 255);
|
//foreground = Vec3f(255, 255, 255);
|
||||||
this->setColor(Vec3f(255, 255, 255));
|
this->setColor(Vec3f(255, 255, 255));
|
||||||
@@ -24,7 +26,7 @@ Button::~Button()
|
|||||||
void Button::draw(void)
|
void Button::draw(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
glColor4f(background.x/255.0f, background.y / 255.0f, background.z / 255.0f, 1.0f);
|
glColor4f(background.x/255.0f, background.y / 255.0f, background.z / 255.0f, alfa);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(planePosition.x, planePosition.y);
|
glVertex2f(planePosition.x, planePosition.y);
|
||||||
@@ -40,7 +42,15 @@ void Button::draw(void)
|
|||||||
|
|
||||||
void Button::update(int x, int y)
|
void Button::update(int x, int y)
|
||||||
{
|
{
|
||||||
//Nothing
|
cursorOnButton =
|
||||||
|
(x > planePosition.x && x < planePosition.x + width) &&
|
||||||
|
y > planePosition.y && y < planePosition.y + height;
|
||||||
|
|
||||||
|
|
||||||
|
if (cursorOnButton)
|
||||||
|
alfa = 1.0f;
|
||||||
|
else
|
||||||
|
alfa = 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Button::setForeground(Vec3f color)
|
void Button::setForeground(Vec3f color)
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ private:
|
|||||||
float width, height;
|
float width, height;
|
||||||
Vec3f background;
|
Vec3f background;
|
||||||
Vec2f planePosition;
|
Vec2f planePosition;
|
||||||
|
bool cursorOnButton;
|
||||||
|
float alfa;
|
||||||
public:
|
public:
|
||||||
Button(const std::string &text, Vec2f position, float width, float height);
|
Button(const std::string &text, Vec2f position, float width, float height);
|
||||||
~Button();
|
~Button();
|
||||||
|
|||||||
+2
-2
@@ -88,9 +88,9 @@ void CrystalPoint::update()
|
|||||||
if (!worldhandler->isPlayerPositionValid())
|
if (!worldhandler->isPlayerPositionValid())
|
||||||
player->position = oldPosition;
|
player->position = oldPosition;
|
||||||
|
|
||||||
player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 1.7f;
|
//player->position.y = worldhandler->getHeight(player->position.x, player->position.z) + 1.7f;
|
||||||
|
|
||||||
worldhandler->update(deltaTime);
|
//worldhandler->update(deltaTime);
|
||||||
|
|
||||||
cursor->update(cursor->mousePosition + mouseOffset);
|
cursor->update(cursor->mousePosition + mouseOffset);
|
||||||
menu->update();
|
menu->update();
|
||||||
|
|||||||
Reference in New Issue
Block a user