Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of https://github.com/ch0m5/Project_1
Browse files Browse the repository at this point in the history
  • Loading branch information
ch0m5 committed May 7, 2018
2 parents 7d745b2 + dd6d4c3 commit 2b8f392
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 64 deletions.
112 changes: 98 additions & 14 deletions Andro_Dunos/ModuleInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,61 @@ update_status ModuleInput::PreUpdate()
}

//CONTROLLER INPUT
for (int i = 0; i < SDL_NumJoysticks(); ++i) {
if (SDL_IsGameController(i))
for (int i = 0; i < SDL_NumJoysticks(); ++i)
{
if (SDL_IsGameController(i))
{
gamepadP1 = SDL_GameControllerOpen(i);
if (SDL_GameControllerGetAttached(gamepadP1)) {
gamepadP1LAxisX = SDL_GameControllerGetAxis(gamepadP1, SDL_CONTROLLER_AXIS_LEFTX);
gamepadP1LAxisY = SDL_GameControllerGetAxis(gamepadP1, SDL_CONTROLLER_AXIS_LEFTY);
gamepadP1APressed = SDL_GameControllerGetButton(gamepadP1, SDL_CONTROLLER_BUTTON_A);
gamepadP1XPressed = SDL_GameControllerGetButton(gamepadP1, SDL_CONTROLLER_BUTTON_X);
gamepadP1con = true;
break;
if (i == 0)
{
if (SDL_IsGameController(i))
{
gamepadP1 = SDL_GameControllerOpen(i);
if (SDL_GameControllerGetAttached(gamepadP1))
{
gamepadP1LAxisX = SDL_GameControllerGetAxis(gamepadP1, SDL_CONTROLLER_AXIS_LEFTX);
gamepadP1LAxisY = SDL_GameControllerGetAxis(gamepadP1, SDL_CONTROLLER_AXIS_LEFTY);
gamepadP1APressed = SDL_GameControllerGetButton(gamepadP1, SDL_CONTROLLER_BUTTON_A);
gamepadP1XPressed = SDL_GameControllerGetButton(gamepadP1, SDL_CONTROLLER_BUTTON_X);
gamepadP1StartPressed = SDL_GameControllerGetButton(gamepadP1, SDL_CONTROLLER_BUTTON_START);
gamepadP1con = true;
}
else
{
SDL_GameControllerClose(gamepadP1);
gamepadP1 = nullptr;
gamepadP1con = false;
}
}
}
else if (i<1)
{
gamepadP2con=false;
SDL_GameControllerClose(gamepadP2);
gamepadP2 = nullptr;
gamepadP2con = false;
}
else
else if (i == 1 || i == 0 && gamepadP1con == false)
{
SDL_GameControllerClose(gamepadP1);
gamepadP1 = nullptr;
gamepadP1con = false;
if (SDL_IsGameController(i))
{
gamepadP2 = SDL_GameControllerOpen(i);
if (SDL_GameControllerGetAttached(gamepadP2))
{
gamepadP2LAxisX = SDL_GameControllerGetAxis(gamepadP2, SDL_CONTROLLER_AXIS_LEFTX);
gamepadP2LAxisY = SDL_GameControllerGetAxis(gamepadP2, SDL_CONTROLLER_AXIS_LEFTY);
gamepadP2APressed = SDL_GameControllerGetButton(gamepadP2, SDL_CONTROLLER_BUTTON_A);
gamepadP2XPressed = SDL_GameControllerGetButton(gamepadP2, SDL_CONTROLLER_BUTTON_X);
gamepadP2StartPressed = SDL_GameControllerGetButton(gamepadP2, SDL_CONTROLLER_BUTTON_START);
gamepadP2con = true;
break;
}
else
{
SDL_GameControllerClose(gamepadP2);
gamepadP2 = nullptr;
gamepadP2con = false;
}
}
}
}
}
Expand Down Expand Up @@ -140,6 +178,52 @@ update_status ModuleInput::PreUpdate()
{
keyboard[SDL_SCANCODE_O] = KEY_STATE::KEY_REPEAT;
}*/

//CHECK P2 Left Axis X & Y
if (gamepadP2LAxisX > 3200)
{
keyboard[SDL_SCANCODE_D] = KEY_STATE::KEY_REPEAT;
}
else if (gamepadP2LAxisX < -3200)
{
keyboard[SDL_SCANCODE_A] = KEY_STATE::KEY_REPEAT;
}

if (gamepadP2LAxisY < -6400)
{
keyboard[SDL_SCANCODE_W] = KEY_STATE::KEY_REPEAT;
}
else if (gamepadP2LAxisY > 6400)
{
keyboard[SDL_SCANCODE_S] = KEY_STATE::KEY_REPEAT;
}

if (gamepadP1StartPressed == true && keyboard[SDL_SCANCODE_SPACE] == KEY_STATE::KEY_IDLE)
{
keyboard[SDL_SCANCODE_SPACE] = KEY_STATE::KEY_DOWN;
}

//CHECK P2 Buttons

if (gamepadP2APressed == true && keyboard[SDL_SCANCODE_V] == KEY_STATE::KEY_IDLE)
{
keyboard[SDL_SCANCODE_V] = KEY_STATE::KEY_DOWN;
}

if (gamepadP2XPressed == true && keyboard[SDL_SCANCODE_B] == KEY_STATE::KEY_IDLE)
{
keyboard[SDL_SCANCODE_B] = KEY_STATE::KEY_DOWN;
}

if (gamepadP2StartPressed == true && keyboard[SDL_SCANCODE_SPACE] == KEY_STATE::KEY_IDLE)
{
keyboard[SDL_SCANCODE_SPACE] = KEY_STATE::KEY_DOWN;
}
/*else
{
keyboard[SDL_SCANCODE_O] = KEY_STATE::KEY_REPEAT;
}*/

return update_status::UPDATE_CONTINUE;
}

Expand Down
11 changes: 11 additions & 0 deletions Andro_Dunos/ModuleInput.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ class ModuleInput : public Module
int gamepadP1LAxisY = 0;
bool gamepadP1APressed = false;
bool gamepadP1XPressed = false;
bool gamepadP1StartPressed = false;

//GAme Controller for Player 2
SDL_GameController* gamepadP2 = nullptr;
bool gamepadP2con = false;
int gamepadP2LAxisX = 0;
int gamepadP2LAxisY = 0;
bool gamepadP2APressed = false;
bool gamepadP2XPressed = false;
bool gamepadP2StartPressed = false;

//debug mode function
bool debugMode = false;
bool coliderView = false;
Expand Down
4 changes: 2 additions & 2 deletions Andro_Dunos/ModuleMainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@ update_status ModuleMainMenu::Update()
App->fade->FadeToBlack(this, App->stage1, 0.5);
}

if (App->input->keyboard[SDL_SCANCODE_1] == 1) //press for 1 player mode @AndresSala
if (App->input->keyboard[SDL_SCANCODE_1] == 1 && App->input->debugMode==true) //press for 1 player mode @AndresSala
{
App->input->secondPlayerState = false;
}


if (App->input->keyboard[SDL_SCANCODE_2] == 1) // press for 2 players mode @AndresSala
if (App->input->keyboard[SDL_SCANCODE_2] == 1 && App->input->debugMode == true) // press for 2 players mode @AndresSala
{
App->input->secondPlayerState = true;
}
Expand Down
90 changes: 50 additions & 40 deletions Andro_Dunos/ModuleParticles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,56 @@ ModuleParticles::ModuleParticles() // @Andres @CarlesHoms
ModuleParticles::~ModuleParticles()
{}

// Called before render is available
bool ModuleParticles::Init()
{
LOG("Init Module Particles");
bool ret = true;
// Explosion particle // @Andres
explosion.anim.PushBack({ 505, 34, 4, 4 });
explosion.anim.PushBack({ 512, 26, 12, 12 });
explosion.anim.PushBack({ 528, 6, 32, 32 });
explosion.anim.PushBack({ 563, 7, 30, 30 });
explosion.anim.PushBack({ 597, 8, 30, 30 });
explosion.anim.PushBack({ 518, 46, 30, 30 });
explosion.anim.PushBack({ 552, 47, 30, 30 });
explosion.anim.PushBack({ 587, 45, 32, 32 });
explosion.anim.PushBack({ 524, 82, 32, 32 });
explosion.anim.PushBack({ 571, 82, 32, 32 });
explosion.anim.loop = false;
explosion.anim.speed = 1.5f;
explosion.anim.Finished();

explosion1.anim.PushBack({ 632, 24, 8, 8 });
explosion1.anim.PushBack({ 642, 18, 13, 14 });
explosion1.anim.PushBack({ 658, 7, 25, 25 });
explosion1.anim.PushBack({ 688, 6, 27, 26 });
explosion1.anim.PushBack({ 718, 3, 30, 29 });
explosion1.anim.PushBack({ 632, 39, 29, 28 });
explosion1.anim.PushBack({ 665, 39, 29, 28 });
explosion1.anim.PushBack({ 698, 40, 28, 27 });
explosion1.anim.PushBack({ 728, 42, 29, 27 });
explosion1.anim.PushBack({ 632, 74, 29, 27 });
explosion1.anim.PushBack({ 665, 76, 28, 26 });
explosion1.anim.PushBack({ 698, 77, 26, 24 });
explosion1.anim.PushBack({ 727, 79, 21, 21 });
explosion1.anim.PushBack({ 638, 107, 17, 17 });
explosion1.anim.PushBack({ 665, 115, 6, 6 });
explosion1.anim.loop = false;
explosion1.anim.speed = 1.5f;
explosion1.anim.Finished();

explosion2.anim.PushBack({ 509, 137, 6, 6 });
explosion2.anim.PushBack({ 521, 135, 10, 8 });
explosion2.anim.PushBack({ 535, 127, 16, 16 });
explosion2.anim.PushBack({ 557, 129, 14, 14 });
explosion2.anim.loop = false;
explosion2.anim.speed = 1.5f;
explosion2.anim.Finished();

return ret;
}

// Load assets
bool ModuleParticles::Start()
{
Expand Down Expand Up @@ -609,47 +659,7 @@ bool ModuleParticles::Start()
enemyBlueShot.life = longLife;


// Explosion particle // @Andres
explosion.anim.PushBack({ 505, 34, 4, 4 });
explosion.anim.PushBack({ 512, 26, 12, 12 });
explosion.anim.PushBack({ 528, 6, 32, 32 });
explosion.anim.PushBack({ 563, 7, 30, 30 });
explosion.anim.PushBack({ 597, 8, 30, 30 });
explosion.anim.PushBack({ 518, 46, 30, 30 });
explosion.anim.PushBack({ 552, 47, 30, 30 });
explosion.anim.PushBack({ 587, 45, 32, 32 });
explosion.anim.PushBack({ 524, 82, 32, 32 });
explosion.anim.PushBack({ 571, 82, 32, 32 });
explosion.anim.loop = false;
explosion.anim.speed = 1.5f;
explosion.anim.Finished();

explosion1.anim.PushBack({ 632, 24, 8, 8 });
explosion1.anim.PushBack({ 642, 18, 13, 14 });
explosion1.anim.PushBack({ 658, 7, 25, 25 });
explosion1.anim.PushBack({ 688, 6, 27, 26 });
explosion1.anim.PushBack({ 718, 3, 30, 29 });
explosion1.anim.PushBack({ 632, 39, 29, 28 });
explosion1.anim.PushBack({ 665, 39, 29, 28 });
explosion1.anim.PushBack({ 698, 40, 28, 27 });
explosion1.anim.PushBack({ 728, 42, 29, 27 });
explosion1.anim.PushBack({ 632, 74, 29, 27 });
explosion1.anim.PushBack({ 665, 76, 28, 26 });
explosion1.anim.PushBack({ 698, 77, 26, 24 });
explosion1.anim.PushBack({ 727, 79, 21, 21 });
explosion1.anim.PushBack({ 638, 107, 17, 17 });
explosion1.anim.PushBack({ 665, 115, 6, 6 });
explosion1.anim.loop = false;
explosion1.anim.speed = 1.5f;
explosion1.anim.Finished();

explosion2.anim.PushBack({ 509, 137, 6, 6 });
explosion2.anim.PushBack({ 521, 135, 10, 8 });
explosion2.anim.PushBack({ 535, 127, 16, 16 });
explosion2.anim.PushBack({ 557, 129, 14, 14 });
explosion2.anim.loop = false;
explosion2.anim.speed = 1.5f;
explosion2.anim.Finished();



Expand Down
1 change: 1 addition & 0 deletions Andro_Dunos/ModuleParticles.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class ModuleParticles : public Module
~ModuleParticles();

bool Start();
bool Init();
update_status Update();
bool CleanUp();

Expand Down
7 changes: 6 additions & 1 deletion Andro_Dunos/ModuleStage1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ bool ModuleStage1::Start()
// Enemies
App->enemies->Enable();

//Score
App->UI->teamScore = 0;
App->UI->player1Score = 0;
App->UI->player2Score = 0;

// First Enemy: GreyBall (4 waves, with 1wave&3wave same position.y and 2wave&4wave same position.y)
//wave 1 ------------------------------------------------------
App->enemies->AddEnemy(ENEMY_TYPES::GREYBALL_UP_DOWN, 480, 50);
Expand Down Expand Up @@ -801,7 +806,7 @@ update_status ModuleStage1::Update()
}

//make so pressing SPACE the other stage is loaded
if (App->input->keyboard[SDL_SCANCODE_SPACE] == 1)
if (App->input->keyboard[SDL_SCANCODE_SPACE] == 1 && App->input->debugMode == true)
{
App->fade->FadeToBlack(App->stage1, App->scene_HiScore, 1);
}
Expand Down
53 changes: 46 additions & 7 deletions Andro_Dunos/ModuleUserInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ update_status ModuleUserInterface::Update()
{
App->fonts->BlitText(10, 50, debug_font, "super speed");
}
//Controller Debug
//Controller Debug P1
if (App->input->debugMode == true && App->input->gamepadP1con == true)
{
App->fonts->BlitText(100, 20, debug_font, "p1 controller on");
Expand All @@ -135,20 +135,49 @@ update_status ModuleUserInterface::Update()
{
App->fonts->BlitText(100, 20, debug_font, "p1 controller off");
}
//Controller Debug P2
if (App->input->debugMode == true && App->input->gamepadP2con == true)
{
App->fonts->BlitText(160, 50, debug_font, "p2 controller on");
if (App->input->gamepadP2APressed == true)
{
App->fonts->BlitText(170, 60, debug_font, "a");
}
if (App->input->gamepadP2XPressed == true)
{
App->fonts->BlitText(180, 60, debug_font, "x");
}
//Check BUTTONS & AXIS Currently PC CRASH DO NOT UNCOMMENT
/*sprintf_s(gamepad_P1_LAxis_X, 4, "%7d", App->input->gamepadP1LAxisX);
App->fonts->BlitText(100, 30, 0, gamepad_P1_LAxis_X);*/
}
if (App->input->debugMode == true && App->input->gamepadP2con == false)
{
App->fonts->BlitText(160, 50, debug_font, "p2 controller off");
}
}break;

case StageClear:
{ //Print the scores, but as we are not playing we don't need to update if the score increases, print teamScore
App->fonts->BlitText(10, 10, font_score, "1P");
App->fonts->BlitText(50, 10, 0, player1Score_text);
App->fonts->BlitText(210, 10, font_score, "2P");
App->fonts->BlitText(250, 10, 0, player2Score_text);
if (App->input->secondPlayerState == true)
{
App->fonts->BlitText(210, 10, font_score, "2P");
App->fonts->BlitText(250, 10, 0, player2Score_text);
}
//Print replay
App->fonts->BlitText(35, 175, font_yellowtxt, "press enter to play again");
App->fonts->BlitText(10, 190, font_yellowtxt, "press space to go to main menu");
//Add the 2 scores to have the Team Score and blit them
App->fonts->BlitText(115, 20, font_yellowtxt, "teamscore");
teamScore = player1Score + player2Score;
if (App->input->secondPlayerState == true)
{
teamScore = player1Score + player2Score;
}
else {
teamScore = player1Score;
}
sprintf_s(teamScore_text, 10, "%7d", teamScore);
App->fonts->BlitText(110, 30, font_yellowtxt, teamScore_text);
}break;
Expand All @@ -157,14 +186,24 @@ update_status ModuleUserInterface::Update()
{ //Print the scores, but as we are not playing we don't need to update if the score increases, print teamScore
App->fonts->BlitText(10, 10, font_score, "1P");
App->fonts->BlitText(50, 10, 0, player1Score_text);
App->fonts->BlitText(210, 10, font_score, "2P");
App->fonts->BlitText(250, 10, 0, player2Score_text);
if (App->input->secondPlayerState == true)
{
App->fonts->BlitText(210, 10, font_score, "2P");
App->fonts->BlitText(250, 10, 0, player2Score_text);
}
//Print replay
App->fonts->BlitText(35,85, font_yellowtxt, "press enter to play again");
App->fonts->BlitText(10, 100, font_yellowtxt, "press space to go to main menu");

//Add the 2 scores to have the Team Score and blit them
App->fonts->BlitText(115, 20, font_yellowtxt, "teamscore");
teamScore = player1Score + player2Score;
if (App->input->secondPlayerState == true)
{
teamScore = player1Score + player2Score;
}
else {
teamScore = player1Score;
}
sprintf_s(teamScore_text, 10, "%7d", teamScore);
App->fonts->BlitText(110, 30, font_yellowtxt, teamScore_text);
}break;
Expand Down

0 comments on commit 2b8f392

Please sign in to comment.