Merge remote-tracking branch 'origin/master'
This commit is contained in:
		
						commit
						978f0e4df7
					
				| @ -16,7 +16,6 @@ players: | ||||
|    right: 6 | ||||
|    shoot: 5 | ||||
| 
 | ||||
| 
 | ||||
| # Enemies config | ||||
| invaders: | ||||
|  size: 15 | ||||
| @ -31,3 +30,8 @@ projectiles: | ||||
|  torpedos: | ||||
|   speed: 2 | ||||
|   width: 10 | ||||
| 
 | ||||
| points: | ||||
|  invader3: 100 | ||||
|  invader2: 250 | ||||
|  invader1: 600 | ||||
| @ -4,6 +4,8 @@ | ||||
| struct Player{ | ||||
| 	unsigned lives; | ||||
| 	unsigned x; | ||||
| 	unsigned id; | ||||
| 	unsigned score; | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
| @ -3,14 +3,14 @@ | ||||
| 
 | ||||
| #include<vector> | ||||
| #include<mingl/mingl.h> | ||||
| #include "position.h" | ||||
| #include"position.h" | ||||
| 
 | ||||
| // hardcoded values
 | ||||
| #define PLAYER_HEIGHT 100 | ||||
| #define PROJ_LENGTH_FACTOR 2 | ||||
| 
 | ||||
| enum WinValue{ | ||||
| 	NOBODY, // should never be used, but hey
 | ||||
| 	NOBODY, // should never be used
 | ||||
| 	PLAYERS, | ||||
| 	INVADERS, | ||||
| }; | ||||
| @ -22,7 +22,12 @@ typedef vector<Alien> aliensLine; | ||||
| typedef vector<aliensLine> aliensGrid; | ||||
| 
 | ||||
| typedef position missile; | ||||
| typedef position torpedo; | ||||
| 
 | ||||
| class torpedo : public nsGraphics::Vec2D { | ||||
| public: | ||||
| 	topedo(int x, int y); | ||||
| 	unsigned playerID; | ||||
| }; | ||||
| 
 | ||||
| // didn't want to use position because of the semantic with x and y
 | ||||
| bool lineCollideCheck(unsigned start1, unsigned end1, unsigned start2, unsigned end2); | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
| 
 | ||||
| #define ISPRESSED(X) window.isPressed({X, false}) | ||||
| 
 | ||||
| void Game::managePlayerMoves(PlayerDef& pdef, unsigned& playerX){ | ||||
| void Game::managePlayerMoves(PlayerDef& pdef, unsigned& playerX, unsigned playerId){ | ||||
| 	if (ISPRESSED(pdef.keys.left)){ | ||||
| 		if(playerX < confData.playersSpeed) playerX = 0; | ||||
| 		else playerX = playerX - confData.playersSpeed; | ||||
| @ -16,15 +16,15 @@ void Game::managePlayerMoves(PlayerDef& pdef, unsigned& playerX){ | ||||
| 		else playerX = playerX + confData.playersSpeed; | ||||
| 	} | ||||
| 	if(ISPRESSED(pdef.keys.shoot)){ | ||||
| 		torpedos.emplace_back(playerX + confData.playersWidth / 2, pm.getScreenHeight() - PLAYER_HEIGHT); | ||||
| 		torpedos.emplace_back(playerX + confData.playersWidth / 2, pm.getScreenHeight() - PLAYER_HEIGHT, playerId ); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| /** Makes the players play once
 | ||||
| */ | ||||
| void Game::managePlayers(){ | ||||
| 	managePlayerMoves(confData.p1Def, p1.x); | ||||
| 	if(playMode==PlayMode::TWO_LOCAL)managePlayerMoves(confData.p2Def, p2.x); | ||||
| 	managePlayerMoves(confData.p1Def, p1.x,p1.id); | ||||
| 	if(playMode==PlayMode::TWO_LOCAL)managePlayerMoves(confData.p2Def, p2.x, p2.id); | ||||
| } | ||||
| 
 | ||||
| /** Makes the invaders play once, and check lower bounds
 | ||||
|  | ||||
| @ -1,5 +1,7 @@ | ||||
| #include "utils.h" | ||||
| 
 | ||||
| torpedo::torpedo(int x, int y) : position(x, y) {} | ||||
| 
 | ||||
| bool lineCollideCheck(unsigned start1, unsigned end1, unsigned start2, unsigned end2){ | ||||
| 	return start1 < end2 != start2 < end1; | ||||
| 	// if true, are colliding. I like truth tables
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user