This commit is contained in:
Thomas 2022-01-12 22:30:51 +01:00
parent 16220d754a
commit 8b89320830
No known key found for this signature in database
GPG Key ID: E538821A6CDFDAD7
21 changed files with 49 additions and 41 deletions

View File

@ -17,7 +17,7 @@
#include "invaderDef.h"
#include "invadersGrid.h"
typedef string configKey;
typedef std::string configKey;
/*!
@ -29,7 +29,7 @@ struct ConfigData {
/*!
* @brief theme to use. Valid values : good,bad
*/
string theme;
std::string theme;
/*!
* @brief maximum framerate at which the game will run
@ -69,7 +69,7 @@ struct ConfigData {
/*!
* @brief players configuration
*/
vector<PlayerDef> playerDefs;
std::vector<PlayerDef> playerDefs;
/*!
* @brief invader movement speed
@ -94,7 +94,7 @@ struct ConfigData {
/*!
* @brief link between an invader type, and its data
*/
map<InvaderType, InvaderTypeDef> invadersDef;
std::map<InvaderType, InvaderTypeDef> invadersDef;
/*!
* @brief invaders missiles width in pixel

View File

@ -34,7 +34,7 @@ public:
* @fn void parseFile(const string& fname);
* @param[in] fname: file to read from
*/
void parseFile(const string& fname);
void parseFile(const std::string& fname);
/*!
* @brief read the values in collectedData and put them in the collectedData object
@ -51,7 +51,7 @@ private:
/*!
* @brief key/values (all strings) collected by the parser, and fed to the get* methods
*/
map<string, string> internalValues;
std::map<std::string, std::string> internalValues;
/*!
* @brief read a string, or return the default argument if not found (safe from config read errors)
@ -59,14 +59,14 @@ private:
* @param[in] key: key to read from
* @param[in] def: default value to use
*/
const string& getString(const configKey& key, const string& def) const;
const std::string& getString(const configKey& key, const std::string& def) const;
/*!
* @brief read a string
* @fn const string& getString(const configKey& key) const;
* @param[in] key: key to read from
*/
const string& getString(const configKey& key) const;
const std::string& getString(const configKey& key) const;
/*!
* @brief read a char, or return the default argument if not found (safe from config read errors)
@ -123,7 +123,7 @@ private:
* @param[in] baseKey: key to read from
* @param[out] vec: vector to write list contents to
*/
void getList(const configKey& baseKey, vector<string>& vec) const;
void getList(const configKey& baseKey, std::vector<std::string>& vec) const;
/*!

View File

@ -46,7 +46,7 @@ private:
* @brief PixelManager : Class that contains and draws all the data that will be drawn on screen
* This is a pointer because the object is allocated at runtime, following the configuration
*/
unique_ptr<PixelManager> pm;
std::unique_ptr<PixelManager> pm;
/*!
* @brief ConfigData : Struct that stores all the relevant data read from the configuration file
@ -81,12 +81,12 @@ private:
/*!
* @brief list of positions of all missiles shot by the invaders
*/
vector<missile> missiles;
std::vector<missile> missiles;
/*!
* @brief list of positions of all torpedoes shot by the player(s)
*/
vector<Torpedo> torpedos;
std::vector<Torpedo> torpedos;
/*!
* @brief Define the current type of the game
@ -96,7 +96,7 @@ private:
/*!
* @brief list of all player data
*/
vector<Player> players;
std::vector<Player> players;
// invaders related variables

View File

@ -27,7 +27,7 @@ class GoodPixelManager : public PixelManager{
* @param[out] tasks : vectot of task
* @fn void loadSprites();
*/
void loadSprites(vector<Task>& tasks) override;
void loadSprites(std::vector<Task>& tasks) override;
/*!
* @brief sprite of the first player

View File

@ -14,8 +14,6 @@
#include<vector>
using namespace std;
/*!
* @brief List of all invader type
*/
@ -30,7 +28,7 @@ enum class InvaderType {
* @class InvadersColumn
* @brief Column of invader
*/
class InvadersColumn : public vector<InvaderType>{
class InvadersColumn : public std::vector<InvaderType>{
public:
/*!
* @brief tells if the column contains no non type NONE invader
@ -59,7 +57,7 @@ public:
* @class InvadersColumn
* @brief Column of invader
*/
class InvadersGrid : public vector<InvadersColumn>{
class InvadersGrid : public std::vector<InvadersColumn>{
public:
/*!

View File

@ -15,8 +15,6 @@
#include<vector>
#include<string>
using namespace std;
/*!
* @struct Menu
* @brief menu stuct
@ -25,7 +23,7 @@ struct Menu{
/*!
* @brief list of all menu options
*/
vector<string> entries;
std::vector<std::string> entries;
/*!
* @brief index of currently selected menu option

View File

@ -16,8 +16,6 @@
#include "mingl/gui/sprite.h"
#include "utils.h"
using namespace std;
class MySprite{
public:
/*!
@ -27,14 +25,14 @@ public:
* so we modify it each time we need to draw it
* Else, we could copy the Sprite each time, but copying a bunch of images each frame doesn't seems like a good idea
*/
mutable optional<nsGui::Sprite> sp;
mutable std::optional<nsGui::Sprite> sp;
/*!
* @brief load a sprite asynchronously
* @fn Task asyncLoad(const string& fname);
* @returns An async task of the loading action
*/
Task asyncLoad(const string& fname);
Task asyncLoad(const std::string& fname);
/*!
* @brief Mirror a sprite pixel data into this one

View File

@ -53,7 +53,7 @@ public:
* @param[in] tasks : vectot of task
* @fn void loadSprites();
*/
virtual void loadSprites(vector<Task>& tasks);
virtual void loadSprites(std::vector<Task>& tasks);
/*!
* @brief sprite of the logo of the game
@ -166,7 +166,7 @@ public:
* @param[in] color : color of the text inside the button
* @fn void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
*/
void displayButton(const Position& baseVector,const string& text,nsGraphics::RGBAcolor& color);
void displayButton(const Position& baseVector, const std::string& text,nsGraphics::RGBAcolor& color);
/*!
* @brief display text on screen
@ -176,7 +176,7 @@ public:
* @param[in] font : the glut font to use for the text
* @fn void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
*/
void drawText(const Position& pos, const string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
void drawText(const Position& pos, const std::string& text, const RGBAcolor& color = nsGraphics::KWhite, Font font = Font::BITMAP_TIMES_ROMAN_24) const;
/*!
* @brief show the title screen of the game
@ -192,7 +192,7 @@ public:
* @param[in] winner : the winner of the game
* @fn bool showDeathMenu();
*/
bool showDeathMenu(const vector<ScoreLink>& rankings,const WinValue& winner);
bool showDeathMenu(const std::vector<ScoreLink>& rankings,const WinValue& winner);
/*!
* @brief give the height of the screen
@ -227,7 +227,7 @@ public:
* @param[out] name : name selected by the player
* @fn void askPlayerNameMenu(playerID pID, unsigned score, string& name);
*/
void askPlayerNameMenu(playerID pID, unsigned score, string& name);
void askPlayerNameMenu(playerID pID, unsigned score, std::string& name);
// y will be negative sometimes, so not unsigned
@ -264,7 +264,7 @@ private:
* @param[in] winner : the winner of the game
* @fn void drawMenu(const Position& pos, Menu& currentMenu);
*/
void drawMenu(const Position& pos, Menu& currentMenu, const vector<ScoreLink>& rankings, const WinValue& winner);
void drawMenu(const Position& pos, Menu& currentMenu, const std::vector<ScoreLink>& rankings, const WinValue& winner);
};

View File

@ -16,8 +16,6 @@
#include<string>
#include "utils.h"
using namespace std;
/*!
* @struct ScoreLink
* @brief Makes a link between a player username and their score
@ -27,7 +25,7 @@ struct ScoreLink{
/*!
* @brief player username
*/
string name;
std::string name;
/*!
* @brief player score
@ -40,7 +38,7 @@ struct ScoreLink{
* @param[in] score : player score
* @fn ScoreLink(string name, unsigned score);
*/
ScoreLink(string name, unsigned score);
ScoreLink(std::string name, unsigned score);
};
@ -54,7 +52,7 @@ public:
/*!
* @brief list of pairs of player names and their score
*/
vector<ScoreLink> scores;
std::vector<ScoreLink> scores;
/*!
* @brief add player name and their score in the list of scores
@ -62,7 +60,7 @@ public:
* @param[in] score : player score
* @fn void inputScore(string name, unsigned score);
*/
void inputScore(string name, unsigned score);
void inputScore(std::string name, unsigned score);
/*!
* @brief read the score file and put all of its data inside the list of score

View File

@ -33,8 +33,6 @@
#define DEBUG_INSTR(X)
#endif
using nsGraphics::RGBAcolor;
/*!
* @brief list of win values
*/
@ -49,6 +47,7 @@ enum class WinValue{
typedef nsGraphics::Vec2D Position;
typedef unsigned playerID;
typedef std::future<void> Task;
typedef nsGraphics::RGBAcolor RGBAcolor;
#define PLAYER1 0
#define PLAYER2 1

View File

@ -14,6 +14,7 @@
#include "configManagement.h"
#include "errors.h"
using namespace std;
void trimSpaces(string& str){
str.erase(0, str.find_first_not_of(' '));

View File

@ -11,6 +11,7 @@
#include "game.h"
using namespace std;
/** Displays the screen once, and returns
* The more important stuff must be drawn last

View File

@ -15,6 +15,7 @@
#include "utils.h"
#include "god.h"
using namespace std;
using namespace nsShape;
using namespace nsGui;

View File

@ -16,6 +16,7 @@
#include "pixelManager.h"
#include "utils.h"
using namespace std;
using namespace nsShape;
using namespace nsGraphics;

View File

@ -15,6 +15,8 @@
#include "playMode.h"
#include "goodPixelManager.h"
using namespace std;
#define WININIT window("SUPER Space Invader : Turbo Apocalypse DX - VS GOD", Position(1280, 720) /*for some reason I can't use the winSize member here*/, Position(128, 128), nsGraphics::KBlack)
Game::Game() : WININIT {

View File

@ -10,6 +10,8 @@
#include "game.h"
using namespace std;
void Game::tryAwakeGod() {
if (baseInvPos.getY() > 100 /*lambda value*/ && god.state == GodState::NONE) {
god.counter = 0;

View File

@ -10,7 +10,9 @@
#include "goodPixelManager.h"
void GoodPixelManager::loadSprites(vector<Task>& tasks) {
using namespace std;
void GoodPixelManager::loadSprites(std::vector<Task>& tasks) {
PixelManager::loadSprites(tasks);
ADD_SPRITE_TASK(player1)
ADD_SPRITE_TASK(player2)

View File

@ -11,6 +11,8 @@
#include<iostream>
#include "invadersGrid.h"
using namespace std;
bool InvadersColumn::hasNoValid() const {
return getOutterInvader()==size();
}

View File

@ -11,6 +11,8 @@
#include "utils.h"
#include "mySprite.h"
using namespace std;
Task MySprite::asyncLoad(const string& fname){
DEBUG_MSG("Load file " << fname)
return std::async(std::launch::async, [fname, this]() -> void {

View File

@ -13,6 +13,7 @@
#include "pixelManager.h"
using namespace std;
void PixelManager::loadSprites(vector<Task>& tasks){
ADD_SPRITE_TASK(logo)

View File

@ -14,6 +14,8 @@
#include <utility>
#include "scoresManager.h"
using namespace std;
// Our own format : kustom
#define SCORE_FILE "scores.kus"
@ -28,7 +30,7 @@ void readWholeFile(const ifstream& ifs, string& str){
static std::hash<string> hasher;
bool verifyHash(size_t savedHash, const string& content){
// non-cryptographic hash, but it is part of the std, and openssl is REALLY difficult
// non-cryptographic hash and non-cross-plateform, but it is part of the std, and openssl is REALLY difficult
// to use in C++ while keeping semantic, because there are no wrappers...
size_t actualHash = hasher(content+SECRET_KEY);
return actualHash==savedHash;