From d3bde622f0e70e5b16f49535694274c39e9aacd0 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 21 Jun 2016 23:19:20 +0200 Subject: [PATCH] menu placing right --- CrystalPoint.cpp | 14 ++++++++++---- CrystalPoint.h | 1 + worlds/small.json | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CrystalPoint.cpp b/CrystalPoint.cpp index 6b59afd..65583c0 100644 --- a/CrystalPoint.cpp +++ b/CrystalPoint.cpp @@ -24,7 +24,7 @@ void CrystalPoint::init() cursor = Cursor::getInstance(); menu = new Menu(); - buildMenu(); + menuIsBuild = false; lastFrameTime = 0; state = true; @@ -158,6 +158,11 @@ void CrystalPoint::update() } else { + if (!menuIsBuild) + { + buildMenu(); + menuIsBuild = true; + } menu->update(); cursor->update(cursor->mousePosition + mouseOffset); } @@ -172,7 +177,7 @@ void CrystalPoint::update() void CrystalPoint::buildMenu() { - Button* start = new Button("Resume", Vec2f(1920 / 2 - 50, 1080 / 2 - 30), 100, 50); + Button* start = new Button("Resume", Vec2f(width / 2 - 50, height / 2 - 30), 100, 50); auto toWorld = [](Button* b) { state = true; @@ -181,13 +186,14 @@ void CrystalPoint::buildMenu() menu->AddMenuElement(start); - Button* test = new Button("Exit", Vec2f(1920 / 2 - 50, 1080 / 2 + 30), 100, 50); + Button* test = new Button("Exit", Vec2f(width / 2 - 50, height / 2 + 30), 100, 50); test->addAction([](Button* b) { exit(0); }); menu->AddMenuElement(test); - Text* t = new Text("Pause", Vec2f(1920 / 2 - Util::glutTextWidth("Pause") / 2, 1080 / 2 - 75)); + + Text* t = new Text("Pause", Vec2f(width / 2 - Util::glutTextWidth("Pause") / 2, height / 2 - 75)); t->setColor(Vec3f(255, 255, 0)); menu->AddMenuElement(t); } diff --git a/CrystalPoint.h b/CrystalPoint.h index 3ab6e53..2c739dc 100644 --- a/CrystalPoint.h +++ b/CrystalPoint.h @@ -43,6 +43,7 @@ public: static SoundSystem& GetSoundSystem() { return sound_system; } + bool menuIsBuild; private: static SoundSystem sound_system; diff --git a/worlds/small.json b/worlds/small.json index c80d509..3bcbb48 100644 --- a/worlds/small.json +++ b/worlds/small.json @@ -24,7 +24,7 @@ "file": "models/squid/Blooper.obj", "pos": [ 20, 5, 10 ], "scale": 0.01, - "music": "WAVE/ghostEnemy.wav" + "music": "WAVE/ghostEnemy.wav", "health": 10, "damage": 2 }, @@ -32,7 +32,7 @@ "file": "models/squid/Blooper.obj", "pos": [ 30, 10, 10 ], "scale": 0.01, - "music": "WAVE/ghostEnemy.wav" + "music": "WAVE/ghostEnemy.wav", "health": 15, "damage": 2 }],