?? intermission.cpp
字號:
Mix_PauseMusic(); } if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 272, 45, 22)) { if (!currentGame.fullScreen) { #if LINUX SDL_WM_ToggleFullScreen(graphics.screen); #else graphics.screen = SDL_SetVideoMode(800, 600, 16, SDL_HWSURFACE|SDL_HWPALETTE|SDL_FULLSCREEN); graphics.drawBackground(); flushBuffer(); #endif currentGame.fullScreen = 1; } } if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 478, 272, 45, 22)) { if (currentGame.fullScreen) { #if LINUX SDL_WM_ToggleFullScreen(graphics.screen); #else graphics.screen = SDL_SetVideoMode(800, 600, 0, SDL_HWSURFACE|SDL_HWPALETTE); graphics.drawBackground(); flushBuffer(); #endif currentGame.fullScreen = 0; } } if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 417, 322, 100, 22)) { Math::wrapChar(&(++currentGame.autoSaveSlot), -1, 4); engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; } createOptions(optionsSurface); }}/*Oddly named function that controls the entire intermissionscreen. This simply draws a background, stars, gridlines and the iconsat the bottom of the screen. Will call (and continue to call) the specifiedfunctions when the player has selected an icon.*/int galaxyMap(){ graphics.freeGraphics(); checkForBossMission(); // double check just to make sure! // Tell the game we are not in a mission so // do not perform certain keyboard actions engine.gameSection = SECTION_INTERMISSION; graphics.clearScreen(graphics.black); graphics.updateScreen(); graphics.clearScreen(graphics.black); initSaveSlots(); SDL_Delay(1000); loadMusic("music/3DParadise.mod"); loadBackground((char *)systemBackground[currentGame.system]); char string[25]; engine.cursor_x = engine.cursor_y = 500; graphics.shape[0] = loadImage("gfx/cursor.bmp"); // Icons 1 - 29 for (int i = 0 ; i < 26 ; i++) { sprintf(string, "gfx/icon%d.bmp", (i + 1)); graphics.shape[i + 1] = loadImage(string); } graphics.shape[27] = loadImage("gfx/buyIcon.bmp"); graphics.shape[28] = loadImage("gfx/sellIcon.bmp"); graphics.shape[29] = loadImage("gfx/firefly1.png"); // Planets 30 - 39 graphics.shape[30] = loadImage("gfx/planet_sun.gif"); graphics.shape[31] = loadImage("gfx/planet_green.gif"); graphics.shape[32] = loadImage("gfx/planet_blue.gif"); graphics.shape[33] = loadImage("gfx/planet_red.gif"); graphics.shape[34] = loadImage("gfx/planet_orange.gif"); // Faces (as defines) graphics.shape[FACE_CHRIS] = loadImage("gfx/face_chris.png"); graphics.shape[FACE_SID] = loadImage("gfx/face_sid.png"); graphics.shape[FACE_KRASS] = loadImage("gfx/face_krass.png"); graphics.shape[FACE_PHOEBE] = loadImage("gfx/face_phoebe.png"); graphics.shape[FACE_URSULA] = loadImage("gfx/face_ursula.png"); graphics.shape[FACE_KLINE] = loadImage("gfx/face_kline.png"); engine.done = 0; engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; engine.ssx = engine.ssy = 0; SDL_Rect r; SDL_Rect destRect; int distance = 0; int interceptionChance = 0; setStatusLines(); initShop(); setSystemPlanets(); SDL_Surface *statsSurface = graphics.alphaRect(600, 330, 0x00, 0x00, 0x99); SDL_Surface *savesSurface = graphics.createSurface(350, 300); SDL_Surface *optionsSurface = graphics.createSurface(320, 240); SDL_Surface *commsSurface = graphics.createSurface(450, 400); createSavesSurface(savesSurface, -1); createOptions(optionsSurface); createCommsSurface(commsSurface); signed char section = 1; float sinX = 300; float cosY = 300; signed char movePlanets = 1; signed char saveSlot = -1; if (currentGame.system > 0) interceptionChance = (300 / currentGame.system); // There is no chance of being interceptted after the final attack on Earth if ((currentGame.system == 3) && (systemPlanet[2].missionCompleted)) interceptionChance = 0; int rtn = 0; if ((engine.useAudio) && (currentGame.useMusic)) Mix_PlayMusic(engine.music, -1); textObject iconInfo[12]; iconInfo[0].image = graphics.textSurface("Start Next Mission", FONT_WHITE); iconInfo[1].image = graphics.textSurface("View System Map", FONT_WHITE); iconInfo[2].image = graphics.textSurface("Current Status", FONT_WHITE); iconInfo[3].image = graphics.textSurface("Save Game", FONT_WHITE); iconInfo[4].image = graphics.textSurface("Upgrade FIREFLY", FONT_WHITE); iconInfo[5].image = graphics.textSurface("Comms", FONT_WHITE); iconInfo[6].image = graphics.textSurface("Options", FONT_WHITE); iconInfo[7].image = graphics.textSurface("Exit to Title Screen", FONT_WHITE); sprintf(string, "System : %s", systemNames[currentGame.system]); iconInfo[8].image = graphics.textSurface(string, FONT_WHITE); sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name); iconInfo[9].image = graphics.textSurface(string, FONT_WHITE); strcpy(string, "Destination: None"); if (currentGame.destinationPlanet > -1) sprintf(string, "Destination: %s", systemPlanet[currentGame.destinationPlanet].name); iconInfo[10].image = graphics.textSurface(string, FONT_WHITE); for (int i = 0 ; i < 9 ; i++) iconInfo[i].x = (800 - iconInfo[i].image->w) / 2; iconInfo[11].image = graphics.textSurface("Go to Destination Planet", FONT_WHITE); signed char redrawBackGround = 1; player.maxShield = (25 * currentGame.shieldUnits); if (currentGame.distanceCovered > 0) section = 0; else player.shield = player.maxShield; unsigned long frameLimit = SDL_GetTicks(); flushInput(); engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; engine.done = 0; while (!engine.done) { graphics.updateScreen(); if (redrawBackGround) { graphics.drawBackGround(); redrawBackGround = 0; } else { graphics.unBuffer(); } doStarfield(); r.x = 0; r.y = 0; r.h = 600; r.w = 1; for (int i = 40 ; i < 800 ; i+= 40) { r.x = i; SDL_FillRect(graphics.screen, &r, graphics.darkerBlue); } r.x = 0; r.y = 0; r.h = 1; r.w = 800; for (int i = 40 ; i < 600 ; i+= 40) { r.y = i; SDL_FillRect(graphics.screen, &r, graphics.darkerBlue); } if (rand() % 1000 < 2) { engine.ssx = Math::rrand(100, 100); engine.ssy = Math::rrand(100, 100); engine.ssx /= 100; engine.ssy /= 100; } graphics.blit(iconInfo[8].image, (int)iconInfo[8].x, 15); switch(section) { case 0: if (currentGame.stationedPlanet == currentGame.destinationPlanet) { currentGame.area = systemPlanet[currentGame.stationedPlanet].missionNumber; rtn = 2; engine.done = 1; } else { distance = abs(currentGame.stationedPlanet - currentGame.destinationPlanet); distance = (5 / distance); if (distance < 1) distance = 1; SDL_FreeSurface(iconInfo[9].image); iconInfo[9].image = graphics.textSurface(systemPlanet[currentGame.stationedPlanet].name, FONT_WHITE); SDL_FreeSurface(iconInfo[10].image); iconInfo[10].image = graphics.textSurface(systemPlanet[currentGame.destinationPlanet].name, FONT_WHITE); section = 8; destRect.x = 180; destRect.y = 450; destRect.w = 1; if (currentGame.distanceCovered > 0) destRect.w = currentGame.distanceCovered; destRect.h = 20; } break; case 1: if (engine.keyState[SDLK_SPACE]) { movePlanets = !movePlanets; engine.keyState[SDLK_SPACE] = 0; } if (movePlanets) { sinX += 0.01; cosY += 0.01; } if (showSystem(sinX, cosY)) { if (currentGame.system == 0) { sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name); SDL_FreeSurface(iconInfo[9].image); iconInfo[9].image = graphics.textSurface(string, FONT_WHITE); updateCommsSurface(commsSurface); } else { sprintf(string, "Destination: %s", systemPlanet[currentGame.destinationPlanet].name); SDL_FreeSurface(iconInfo[10].image); iconInfo[10].image = graphics.textSurface(string, FONT_WHITE); } } graphics.blit(iconInfo[9].image, 90, 450); if ((currentGame.system > 0) && (currentGame.stationedPlanet != currentGame.destinationPlanet)) graphics.blit(iconInfo[10].image, 550, 450); break; case 2: showStatus(statsSurface); break; case 3: graphics.blit(savesSurface, 200, 100); saveSlot = showSaveSlots(savesSurface, saveSlot); break; case 4: showShop(); break; case 5: graphics.blit(commsSurface, 170, 70); doComms(commsSurface); break; case 6: graphics.blit(optionsSurface, 230, 130); showOptions(optionsSurface); break; case 7: rtn = 0; engine.done = 1; break; case 8: showSystem(sinX, cosY); graphics.blit(systemPlanet[currentGame.stationedPlanet].image, 150, 450); graphics.blit(iconInfo[9].image, 135, 480); graphics.blit(systemPlanet[currentGame.destinationPlanet].image, 650, 450); graphics.blit(iconInfo[10].image, 635, 480); destRect.w += distance; SDL_FillRect(graphics.screen, &destRect, graphics.red); if (destRect.w >= 450) { currentGame.stationedPlanet = currentGame.destinationPlanet; currentGame.distanceCovered = 0; player.shield = player.maxShield; sprintf(string, "Stationed At: %s", systemPlanet[currentGame.stationedPlanet].name); strcpy(currentGame.stationedName, systemPlanet[currentGame.stationedPlanet].name); SDL_FreeSurface(iconInfo[9].image); iconInfo[9].image = graphics.textSurface(string, FONT_WHITE); updateCommsSurface(commsSurface); section = 1; redrawBackGround = 1; } if (interceptionChance > 0) { if ((rand() % interceptionChance) == 0) { currentGame.area = MAX_MISSIONS - 1; rtn = 2; engine.done = 1; currentGame.distanceCovered = destRect.w; } } break; } graphics.addBuffer(300, 545, 200, 15); if (section != 8) { for (int i = 0 ; i < 8 ; i++) { // if the mission has been completed, there is no "Start Next Mission" icon if (i == 0) { if ((currentGame.stationedPlanet == currentGame.destinationPlanet) && (systemPlanet[currentGame.stationedPlanet].missionCompleted != 0)) continue; else if (currentGame.stationedPlanet == currentGame.destinationPlanet) graphics.blit(graphics.shape[1], 80 + (i * 90), 500); else if (currentGame.stationedPlanet != currentGame.destinationPlanet) graphics.blit(graphics.shape[26], 80 + (i * 90), 500); } else { graphics.blit(graphics.shape[i + 1], 80 + (i * 90), 500); } if (Collision::collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 80 + (i * 90), 500, 32, 32)) { if (i != 0) { graphics.blit(iconInfo[i].image, (int)iconInfo[i].x, 545); } else { if (currentGame.stationedPlanet == currentGame.destinationPlanet) graphics.blit(iconInfo[0].image, (int)iconInfo[i].x, 545); else graphics.blit(iconInfo[11].image, (int)iconInfo[i].x, 545); } if ((engine.keyState[SDLK_LCTRL]) || (engine.keyState[SDLK_RCTRL])) { redrawBackGround = 1; section = i; engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = 0; } } } } engine.keyState[SDLK_LCTRL] = engine.keyState[SDLK_RCTRL] = engine.keyState[SDLK_SPACE] = 0; doCursor(); // Limit us to 60 frame a second while (SDL_GetTicks() < (frameLimit + 16)){} frameLimit = SDL_GetTicks(); } Mix_HaltMusic(); SDL_FreeSurface(statsSurface); SDL_FreeSurface(savesSurface); SDL_FreeSurface(optionsSurface); SDL_FreeSurface(commsSurface); for (int i = 0 ; i < 12 ; i++) SDL_FreeSurface(iconInfo[i].image); player.maxShield = (25 * currentGame.shieldUnits); if (currentGame.distanceCovered == 0) player.shield = player.maxShield; return rtn;}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -