piew piew (from player only, fuck you invaders, also torpedos are invisibles)

This commit is contained in:
Thomas 2021-12-26 20:17:36 +01:00
parent 9e74ca9ecd
commit bad10aea4d
No known key found for this signature in database
GPG Key ID: E538821A6CDFDAD7
8 changed files with 35 additions and 11 deletions

View File

@ -20,6 +20,7 @@ public:
unsigned player_width;
unsigned alien_speed;
unsigned player_speed;
bool loadConfig();
};

View File

@ -2,7 +2,7 @@
#define GUARD_GAME_H
#include <vector>
#include "mingl/mingl.h"
#include "pixelManager.h"
#include "pixel_manager.h"
#include "config.h"
#include "utils.h"
#include "position.h"
@ -11,6 +11,7 @@ using namespace std;
class Game {
private:
MinGL window;
PixelManager pm;
Config conf;

View File

@ -9,8 +9,8 @@
class PixelManager{
public:
MinGL window;
PixelManager();
MinGL& window;
explicit PixelManager(MinGL&);
void dessinerInvader1(const nsGraphics::Vec2D& baseVector, unsigned size);
void dessinerInvader2(const nsGraphics::Vec2D& baseVector, unsigned size);
void dessinerInvader3(const nsGraphics::Vec2D& baseVector, unsigned size);

View File

@ -10,13 +10,14 @@ bool Config::loadConfig() {
alien_size = 20;
distance = 5;
alien_speed = 1;
player_speed = 2;
missile_width = 10;
missile_length = 15;
torpedo_width = 10;
torpedo_length = 15;
player_width = 50;
player_width = 1000;
return true;
}

View File

@ -2,7 +2,10 @@
#include <thread>
#include "game.h"
Game::Game() {
#define WININIT window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack)
Game::Game() : WININIT, pm(window) {
conf.loadConfig();
}

View File

@ -7,7 +7,17 @@
/** Makes the player play once
*/
void Game::managePlayer(){
if (window.isPressed({'q', false})){
if(playerX < conf.player_speed) playerX = 0;
else playerX = playerX-conf.player_speed;
}
if (window.isPressed({'d', false})){
if(playerX+conf.player_speed>=pm.getScreenWidth()) playerX = pm.getScreenWidth()-1;
else playerX = playerX+conf.player_speed;
}
if(window.isPressed({' ', false})){
torpedos.emplace_back(playerX+conf.player_width/2, pm.getScreenHeight()-PLAYER_HEIGHT);
}
}
/** Makes the invaders play once, and check lower bounds

View File

@ -2,8 +2,18 @@
#include "game.h"
using namespace std;
#define C "space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack
class Test{
public:
MinGL a;
PixelManager pm;
Test() : a(C), pm(a) {
}
};
int main(){
Game g;
Game g;
g.managedGames();
return 0;

View File

@ -1,9 +1,7 @@
#include "pixelManager.h"
#include "pixel_manager.h"
#include "utils.h"
#define WININIT window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack)
PixelManager::PixelManager() : WININIT {
PixelManager::PixelManager(MinGL& a) : window(a) {
window.initGlut();
window.initGraphic();
}