update_status ModuleGameplay::Update() { if (App->player->IsEnabled()) { if (App->player->pause == true) { Mix_PauseMusic(); App->render->Blit(pause, 0, 0, &pausing); } else { Mix_ResumeMusic(); //App->textures->Unload(pause); } if (App->player->godmode == true) { App->render->Blit(godm, 500, 1, &gmode); } /*else App->textures->Unload(godm);*/ if (App->board->CheckWin()/*|| App->input->keyboard[SDL_SCANCODE_W] == KEY_STATE::KEY_DOWN*/) { if (App->level_3->IsEnabled()) { Congratulations(); } else Win(); if (check_time == 0)check_time = SDL_GetTicks(); } else if (App->player->LoseCondition == true) { Lose(); if (check_time == 0)check_time = SDL_GetTicks(); } if (check_time != 0) { if (SDL_GetTicks() - check_time >= 2000) { check_time = 0; } } } return UPDATE_CONTINUE; }
void Snake::Cut(int segments) { for (int i = 0; i < segments; ++i) { _body.pop_back(); } _lives -= 1; if (!_lives) { Lose(); } }
bool CBettingGuy::EndBetAttempt( uint32 goalId ) { // this acts like a secondary deactivate if ( IsActive() && m_currentMinigame == goalId && m_inAttempt && !m_shouldMove ) { //printf("CBettingGuy::EndBetAttempt\n"); // printf("step 2\n"); m_inAttempt = false; Script::CStruct* pBetParams = GetBetParams(); // check that they haven't exceeded the number of tries int max_attempts; pBetParams->GetInteger( "tries", &max_attempts, Script::ASSERT ); // we're challenging them to break a record CGoalManager* pGoalManager = GetGoalManager(); Dbg_Assert( pGoalManager ); Script::CStruct* pMinigameParams = pGoalManager->GetGoal( m_currentMinigame )->GetParams(); Dbg_Assert( pMinigameParams ); if ( m_currentChallenge ) { // printf("step 3\n"); int last_attempt; if ( pMinigameParams->GetInteger( "last_attempt", &last_attempt, Script::NO_ASSERT ) ) { printf("got a last attempt of %i\n", last_attempt); printf("m_currentChallenge is %i\n", m_currentChallenge); if ( last_attempt >= m_currentChallenge ) { // printf("you won the bet!\n"); // beat the bet and call the minigame's bet_success script this->Win(); return true; } } } // check that this isn't their last try m_numTries++; if ( m_numTries >= max_attempts ) { Lose(); return true; } // if it's not a challenge minigame, it's probably a trickspot // minigame. In that case, we'll be told when the game is won // the the gap script. } return false; }
void RPS() { enum Hands{ /*Rock = 0, Paper = 1, Scissors = 2, EXIT = 3*/ Rock, Paper, Scissor, Exit }; printf("\n You are playing ROCK/PAPER/SCISSORS \n"); /*input and check rounds from the user */ printf("\nEnter how many rounds you want to play: "); scanf("%i", &rounds); if(rounds <= 0){ do{ printf("\nEnter how many rounds you want to play: "); scanf("%i", &rounds); if(rounds > 0) break; }while(rounds <= 0); } /*Loop the number of rounds */ for(int x = 0; x < rounds; x++){ Computer = rand() % 2; /*random number between 0 and 2*/ printf("\nSelect a value... \n 0: Rock \n 1: Paper \n 2: Scissors \n 3: Exit \n Enter Value: "); scanf("%i", &User); if(User == Exit) /*if user wants to exit, go back to main*/ break; if(User == Computer) printf("\nDraw! Total Score: %i\n", TotalScore); /*Check who wins and adjust score*/ if(User == Rock && Computer == Paper) { Lose(); printf("\nYou Lose! You chose Rock, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Rock && Computer == Scissor) { Win(); printf("\nYou Win! You chose Rock, Computer chose Scissors. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Rock) { Win(); printf("\nYou win! You chose Paper, Computer chose Rock. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Scissor) { Lose(); printf("\nYou Lose! You chose Paper, Computer chose Scissor. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Paper) { Win(); printf("\nYou win! You chose Scissor, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Rock) { Lose(); printf("\nYou Lose! You chose Scissor, Computer chose Rock. Total Score: %i\n", TotalScore); } /*if user inputs invalid values*/ if(User > Exit || User < Rock) printf("\nError: Enter an acceptable value\n"); } }
void RPSLS(){ enum Hand{ /*Rock = 0, Paper = 1, Scissors = 2, Lizard = 3, Spock = 4, EXIT = 5*/ Rock, Paper, Scissor, Lizard, Spock, Exit }; printf("\n You are playing ROCK/PAPER/SCISSORS/LIZARD/SPOCK \n"); /*input rounds from the user */ printf("\nEnter how many rounds you want to play: "); scanf("%i", &rounds); if(rounds <= 0){ do{ printf("\nEnter how many rounds you want to play: "); scanf("%i", &rounds); if(rounds > 0) break; }while(rounds <= 0); } /*loop number of rounds*/ for(int x = 0; x < rounds; x++){ Computer = rand() % 4; printf("\nSelect a value... \n 0: Rock \n 1: Paper \n 2: Scissors \n 3: Lizard \n 4. Spock \n 5. Exit \n Enter Value: "); scanf("%i", &User); if(User == Exit) break; if(User == Computer) printf("\nDraw! Total Score: %i\n", TotalScore); /*check who wins and adjust score */ if(User == Rock && Computer == Paper) { Lose(); printf("\nYou Lose! You chose Rock, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Rock && Computer == Scissor) { Win(); printf("\nYou Win! You chose Rock, Computer chose Scissors. Total Score: %i\n", TotalScore); } if(User == Rock && Computer == Lizard) { Win(); printf("\nYou win! You chose Rock, Computer chose lizard. Total Score: %i\n", TotalScore); } if(User == Rock && Computer == Spock) { Lose(); printf("\nYou Lose! You chose Rock, Computer chose Spock. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Rock) { Win(); printf("\nYou win! You chose Paper, Computer chose Rock. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Scissor) { Lose(); printf("\nYou Lose! You chose Paper, Computer chose Scissor. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Lizard) { Lose(); printf("\nYou Lose! You chose Paper, Computer chose Lizard. Total Score: %i\n", TotalScore); } if(User == Paper && Computer == Spock) { Win(); printf("\nYou win! You chose Paper, Computer chose Spock. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Paper) { Win(); printf("\nYou win! You chose Scissor, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Rock) { Lose(); printf("\nYou Lose! You chose Scissor, Computer chose Rock. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Lizard) { Win(); printf("\nYou win! You chose Scissor, Computer chose Lizard. Total Score: %i\n", TotalScore); } if(User == Scissor && Computer == Spock) { Lose(); printf("\nYou Lose! You chose Scissor, Computer chose Spock. Total Score: %i\n", TotalScore); } if(User == Lizard && Computer == Paper) { Win(); printf("\nYou Win! You chose Lizard, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Lizard && Computer == Rock) { Lose(); printf("\nYou Lose! You chose Lizard, Computer chose Rock. Total Score: %i\n", TotalScore); } if(User == Lizard && Computer == Scissor) { Lose(); printf("\nYou Lose! You chose Lizard, Computer chose Scissor. Total Score: %i\n", TotalScore); } if(User == Lizard && Computer == Spock) { Win(); printf("\nYou Win! You chose Lizard, Computer chose Spock. Total Score: %i\n", TotalScore); } if(User == Spock && Computer == Lizard) { Lose(); printf("\nYou Lose! You chose Spock, Computer chose Lizard. Total Score: %i\n", TotalScore); } if(User == Spock && Computer == Paper) { Lose(); printf("\nYou Lose! You chose Spock, Computer chose Paper. Total Score: %i\n", TotalScore); } if(User == Spock && Computer == Scissor) { Win(); printf("\nYou Win! You chose Spock, Computer chose Scissor. Total Score: %i\n", TotalScore); } if(User == Spock && Computer == Rock) { Win(); printf("\nYou Win! You chose Spock, Computer chose Rock. Total Score: %i\n", TotalScore); } /*if user enters invalid value*/ if(User > Exit || User < Rock) printf("\nError: Enter an acceptable value\n"); } }
/*======================================================================* Start *======================================================================*/ void Start() { /*int ai; disp_pos = 0; for (ai = 0; ai < 80 * 25; ai++) { disp_str(" "); } disp_pos = 0;*/ //memset(snake_map, 0, sizeof(char)*MAP_SIZE); /*int ai; for (ai = 0; ai < 80 * 25; ai++) { snake_map[ai] = ' '; }*/ Reset(); while (1){ //proc_table[0].ticks = proc_table[0].priority = 150; milli_delay(3333); int hX, hY; int newHead; if (snake_direct == DIRECT_NULL) continue; hX = snake_path[snake_head] % MAP_LENGTH; hY = snake_path[snake_head] / MAP_LENGTH; switch (snake_direct) { case DIRECT_UP: { hY--; break; } case DIRECT_DOWN:{ hY++; break; } case DIRECT_LEFT:{ hX--; break; } case DIRECT_RIGHT:{ hX++; break; } default: break; } newHead = hY*MAP_LENGTH + hX; if (newHead < 0 || newHead >= MAP_SIZE || hY >= MAP_HEIGHT || hY < 0 || hX < 0 || hX >= MAP_LENGTH){ Lose(); continue; } if (snake_map[newHead] == 'O' && newHead != snake_path[snake_tail]){ Lose(); continue; } if (snake_map[newHead] != '*'){ disp_pos = snake_path[snake_tail] * 2; disp_str(" "); snake_map[snake_path[snake_tail]] = ' '; snake_tail++; if (snake_tail == MAP_SIZE) snake_tail = 0; } else{ snake_length++; } disp_pos = snake_path[snake_head] * 2; disp_str("0"); snake_map[snake_path[snake_head]] = 'O'; snake_head++; if (snake_head == MAP_SIZE) snake_head = 0; snake_path[snake_head] = newHead; disp_pos = snake_path[snake_head] * 2; disp_str("@"); snake_map[snake_path[snake_head]] = '@'; if (snake_length == 6) { Win(); continue; } } }