finished for this morning
This commit is contained in:
		
							parent
							
								
									d52a491cd0
								
							
						
					
					
						commit
						a39266b044
					
				| @ -1,12 +1,12 @@ | ||||
| #ifndef SPACE_CONFIG | ||||
| #define SPACE_CONFIG | ||||
| #ifndef GUARD_CONFIG | ||||
| #define GUARD_CONFIG | ||||
| 
 | ||||
| #include<vector> | ||||
| 
 | ||||
| using namespace std; | ||||
| 
 | ||||
| struct Config{ | ||||
| 	vector<vector<unsigned>> grid; | ||||
| 	aliensGrid grid; | ||||
| 
 | ||||
| 	unsigned alien_size; | ||||
| 	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 | ||||
| #define game | ||||
| #ifndef GUARD_GAME | ||||
| #define GUARD_GAME | ||||
| #include <vector> | ||||
| #include "mingl/mingl.h" | ||||
| #include "sprites.h" | ||||
| #include "drawEngine.h" | ||||
| #include "config.h" | ||||
| 
 | ||||
| using namespace std; | ||||
| @ -13,20 +13,20 @@ typedef vector<aliensLine> aliensGrid; | ||||
| 
 | ||||
| class Game { | ||||
| private: | ||||
|     MinGL window; | ||||
|     DrawEngine drawer; | ||||
| 	Config conf; | ||||
| 	unsigned baseX; | ||||
| 	unsigned baseY; | ||||
| 	vector<vector<TypeAlien>> aliens; | ||||
|     matriceAlien grid; | ||||
| 	aliensGrid grid; | ||||
|     vector<nsGraphics::Vec2D> missiles; | ||||
|     vector<nsGraphics::Vec2D> torpilles; | ||||
| 
 | ||||
| 	void loadConfig(); | ||||
| 
 | ||||
| 	unsigned manageCollisions(); | ||||
| 	void managePlayer(); | ||||
| 	bool manageInvaders(); | ||||
| 	void display(); | ||||
| 	void importConfig(); | ||||
| 	void summon(); | ||||
| 	void deleteEntity(); | ||||
| 	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(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); | ||||
| @ -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(60, 50)+baseVector, 50, nsGraphics::KRed); | ||||
|     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); | ||||
| } | ||||
| 
 | ||||
| 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(50, 50)+baseVector, 50, nsGraphics::KGreen); | ||||
|     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); | ||||
| } | ||||
| 
 | ||||
| sprites joueur(); | ||||
| sprites missile(); | ||||
| sprites torpille(); | ||||
| 
 | ||||
| @ -3,8 +3,7 @@ | ||||
| Game::Game() : | ||||
|     window("space invader du turfu ma gueule", nsGraphics::Vec2D(1280, 720), nsGraphics::Vec2D(128, 128), nsGraphics::KBlack) { | ||||
| 
 | ||||
| 	this->window.initGlut(); | ||||
| 	this->window.initGraphic(); | ||||
| 	loadConfig(); | ||||
| } | ||||
| 
 | ||||
| void Game::managedGame() { | ||||
| @ -46,10 +45,13 @@ unsigned Game::playGame(){ // returns when game is finished | ||||
| /** Displays the screen once, and returns
 | ||||
|  * | ||||
|  */ | ||||
| void Game::display(){ | ||||
|     for(aliensLine& line : this->grid){ | ||||
|         for(Alien& al : line){ | ||||
|             pixelManager.dessinerInvader1(this->window, alien.coord); | ||||
|         } | ||||
|     } | ||||
| void Game::display() { | ||||
| 	for (unsigned i = 0; i < this->grid.size(); ++i){ | ||||
| 		for (unsigned j = 0; j < this->grid[0].size(); ++j){ | ||||
| 			drawer.dessinerInvader1(nsGraphics::Vec2D( | ||||
| 				baseX+j*conf.alien_size+j*conf.distance, | ||||
| 				baseY+i*conf.alien_size+i*conf.distance | ||||
| 			)); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| @ -12,4 +12,12 @@ void Game::managePlayer(){ | ||||
| bool Game::manageInvaders(){ | ||||
| 	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; | ||||
| 
 | ||||
| int main(){ | ||||
|     Game g(); | ||||
|     Game g; | ||||
| 	g.managedGame(); | ||||
|     return 0; | ||||
| } | ||||
| @ -1 +0,0 @@ | ||||
| #include "space.h" | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user