drawmenu
This commit is contained in:
parent
a22ae07829
commit
52d9972c93
@ -2,3 +2,5 @@ nom du joueur ecran 100*100 sans effacer le reste
|
|||||||
le joueur est gros
|
le joueur est gros
|
||||||
basevector a change en variable x
|
basevector a change en variable x
|
||||||
projectile style fusée
|
projectile style fusée
|
||||||
|
|
||||||
|
|
||||||
|
13
headers/menu.h
Normal file
13
headers/menu.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef GUARD_MENU_H
|
||||||
|
#define GUARD_MENU_H
|
||||||
|
#include"vector"
|
||||||
|
#include"string"
|
||||||
|
|
||||||
|
struct Menu{
|
||||||
|
vector<string> entries;
|
||||||
|
size_t currentValue = 0;
|
||||||
|
nsGraphics::RGBAcolor selectedColor;
|
||||||
|
nsGraphics::RGBAcolor unSelectedColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -11,6 +11,7 @@
|
|||||||
#include "mingl/gui/text.h"
|
#include "mingl/gui/text.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "playMode.h"
|
#include "playMode.h"
|
||||||
|
#include "menu.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -45,11 +46,14 @@ public:
|
|||||||
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawMissile(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
void drawTorpedo(const Position& baseVector, unsigned width, const nsGraphics::RGBAcolor& color) const;
|
||||||
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
|
void drawSprite(const nsGui::Sprite& sprite, const Position& pos) const;
|
||||||
|
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
|
||||||
|
void displayText(const Position& pos, const string& text,const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||||
|
void displayMenu(const Position& pos, Menu& currentMenu);
|
||||||
void drawBackground() const;
|
void drawBackground() const;
|
||||||
|
|
||||||
void drawFPS(unsigned fps) const;
|
void drawFPS(unsigned fps) const;
|
||||||
|
|
||||||
PlayMode showInitialMenu() const;
|
PlayMode showInitialMenu();
|
||||||
bool showDeathMenu() const;
|
bool showDeathMenu() const;
|
||||||
unsigned getScreenHeight() const;
|
unsigned getScreenHeight() const;
|
||||||
unsigned getScreenWidth() const;
|
unsigned getScreenWidth() const;
|
||||||
|
@ -108,6 +108,10 @@ void PixelManager::drawGodLeftHand(const Position& pos, bool closed) const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelManager::displayText(const Position& pos, const string& text,const nsGraphics::RGBAcolor& color) const {
|
||||||
|
window << nsGui::Text(pos, text, color);
|
||||||
|
}
|
||||||
|
|
||||||
void PixelManager::drawFPS(unsigned fps) const {
|
void PixelManager::drawFPS(unsigned fps) const {
|
||||||
window << nsGui::Text(Position(getScreenWidth()-100, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite);
|
window << nsGui::Text(Position(getScreenWidth()-100, 10), "FPS : "+ to_string(fps), nsGraphics::KWhite);
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,60 @@
|
|||||||
#include "pixelManager.h"
|
#include "pixelManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "god.h"
|
#include "god.h"
|
||||||
|
#include "mingl/shape/rectangle.h"
|
||||||
|
|
||||||
PlayMode PixelManager::showInitialMenu() const {
|
using namespace nsShape;
|
||||||
return PlayMode::SINGLE;
|
using namespace nsGraphics;
|
||||||
|
|
||||||
|
void PixelManager::displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color){
|
||||||
|
window << Rectangle(Position(190, 430)+baseVector, Position(310, 465)+baseVector, KGray);
|
||||||
|
window << Rectangle(Position(188, 428)+baseVector, Position(312, 467)+baseVector, KBlack);
|
||||||
|
window << nsGui::Text(Vec2D(200, 450)+baseVector, text, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||||
|
startFrame();
|
||||||
|
size_t margin = 0;
|
||||||
|
size_t cpt = 0;
|
||||||
|
for(auto& value : currentMenu.entries ){
|
||||||
|
displayButton(Position(0,0+margin)+ pos, value, (currentMenu.currentValue == cpt) ? currentMenu.selectedColor : currentMenu.unSelectedColor );
|
||||||
|
++cpt;
|
||||||
|
margin += 50;
|
||||||
|
}
|
||||||
|
endFrame();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayMode PixelManager::showInitialMenu(){
|
||||||
|
//return PlayMode::SINGLE; // will remove
|
||||||
|
vector<string> entries {"single player","multi player (local)","EXIT"};
|
||||||
|
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||||
|
while(true){
|
||||||
|
displayMenu(Position(100,100),initial);
|
||||||
|
// dessends
|
||||||
|
if (window.isPressed({'s', false})){
|
||||||
|
++initial.currentValue;
|
||||||
|
if (initial.currentValue > initial.entries.size()) initial.currentValue = 0;
|
||||||
|
}
|
||||||
|
// monte
|
||||||
|
if (window.isPressed({'z', false}))
|
||||||
|
if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1;
|
||||||
|
else --initial.currentValue;
|
||||||
|
|
||||||
|
|
||||||
|
else if (window.isPressed({13, false})){
|
||||||
|
switch(initial.currentValue){
|
||||||
|
case 0:
|
||||||
|
return PlayMode::SINGLE;
|
||||||
|
case 1:
|
||||||
|
return PlayMode::TWO_LOCAL;
|
||||||
|
case 2:
|
||||||
|
return PlayMode::EXIT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PixelManager::showDeathMenu() const {
|
bool PixelManager::showDeathMenu() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user