finished for this morning
This commit is contained in:
parent
d52a491cd0
commit
a39266b044
@ -1,12 +1,12 @@
|
|||||||
#ifndef SPACE_CONFIG
|
#ifndef GUARD_CONFIG
|
||||||
#define SPACE_CONFIG
|
#define GUARD_CONFIG
|
||||||
|
|
||||||
#include<vector>
|
#include<vector>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct Config{
|
struct Config{
|
||||||
vector<vector<unsigned>> grid;
|
aliensGrid grid;
|
||||||
|
|
||||||
unsigned alien_size;
|
unsigned alien_size;
|
||||||
unsigned distance;
|
unsigned distance;
|
||||||
|
19
headers/drawEngine.h
Normal file
19
headers/drawEngine.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef GUARD_DRAWENGINE
|
||||||
|
#define GUARD_DRAWENGINE
|
||||||
|
|
||||||
|
#include "mingl/mingl.h"
|
||||||
|
#include "mingl/shape/line.h"
|
||||||
|
#include "mingl/shape/triangle.h"
|
||||||
|
#include "mingl/shape/rectangle.h"
|
||||||
|
#include "mingl/shape/circle.h"
|
||||||
|
|
||||||
|
class DrawEngine{
|
||||||
|
public:
|
||||||
|
MinGL window;
|
||||||
|
void dessinerInvader1(const nsGraphics::Vec2D& baseVector);
|
||||||
|
void dessinerInvader2(const nsGraphics::Vec2D& baseVector);
|
||||||
|
void dessinerInvader3(const nsGraphics::Vec2D& baseVector);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef game
|
#ifndef GUARD_GAME
|
||||||
#define game
|
#define GUARD_GAME
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "mingl/mingl.h"
|
#include "mingl/mingl.h"
|
||||||
#include "sprites.h"
|
#include "drawEngine.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -13,20 +13,20 @@ typedef vector<aliensLine> aliensGrid;
|
|||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
private:
|
private:
|
||||||
MinGL window;
|
DrawEngine drawer;
|
||||||
Config conf;
|
Config conf;
|
||||||
unsigned baseX;
|
unsigned baseX;
|
||||||
unsigned baseY;
|
unsigned baseY;
|
||||||
vector<vector<TypeAlien>> aliens;
|
aliensGrid grid;
|
||||||
matriceAlien grid;
|
|
||||||
vector<nsGraphics::Vec2D> missiles;
|
vector<nsGraphics::Vec2D> missiles;
|
||||||
vector<nsGraphics::Vec2D> torpilles;
|
vector<nsGraphics::Vec2D> torpilles;
|
||||||
|
|
||||||
|
void loadConfig();
|
||||||
|
|
||||||
unsigned manageCollisions();
|
unsigned manageCollisions();
|
||||||
void managePlayer();
|
void managePlayer();
|
||||||
bool manageInvaders();
|
bool manageInvaders();
|
||||||
void display();
|
void display();
|
||||||
void importConfig();
|
|
||||||
void summon();
|
void summon();
|
||||||
void deleteEntity();
|
void deleteEntity();
|
||||||
void invaderMovement();
|
void invaderMovement();
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#ifndef space
|
|
||||||
#define space
|
|
||||||
|
|
||||||
void display(CVString & space, entites & pos_entites);
|
|
||||||
|
|
||||||
void initTerminalSpace (CVString & space, entites & liste_pos);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,29 +0,0 @@
|
|||||||
#ifndef sprites
|
|
||||||
#define sprites
|
|
||||||
|
|
||||||
#include "mingl/mingl.h"
|
|
||||||
#include "mingl/shape/line.h"
|
|
||||||
#include "mingl/shape/triangle.h"
|
|
||||||
#include "mingl/shape/rectangle.h"
|
|
||||||
#include "mingl/shape/circle.h"
|
|
||||||
|
|
||||||
enum typeA{
|
|
||||||
vert,
|
|
||||||
rouge,
|
|
||||||
bleu,
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
sprites envahisseurUn();
|
|
||||||
sprites envahisseurDeux();
|
|
||||||
sprites envahisseurTrois();
|
|
||||||
sprites joueur();
|
|
||||||
sprites missile();
|
|
||||||
sprites torpille();
|
|
||||||
*/
|
|
||||||
|
|
||||||
void dessinerInvader1(MinGL& window, const nsGraphics::Vec2D& baseVector);
|
|
||||||
void dessinerInvader2(MinGL& window, const nsGraphics::Vec2D& baseVector);
|
|
||||||
void dessinerInvader3(MinGL& window, const nsGraphics::Vec2D& baseVector);
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,8 +0,0 @@
|
|||||||
//
|
|
||||||
// Created by itrooz on 16/12/2021.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef SPACE_TYPEALIEN_H
|
|
||||||
#define SPACE_TYPEALIEN_H
|
|
||||||
|
|
||||||
#endif //SPACE_TYPEALIEN_H
|
|
@ -1,7 +1,11 @@
|
|||||||
#include "sprite.h"
|
#include "drawEngine.h"
|
||||||
|
|
||||||
void dessinerInvader1(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
void DrawEngine::DrawEngine(){
|
||||||
|
window.initGlut();
|
||||||
|
window.initGraphic();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawEngine::dessinerInvader1(const nsGraphics::Vec2D& baseVector){
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KGray);
|
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KGray);
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KGray);
|
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KGray);
|
||||||
window << nsShape::Triangle(nsGraphics::Vec2D(35, 50)+baseVector, nsGraphics::Vec2D(15, 25)+baseVector, nsGraphics::Vec2D(15, 75)+baseVector, nsGraphics::KBlack);
|
window << nsShape::Triangle(nsGraphics::Vec2D(35, 50)+baseVector, nsGraphics::Vec2D(15, 25)+baseVector, nsGraphics::Vec2D(15, 75)+baseVector, nsGraphics::KBlack);
|
||||||
@ -12,7 +16,7 @@ void dessinerInvader1(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dessinerInvader2(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
void DrawEngine::dessinerInvader2(const nsGraphics::Vec2D& baseVector){
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KRed);
|
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KRed);
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KRed);
|
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KRed);
|
||||||
window << nsShape::Rectangle(nsGraphics::Vec2D(25, 30)+baseVector, nsGraphics::Vec2D(45, 40)+baseVector, nsGraphics::KBlack);
|
window << nsShape::Rectangle(nsGraphics::Vec2D(25, 30)+baseVector, nsGraphics::Vec2D(45, 40)+baseVector, nsGraphics::KBlack);
|
||||||
@ -20,7 +24,7 @@ void dessinerInvader2(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
|||||||
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
||||||
}
|
}
|
||||||
|
|
||||||
void dessinerInvader3(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
void DrawEngine::dessinerInvader3(const nsGraphics::Vec2D& baseVector){
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KGreen);
|
window << nsShape::Circle(nsGraphics::Vec2D(60, 50)+baseVector, 50, nsGraphics::KGreen);
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KGreen);
|
window << nsShape::Circle(nsGraphics::Vec2D(50, 50)+baseVector, 50, nsGraphics::KGreen);
|
||||||
window << nsShape::Circle(nsGraphics::Vec2D(35, 35)+baseVector, 10, nsGraphics::KBlack);
|
window << nsShape::Circle(nsGraphics::Vec2D(35, 35)+baseVector, 10, nsGraphics::KBlack);
|
||||||
@ -28,7 +32,3 @@ void dessinerInvader3(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
|||||||
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprites joueur();
|
|
||||||
sprites missile();
|
|
||||||
sprites torpille();
|
|
||||||
|
|
@ -3,8 +3,7 @@
|
|||||||
Game::Game() :
|
Game::Game() :
|
||||||
window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack) {
|
window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack) {
|
||||||
|
|
||||||
this->window.initGlut();
|
loadConfig();
|
||||||
this->window.initGraphic();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::managedGame() {
|
void Game::managedGame() {
|
||||||
@ -46,10 +45,13 @@ unsigned Game::playGame(){ // returns when game is finished
|
|||||||
/** Displays the screen once, and returns
|
/** Displays the screen once, and returns
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void Game::display(){
|
void Game::display() {
|
||||||
for(aliensLine& line : this->grid){
|
for (unsigned i = 0; i < this->grid.size(); ++i){
|
||||||
for(Alien& al : line){
|
for (unsigned j = 0; j < this->grid[0].size(); ++j){
|
||||||
pixelManager.dessinerInvader1(this->window, alien.coord);
|
drawer.dessinerInvader1(nsGraphics::Vec2D(
|
||||||
|
baseX+j*conf.alien_size+j*conf.distance,
|
||||||
|
baseY+i*conf.alien_size+i*conf.distance
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,3 +13,11 @@ bool Game::manageInvaders(){
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** makes projectile smove, and manage collisions between everything
|
||||||
|
*
|
||||||
|
* @return true if the invaders crossed the first line of the grid, else false
|
||||||
|
*/
|
||||||
|
unsigned Game::manageCollisions(){
|
||||||
|
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
Game g();
|
Game g;
|
||||||
g.managedGame();
|
g.managedGame();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1 +0,0 @@
|
|||||||
#include "space.h"
|
|
Loading…
Reference in New Issue
Block a user