progress de la classe game
This commit is contained in:
parent
d40f802f7a
commit
9d4f1f640a
8
README
8
README
@ -1 +1,7 @@
|
||||
Hey there
|
||||
Conventions à suivre :
|
||||
camelCase pour les noms de variables/fonctions/fichiers
|
||||
PascalCase pour les noms de classes/structures
|
||||
Nommage en anglais
|
||||
Pas de fonctions de +100 lignes
|
||||
|
||||
écran : constante 1280x720
|
||||
|
@ -3,13 +3,6 @@ screen:
|
||||
# specifies the screen resolution, must in 16:9,
|
||||
# default : "1280x720"
|
||||
#! hardcoder une res de base si c'est pas un 16:9
|
||||
resolution:
|
||||
screen:
|
||||
- "1920"
|
||||
- "1080"
|
||||
terminal:
|
||||
- 10
|
||||
- 10
|
||||
terminal:
|
||||
charEmptySpace: ' '
|
||||
charPlayer: ''
|
||||
|
@ -1,16 +0,0 @@
|
||||
#ifndef entites
|
||||
#define entites
|
||||
|
||||
void summonEntity(entites & pos_entites, pos & coordonees);
|
||||
|
||||
void deleteEntity(entites & pos_entites, pos & coordonees);
|
||||
|
||||
void invaderMovement(entites & pos_entites);
|
||||
|
||||
void torpilleMovement(entites & pos_entites);
|
||||
|
||||
void Collision(entites & pos_entites);
|
||||
|
||||
void userInteraction(entites & pos_entites);
|
||||
|
||||
#endif
|
42
headers/game.h
Normal file
42
headers/game.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef game
|
||||
#define game
|
||||
#include <vector>
|
||||
#include "mingl/mingl.h"
|
||||
#include "sprites.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
enum TypeAlien {
|
||||
typeUn,
|
||||
typeDeux,
|
||||
typeTrois
|
||||
};
|
||||
|
||||
struct Alien{
|
||||
TypeAlien type;
|
||||
nsGraphics::Vec2D coord;
|
||||
};
|
||||
|
||||
typedef vector<Alien> ligneEntite;
|
||||
typedef vector<ligneEntite> matriceAlien;
|
||||
|
||||
class Game {
|
||||
private:
|
||||
MinGL window;
|
||||
matriceAlien grid;
|
||||
vector<nsGraphics::Vec2D>missiles;
|
||||
vector<nsGraphics::Vec2D>torpilles;
|
||||
public:
|
||||
Game();
|
||||
void display();
|
||||
void importConfig();
|
||||
void summon();
|
||||
void deleteEntity();
|
||||
void invaderMovement();
|
||||
void torpilleMovement();
|
||||
void collision();
|
||||
void userInteraction();
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,12 +1,29 @@
|
||||
#ifndef sprites
|
||||
#define sprites
|
||||
#include "mingl/mingl.h"
|
||||
|
||||
#include "mingl/mingl.h"
|
||||
#include "mingl/shape/line.h"
|
||||
#include "mingl/shape/triangle.h"
|
||||
#include "mingl/shape/rectangle.g"
|
||||
#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
|
3
main.cpp
3
main.cpp
@ -1,6 +1,9 @@
|
||||
#include <iostream>
|
||||
#include "game.h"
|
||||
using namespace std;
|
||||
|
||||
int main(){
|
||||
Game jeu();
|
||||
jeu.display();
|
||||
return 0;
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#include<string>
|
||||
#include "entites.h"
|
||||
#include <mingl/mingl.h>
|
||||
|
||||
struct pos {
|
||||
int x;
|
||||
int y;
|
||||
};
|
||||
|
||||
struct entites {
|
||||
vector<pos> torpille = vector<pos>(0);
|
||||
vector<pos> missile = vector<pos>(0);
|
||||
pos joueur;
|
||||
vector<pos> envahisseur= vector<pos>(0);
|
||||
string direction;
|
||||
};
|
23
src/game.cpp
Normal file
23
src/game.cpp
Normal file
@ -0,0 +1,23 @@
|
||||
#include "game.h"
|
||||
|
||||
Game::Game() :
|
||||
window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack)
|
||||
{
|
||||
// init la fentre
|
||||
|
||||
this->window.initGlut();
|
||||
this->window.initGraphic();
|
||||
// init les amlien
|
||||
Alien tamer {typeUn,{0,0}};
|
||||
ligneEntite tmp(0);
|
||||
tmp.push_back(tamer);
|
||||
this->grid.push_back(tmp);
|
||||
}
|
||||
|
||||
void Game::display(){
|
||||
for(ligneEntite & ligne : this->grid){
|
||||
for( Alien & alien : ligne){
|
||||
dessinerInvader1(this->window, alien.coord);
|
||||
}
|
||||
}
|
||||
}
|
34
src/sprites.cpp
Normal file
34
src/sprites.cpp
Normal file
@ -0,0 +1,34 @@
|
||||
#include "sprite.h"
|
||||
|
||||
void dessinerInvader1(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
||||
|
||||
window << nsShape::Circle(nsGraphics::Vec2D(50, 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(25, 50)+baseVector, nsGraphics::Vec2D(10, 25)+baseVector, nsGraphics::Vec2D(10, 75)+baseVector, nsGraphics::KGray);
|
||||
window << nsShape::Triangle(nsGraphics::Vec2D(75, 50)+baseVector, nsGraphics::Vec2D(95, 25)+baseVector, nsGraphics::Vec2D(95, 75)+baseVector, nsGraphics::KBlack);
|
||||
window << nsShape::Triangle(nsGraphics::Vec2D(85, 50)+baseVector, nsGraphics::Vec2D(100, 25)+baseVector, nsGraphics::Vec2D(100, 75)+baseVector, nsGraphics::KGray);
|
||||
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
||||
|
||||
}
|
||||
|
||||
void dessinerInvader2(MinGL& window, const nsGraphics::Vec2D& baseVector){
|
||||
window << nsShape::Circle(nsGraphics::Vec2D(50, 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(65, 30)+baseVector, nsGraphics::Vec2D(85, 40)+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){
|
||||
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(35, 35)+baseVector, 10, nsGraphics::KBlack);
|
||||
window << nsShape::Circle(nsGraphics::Vec2D(75, 35)+baseVector, 10, nsGraphics::KBlack);
|
||||
window << nsShape::Rectangle(nsGraphics::Vec2D(35, 65)+baseVector, nsGraphics::Vec2D(75, 72)+baseVector, nsGraphics::KBlack);
|
||||
}
|
||||
|
||||
sprites joueur();
|
||||
sprites missile();
|
||||
sprites torpille();
|
||||
|
Loading…
Reference in New Issue
Block a user