/* key 값에 따라 노래가 흘러나온다. 노래 재생은 sndPlaySound 함수로 흘러나오게 설정하였다. 각 key 값의 뜻은 각 장면을 뜻한다. 별도의 음악파일이 필요하며 경로설정은 sndPlaySound(TEXT("음악파일경로") 를 입력하면 된다. */ void MyDisplay(){ if (key == RUN){//로봇이 달릴때 Run(); glPopMatrix(); } else if (key == JAP){//로봇이 잽을 날릴 때 Jap(); glPopMatrix(); } else if (key == ROCKET){//로봇이 로켓을 발사할때 Rocket(); glPopMatrix(); } else if (key == YUNA){//로봇이 김연아 선수의 모션을 취할 때 Show(); glPopMatrix(); } else if (key == 5){//중지가 선택됐을 때 sndPlaySound(NULL, SND_ASYNC); } else if (key == EXIT){//종료가 선택됐을 때 ex(); glPopMatrix(); } }
Rocket Rocket::mate(Rocket partner) { Rocket child = Rocket(); child.setDNA(dna.crossover(partner.getDNA())); child.setTarget(target); child.setObstacles(obstacles); return child; }
void play(int i, Window& win) { nodelay(stdscr, TRUE); i = get_difficult(i); Player p(win); EnnemyHorde n = EnnemyHorde(i, "^v^"); Missile miss = Missile(10, "|"); Rocket rock = Rocket(2, "[]"); n.randomPOP(win); int input = 0; p.setScoreZero(); while (input != KEY_ECHAP && p.getHP() > 0) { clear(); miss.print_score(win); win.takeSize(); win.printBorder(); input = getch(); miss.activate(p.getX(), p.getY(), input); rock.activate(p.getX(), p.getY(), input); miss.checkDamages(n.getHorde(), n.getNumber(), win); rock.checkDamages(n.getHorde(), n.getNumber(), win); p.checkEnemies(n.getHorde(), n.getNumber(), win); p.print_life(win); miss.print_chargeur(win); rock.print_chargeur(win); if (p.getHP() > 0) { n.printit(win); miss.move(win); rock.move(win); miss.printit(win); rock.printit(win); p.printit(win); p.inputDirection(input); wrefresh(win.getWin()); p.move(win); p.printit(win); n.move(win); } while(getch() != ERR); usleep(60000); } if (p.getHP() <= 0) { clear(); print_die(win, p); } if (p.getScore() > hight_score) hight_score = p.getScore(); }
// // this is the smarts for the rocket launcher in coop // // if there is a player behind/below the carrier, and we can shoot, and we can trace a LOS to them .. // pick one of the group, and let it rip void CCarrier::CoopCheck () { // no more than 4 players in coop, so.. static std::vector<CPlayerEntity*> targets; targets.clear(); // if we're not in coop, this is a noop if (!(Game.GameMode & GAME_COOPERATIVE)) return; // if we are, and we have recently fired, bail if (RefireWait > Level.Frame) return; // cycle through players for (int player = 1; player <= Game.MaxClients; player++) { CPlayerEntity *ent = entity_cast<CPlayerEntity>(Game.Entities[player].Entity); if (!ent->GetInUse()) continue; if (IsInBack(Entity, ent) || IsBelow(Entity, ent)) { CTrace tr (Entity->State.GetOrigin(), ent->State.GetOrigin(), Entity, CONTENTS_MASK_SOLID); if (tr.Fraction == 1.0) targets.push_back (ent); } } if (targets.empty()) return; int target = irandom(targets.size()); // make sure to prevent rapid fire rockets RefireWait = Level.Frame + CARRIER_ROCKET_TIME; // save off the real enemy IBaseEntity *OldEnemy = *Entity->Enemy; // set the new guy as temporary enemy Entity->Enemy = targets[target]; Rocket (); // put the real enemy back Entity->Enemy = OldEnemy; // we're done return; }
GameState::GameState(int x, int y) { // Initial game state m_game_state = STATE_MENU; // Size of the game area m_size_x = x; m_size_y = y; //schwerkraft gravity = 0.01; total_dodgecoins = 0; m_dodgecoins_collected = 0; //hole Soundhandler s = SoundHandler::getSoundHandler(); // Set initial player movement and location setPlayerMovementDirection(DIRECTION_NONE); setPlayerLocation(sf::Vector2f(x/2-ROBOT_WIDTH/2,y/2-ROBOT_HEIGHT/2)); // ORIGINAL //setPlayerLocation(sf::Vector2f(x/2-ROBOT_WIDTH/2,700)); // BROKEN EXPERIMENTAL // Initialize random seed srand (static_cast <unsigned> (time(0))); loadUpgrades(); rocket = Rocket(upgradeList); m_dodgecoin_locations.clear(); rocket.updateStats(); //load buttons button_back = Button(sf::Vector2f(100,700),sf::Vector2f(130,47),"Back","assets/menu_button.png"); button_play = Button(sf::Vector2f(100,200),sf::Vector2f(130,47),"Play","assets/menu_button.png"); button_credits = Button(sf::Vector2f(100,350),sf::Vector2f(130,47),"Credits","assets/menu_button.png"); button_help = Button(sf::Vector2f(100,500),sf::Vector2f(130,47),"Help","assets/menu_button.png"); button_quit = Button(sf::Vector2f(100,650),sf::Vector2f(130,47),"Quit","assets/menu_button.png"); button_takeOff = Button(sf::Vector2f(1000,700),sf::Vector2f(130,47),"Launch","assets/menu_button.png"); }
void GameState::startPlaying() { m_game_state = STATE_PLAYING; // Reset all values m_dodgecoins_collected = 0; m_dodgecoin_locations.clear(); setPlayerMovementDirection(DIRECTION_NONE); rocket = Rocket(upgradeList); rocket.updateStats(); //setPlayerLocation(sf::Vector2f(640, 700)); // Start zentriert auf Bodenhöhe m_velocity = rocket.boost; //std::cout << rocket.boost << "\n"; // Initialize random seed srand (static_cast <unsigned> (time(0))); s->playBg(); }
void GameState::shopMouseHandling(sf::Vector2i location) { int x = (location.x -200) /150; int y = (location.y -100)/ 200; if(x<=4 && y<=3) { int index = 4*y + x; if (total_dodgecoins >= upgradeList.at(index)->price && upgradeList.at(index)->price != 0) { total_dodgecoins -= upgradeList.at(index)->price; upgradeList.at(index)->price = 0; rocket = Rocket(upgradeList); rocket.updateStats(); std::cout << "gekauft\n"; } } std::cout<< "mouse: "<< location.x << " " << location.y << "\n x:" << x << " y: " << y << "\n"; //STARTBUTTON if(button_takeOff.checkClick(location)) { readyToLaunch(); //startPlaying(); } //MenueBUTTON if(button_back.checkClick(location)) { m_game_state = STATE_MENU; } //Stats Updaten rocket.updateStats(); }
int main(int argc, char** argv) { // Starting game window size. height = 960; width = 1000; //Initialize Object Data srand(time(NULL)); // Initialize Tank float randomAngle = (float)random(0, 200) / 10; artillery = tank(random(-width * 24, width * 24), random(-height * 24, height * 24), 1500, 15, randomAngle); player = Rocket(0,0, 100, 0.8f, 10); player.follow(artillery); //Sets initial Position to tank UI = new UIManager(); moonLand = random(0, numMoons-1); seed = random(-123456, 123456); // Level seed to randomize each level creation between min and max value. int sizeOfMoonLoc = -1; artillery.colRadius = artillery.radius * distanceFromStartMult; for (int i = 0; i < numMoons; i++) { sizeOfMoonLoc++; moonLocation[i] = vector(random(-width * 24, width * 24), random(-height * 24, height * 24)); float moonRadius = random(300, 500); moons[i] = Moon(moonLocation[i], moonRadius, 0, 0, 0, 60); for (int z = 0; z < sizeOfMoonLoc; z++) { if (z != i) { while (moons[i].checkCollision(moons[z]) || moons[i].checkCollision(artillery)) { moonLocation[i] = vector(random(-width * 24, width * 24), random(-height * 24, height * 24)); moons[i] = Moon(moonLocation[i], moonRadius, 0, 0, 0, round(moonRadius / 10)); } } } } artillery.colRadius = artillery.radius; for (int i = 0; i < numStars; i++) { star[i] = new Star(vector(random(-width*24,width*24), random(-height*24,height*24)), vector(0.8f, 0.8f, 0.0f), random(3, 15), random(0,100)); } //End of Initialization glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(0,0); glutInitWindowSize(width, height); glutCreateWindow("IchyMoo the LunarLunar"); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(0.05, 0.05, 0.05, 0.0); glutReshapeFunc(reshape); glutDisplayFunc(renderScene); glutKeyboardFunc(keyDown); glutKeyboardUpFunc(keyUp); glutTimerFunc(41,idle,0); glutMainLoop(); }