main title almost screen done
This commit is contained in:
parent
a2c9d40d4d
commit
6faffb7baf
BIN
assets/logo.si2
Normal file
BIN
assets/logo.si2
Normal file
Binary file not shown.
BIN
assets/menu_background.si2
Normal file
BIN
assets/menu_background.si2
Normal file
Binary file not shown.
@ -25,11 +25,13 @@ public:
|
|||||||
* Sprites are not const because for some reason the texture is associated with coordinates,
|
* Sprites are not const because for some reason the texture is associated with coordinates,
|
||||||
* and we have no way to dissociate them...
|
* and we have no way to dissociate them...
|
||||||
* So the objects are constantly updated with new coordinates as they need to be drawn
|
* So the objects are constantly updated with new coordinates as they need to be drawn
|
||||||
* We used {} insead of {} for the constructor because the () makes the compiler think we declare methods
|
* We used {} insead of () for the constructor because the () makes the compiler think we declare methods
|
||||||
*
|
*
|
||||||
* (We could copy them every time, but I feel like copying image data every frame isn't great)
|
* (We could copy them every time, but I feel like copying image data every frame isn't great)
|
||||||
*/
|
*/
|
||||||
nsGui::Sprite background{"assets/bg.si2"};
|
nsGui::Sprite logo{"assets/logo.si2"};
|
||||||
|
nsGui::Sprite gameBackground{"assets/game_background.si2"};
|
||||||
|
nsGui::Sprite menuBackground{"assets/menu_background.si2"};
|
||||||
nsGui::Sprite rightHand{"assets/hand_open.si2"};
|
nsGui::Sprite rightHand{"assets/hand_open.si2"};
|
||||||
nsGui::Sprite leftHand{MIRROR(rightHand)};
|
nsGui::Sprite leftHand{MIRROR(rightHand)};
|
||||||
|
|
||||||
@ -49,7 +51,8 @@ public:
|
|||||||
// TODO remove because unused ?
|
// TODO remove because unused ?
|
||||||
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
void displayText(const Position& pos, const string& text, const nsGraphics::RGBAcolor& color = nsGraphics::KWhite) const;
|
||||||
void displayMenu(const Position& pos, Menu& currentMenu);
|
void displayMenu(const Position& pos, Menu& currentMenu);
|
||||||
void drawBackground() const;
|
void drawGameBackground() const;
|
||||||
|
void drawMenuBackground() const;
|
||||||
|
|
||||||
void drawFPS(unsigned fps) const;
|
void drawFPS(unsigned fps) const;
|
||||||
|
|
||||||
|
@ -76,8 +76,12 @@ void PixelManager::drawSprite(const Sprite& sprite, const Position& pos) const {
|
|||||||
sprite.draw(window);
|
sprite.draw(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PixelManager::drawBackground() const {
|
void PixelManager::drawGameBackground() const {
|
||||||
background.draw(window);
|
gameBackground.draw(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PixelManager::drawMenuBackground() const {
|
||||||
|
menuBackground.draw(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned PixelManager::getScreenHeight() const {
|
unsigned PixelManager::getScreenHeight() const {
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
#include <playMode.h>
|
#include <playMode.h>
|
||||||
#include "pixelManager.h"
|
#include "pixelManager.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -15,6 +17,8 @@ void PixelManager::displayButton(const Position& baseVector,const string& text,n
|
|||||||
|
|
||||||
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
||||||
startFrame();
|
startFrame();
|
||||||
|
drawMenuBackground();
|
||||||
|
drawSprite(logo,Position(100,50));
|
||||||
size_t margin = 0;
|
size_t margin = 0;
|
||||||
size_t cpt = 0;
|
size_t cpt = 0;
|
||||||
for(string& value : currentMenu.entries ){
|
for(string& value : currentMenu.entries ){
|
||||||
@ -26,22 +30,25 @@ void PixelManager::displayMenu(const Position& pos, Menu& currentMenu){
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayMode PixelManager::showInitialMenu(){
|
PlayMode PixelManager::showInitialMenu(){
|
||||||
//return PlayMode::SINGLE; // will remove
|
|
||||||
vector<string> entries {"single player","multi player (local)","EXIT"};
|
vector<string> entries {"single player","multi player (local)","EXIT"};
|
||||||
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
Menu initial {entries,0,nsGraphics::KRed,nsGraphics::KWhite};
|
||||||
|
const unsigned xOffset = getScreenHeight() / 2;
|
||||||
|
const unsigned yOffset = getScreenWidth() / 2;
|
||||||
|
chrono::milliseconds waitTime = chrono::milliseconds(100);
|
||||||
while(true){
|
while(true){
|
||||||
displayMenu(Position(100,100),initial);
|
displayMenu(Position(350,0),initial);
|
||||||
// dessends
|
// go down
|
||||||
if (window.isPressed({'s', false})){
|
if (window.isPressed({'s', false})){
|
||||||
++initial.currentValue;
|
++initial.currentValue;
|
||||||
if (initial.currentValue > initial.entries.size()) initial.currentValue = 0;
|
if (initial.currentValue > initial.entries.size()) initial.currentValue = 0;
|
||||||
|
this_thread::sleep_for(waitTime);
|
||||||
}
|
}
|
||||||
// monte
|
// go up
|
||||||
if (window.isPressed({'z', false}))
|
if (window.isPressed({'z', false})){
|
||||||
if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1;
|
if (initial.currentValue == 0) initial.currentValue = initial.entries.size()-1;
|
||||||
else --initial.currentValue;
|
else --initial.currentValue;
|
||||||
|
this_thread::sleep_for(waitTime);
|
||||||
|
}
|
||||||
else if (window.isPressed({13, false})){
|
else if (window.isPressed({13, false})){
|
||||||
switch(initial.currentValue){
|
switch(initial.currentValue){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
* The more important stuff must be drawn last
|
* The more important stuff must be drawn last
|
||||||
*/
|
*/
|
||||||
void Game::displayAll(unsigned fps) const {
|
void Game::displayAll(unsigned fps) const {
|
||||||
pm.drawBackground();
|
pm.drawGameBackground();
|
||||||
for (unsigned i = 0; i < this->grid.size(); ++i){
|
for (unsigned i = 0; i < this->grid.size(); ++i){
|
||||||
for (unsigned j = 0; j < this->grid[i].size(); ++j){
|
for (unsigned j = 0; j < this->grid[i].size(); ++j){
|
||||||
Position vec(
|
Position vec(
|
||||||
|
Loading…
Reference in New Issue
Block a user