From 881b58138c6119e0df0f3c3b27a3d358939d6bc1 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Jun 2016 13:08:14 +0200 Subject: [PATCH] crystal displayed on interface, with fancy gradient and the most beautifull colors for the crystal :) --- Interface.cpp | 17 +++++++++++++++++ Player.cpp | 1 + Player.h | 1 + World.cpp | 3 ++- worlds/small.json | 8 +++++--- 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Interface.cpp b/Interface.cpp index 85d2778..9a3d498 100644 --- a/Interface.cpp +++ b/Interface.cpp @@ -77,6 +77,23 @@ void Interface::draw() glColor4f(1.0f, 1.0f, 0.1f, 1.0); glutBitmapString("Level: " + std::to_string(player->level), 490, 900); + + + int cw, ch, offset; + cw = 20; + ch = 50; + offset = 5; + for (int i = 0; i < player->crystals; i++) + { + glBegin(GL_QUADS); + glColor4f(0, 1.0f, 1.0f, 1.0f); + glVertex2f(975 - cw / 2, offset*i + ch*i); + glVertex2f(975 - cw , ch / 2 + offset*i + ch*i); + glColor4f(0, 0.8f, 0.8f, 1.0f); + glVertex2f(975 - cw / 2, ch + offset*i + ch*i); + glVertex2f(975 , ch / 2 + offset*i + ch*i); + glEnd(); + } } void Interface::update(float deltaTime) diff --git a/Player.cpp b/Player.cpp index f905e93..f6de1c3 100644 --- a/Player.cpp +++ b/Player.cpp @@ -11,6 +11,7 @@ Player::Player() health = 50; xp = 75; level = 10; + crystals = 0; } Player* Player::getInstance() diff --git a/Player.h b/Player.h index 18d3fb8..374d1dd 100644 --- a/Player.h +++ b/Player.h @@ -26,6 +26,7 @@ public: float health; float xp; int level; + int crystals; float speed; }; \ No newline at end of file diff --git a/World.cpp b/World.cpp index 042a9c9..42c1a0b 100644 --- a/World.cpp +++ b/World.cpp @@ -220,9 +220,10 @@ void World::update(float elapsedTime) } for(auto &crystal : crystals) - if (crystal->canCollide && crystal->inObject(player->position)) + if (crystal->canCollide && crystal->inObject(player->position) && crystal->filled) { crystal->filled = false; + player->crystals++; break; } } diff --git a/worlds/small.json b/worlds/small.json index b33c9b4..685c370 100644 --- a/worlds/small.json +++ b/worlds/small.json @@ -17,9 +17,11 @@ "crystals": [ { "file": "models/sphere/sphere.obj", - "pos": [ 33, 2, 31 ], - "collide": "true" + "pos": [ 33, 2, 31 ] + }, + { + "file": "models/sphere/sphere.obj", + "pos": [ 45, 2, 31 ] } ] - } \ No newline at end of file