//---------------------------- SCREEN/HUD CONTROLS void KeyButtons(unsigned char key, int y, int z) { //--------------------------CHANGE ENEMY' SPEED switch (key) { case '1': lvl.SetEnemiesSpeed(15); break; case '2': lvl.SetEnemiesSpeed(20); break; case '3': lvl.SetEnemiesSpeed(30); break; } // -------------------------------- PLAYER FIRE if (inGame) { if (key == ' ' && (player.IsFiring() == false)) { if (!(player.HasPowderBag())) { // As long has player has no powder bag player.Attack(); lvl.NewFire(player.GetWeapon(), player.GetDir(), player.GetPos()); } else { // consume powder bag and convert cases int X = round(player.GetPos().x / TextWidth + 0.4); int Y = round(player.GetPos().y / TextWidth + 0.4); switch (player.GetDir()) { case 'u': for (int i = player.GetPos().y/TextWidth; i > player.GetPos().y/ TextWidth - 5; i--) { lvl.SetMap(X, i, 4); } break; case 'd': for (int i = player.GetPos().y / TextWidth; i < player.GetPos().y / TextWidth + 5; i++) { lvl.SetMap(X, i, 4); } break; case 'r': for (int i = player.GetPos().x / TextWidth; i < player.GetPos().x / TextWidth + 5; i++) { lvl.SetMap(i, Y, 4); } break; case 'l': for (int i = player.GetPos().x / TextWidth; i > player.GetPos().x / TextWidth - 5; i--) { lvl.SetMap(i, Y, 4); } break; } player.SetPowderBag(false); } } if (key == 'p') { cout << key << endl; menu.Pause(); } } else { if (key == ' ') { menu.Clicking(); } if (key == 'p') { cout << key << endl; menu.Pause(); } } }
void InterfaceArduino() { readResult = SP->ReadData(incomingData, dataLength); if (readResult != -1) { /* if (incomingData[0] == 'B') { cout << "bouclier" << endl; //SP->WriteData("b", 1); //Sleep(150); ------ si on envoie des données } else */ int L = player.GetLife(); if (inGame) { if (L <= 150 && L > 125) SP->WriteData("7", 1); else if (L <= 125 && L > 100) SP->WriteData("6", 1); else if (L <= 100 && L > 75) SP->WriteData("5", 1); else if (L <= 75 && L > 50) SP->WriteData("4", 1); else if (L <= 50 && L > 25) SP->WriteData("3", 1); else if (L <= 25 && L > 0) SP->WriteData("2", 1); else if (L <= 0) SP->WriteData("1", 1); if (incomingData[0] == 'P') { // Game is Paused menu.Pause(); } } else SP->WriteData("0", 1); if (incomingData[0] == 'I') { // Player is invisible player.setOpacity(0.1); light = 0.1; } else if (incomingData[0] == 'J') { // Player is visible player.setOpacity(0.4); light = 0.4; } else if (incomingData[0] == 'W') { // Player is visible player.setOpacity(0.70); light = 0.70; } else if (incomingData[0] == 'V') { // Player is visible player.setOpacity(1.0); light = 1.0; } else if (incomingData[0] == 'F') { // Player is firing if (inGame) { if (player.IsFiring() == false) { if (!(player.HasPowderBag())) { // As long has player has no powder bag player.Attack(); lvl.NewFire(player.GetWeapon(), player.GetDir(), player.GetPos()); } else { // consume powder bag and convert cases int X = round(player.GetPos().x / TextWidth + 0.4); int Y = round(player.GetPos().y / TextWidth + 0.4); switch (player.GetDir()) { case 'u': for (int i = player.GetPos().y / TextWidth; i > player.GetPos().y / TextWidth - 5; i--) { if (lvl.Map(X, i) == 0) lvl.SetMap(X, i, 4); } break; case 'd': for (int i = player.GetPos().y / TextWidth; i < player.GetPos().y / TextWidth + 5; i++) { if (lvl.Map(X, i) == 0) lvl.SetMap(X, i, 4); } break; case 'r': for (int i = player.GetPos().x / TextWidth; i < player.GetPos().x / TextWidth + 5; i++) { if (lvl.Map(X, i) == 0) lvl.SetMap(X, i, 4); } break; case 'l': for (int i = player.GetPos().x / TextWidth; i > player.GetPos().x / TextWidth - 5; i--) { if (lvl.Map(X, i) == 0) lvl.SetMap(X, i, 4); } break; } player.SetPowderBag(false); } } } else { menu.Clicking(); } } else if (incomingData[0] == 'u') { // Player's Direction player.SwitchDir('u'); player.SetMoving(true); player.SetStillMoving(true); } else if (incomingData[0] == 'd') { // Player's Direction player.SwitchDir('d'); player.SetMoving(true); player.SetStillMoving(true); } else if (incomingData[0] == 'r') { // Player's Direction player.SwitchDir('r'); player.SetMoving(true); player.SetStillMoving(true); } else if (incomingData[0] == 'l') { // Player's Direction player.SwitchDir('l'); player.SetMoving(true); player.SetStillMoving(true); } else if (incomingData[0] == 'A') { // Enemies' speed lvl.SetEnemiesSpeed(18); cout << "A" << endl; } else if (incomingData[0] == 'B') { // Enemies' speed lvl.SetEnemiesSpeed(12); cout << "B" << endl; } else if (incomingData[0] == 'C') { // Enemies' speed lvl.SetEnemiesSpeed(6); cout << "C" << endl; } } //Serial.read() ---- pour éteindre / allumer les leds }