14#include "mingl/shape/rectangle.h"
19using namespace nsShape;
20using namespace nsGraphics;
23 window << Rectangle(baseVector,
Position(180, 40)+baseVector, KGray);
28void PixelManager::drawMenu(
const Position& pos,
Menu& currentMenu){
32 drawText(
Position(10, 692),
"tips:",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
33 drawText(
Position(10, 702),
"use 'z','s','q','d' and 'enter' to navigate the menus",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
34 drawText(
Position(10, 712),
"see the configuration file for player specific key bindings",nsGraphics::KWhite,Font::BITMAP_8_BY_13);
38 for(
string& value : currentMenu.
entries ){
47void PixelManager::drawMenu(
const Position& pos,
Menu& currentMenu,
const vector<ScoreLink>& rankings,
const WinValue& winner){
56 else drawText(
Position(0-55,0-20)+ pos,
"God won, as His power are infinite",nsGraphics::KWhite);
57 for(
string& value : currentMenu.
entries ){
64 for (
auto& value: rankings){
65 drawText(
Position(0,400+margin),value.name,nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
66 drawText(
Position(140,400+margin),to_string(value.score),nsGraphics::KWhite,Font::BITMAP_HELVETICA_12);
73 vector<string> entries {
"single player",
"multi player (local)",
"exit"};
74 Menu initialMenu {entries, 0, nsGraphics::KRed, nsGraphics::KWhite};
77 chrono::milliseconds waitTime = chrono::milliseconds(100);
79 drawMenu(
Position(yOffset, xOffset), initialMenu);
81 if (
window.isPressed({
's', false})){
82 ++initialMenu.selectedEntry;
83 if (initialMenu.selectedEntry > initialMenu.entries.size() - 1) initialMenu.selectedEntry = 0;
84 this_thread::sleep_for(waitTime);
87 if (
window.isPressed({
'z', false})){
88 if (initialMenu.selectedEntry == 0) initialMenu.selectedEntry = initialMenu.entries.size() - 1;
89 else --initialMenu.selectedEntry;
90 this_thread::sleep_for(waitTime);
92 else if (
window.isPressed({13, false})){
93 switch(initialMenu.selectedEntry){
109 name = string(6,
'A');
110 unsigned currentSelected = 0 ;
111 chrono::milliseconds waitTime = chrono::milliseconds(100);
117 for (
unsigned i = 0; i < name.size(); ++i){
119 (i == currentSelected) ? nsGraphics::KRed : nsGraphics::KWhite);
123 if (
window.isPressed({
's', false})){
124 ++name[currentSelected];
125 if (name[currentSelected] > 90) name[currentSelected] = 65;
126 this_thread::sleep_for(waitTime);
129 if (
window.isPressed({
'z', false})){
130 --name[currentSelected];
131 if (name[currentSelected] < 65) name[currentSelected] = 90;
132 this_thread::sleep_for(waitTime);
135 if (
window.isPressed({
'd', false})){
137 if (currentSelected > name.size()-1) currentSelected = 0;
138 this_thread::sleep_for(waitTime);
141 if (
window.isPressed({
'q', false})){
142 if (currentSelected == 0) currentSelected = name.size()-1;
143 else --currentSelected;
144 this_thread::sleep_for(waitTime);
147 else if (
window.isPressed({13, false}))
149 window.resetKey({13,
false});
157 vector<string> entries {
"retry",
"main menu"};
158 Menu death {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
161 chrono::milliseconds waitTime = chrono::milliseconds(100);
163 drawMenu(
Position(yOffset, xOffset), death, rankings, winner);
165 if (
window.isPressed({
's', false})){
166 ++death.selectedEntry;
167 if (death.selectedEntry > death.entries.size() - 1) death.selectedEntry = 0;
168 this_thread::sleep_for(waitTime);
171 if (
window.isPressed({
'z', false})){
172 if (death.selectedEntry == 0) death.selectedEntry = death.entries.size() - 1;
173 else --death.selectedEntry;
174 this_thread::sleep_for(waitTime);
176 else if (
window.isPressed({13, false})){
177 switch(death.selectedEntry){
182 window.resetKey({13,
false});
void startFrame() const
clear the screen for a new frame
void drawSprite(const MySprite &msp, const Position &pos) const
display a sprite on screen
MySprite menuBackground
sprite of the background during menu
PlayMode showInitialMenu()
show the title screen of the game
void displayButton(const Position &baseVector, const string &text, nsGraphics::RGBAcolor &color)
display a menu button on screen
void endFrame() const
finish a frame render
void drawText(const Position &pos, const string &text, const RGBAcolor &color=nsGraphics::KWhite, Font font=Font::BITMAP_TIMES_ROMAN_24) const
display text on screen
unsigned getScreenHeight() const
give the height of the screen
unsigned getScreenWidth() const
give the width of the screen
MySprite logo
sprite of the logo of the game
MinGL & window
display window
bool showDeathMenu(const vector< ScoreLink > &rankings, const WinValue &winner)
show the menu after a player lose, or all invader has been defeated
void askPlayerNameMenu(playerID pID, unsigned score, string &name)
display the player name selection menu
PlayMode
List of all game playmode.
nsGraphics::Vec2D Position
WinValue
list of win values