/** * Entry point of program. */ int main(int argc, char ** argv) { init(); while(true) // Keep app running { setupGame(); while(game.lives) // New Round { setupRound(); while(!game.gameover) // Neither player missed the ball { getInput(); processAI(); moveBall(); displayOutput(); // Sleep PA_CheckLid(); PA_WaitForVBL(); } postRound(); } postGame(); } return 0; }
DWORD WINAPI serverMain(LPVOID in) { Game *sharedGame = (Game *)in; setupGame(sharedGame); return 0; }
int main() { setupGame(); addLength(); addLength(); drawBoard(); drawFood(); Game(); getchar(); }
//------------------------------------------------------------------------------------- void BallGame::createScene(void) { // create your scene here :) setupGame(); createAmbientLight(); createEntities(); createCameraFollower(); setupPhysicsObject(); }
int pingpong() { buffer = create_bitmap( 640, 480); BITMAP *BGpong = load_bitmap("C:\\Sanchit\\Game Pack\\Sprites\\BGpong.bmp", NULL); samSong = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\pingpong.wav"); play_sample(samSong, 128, 128, 1000, 1); setupGame(); while( !key[KEY_ESC]) { draw_sprite(buffer, BGpong, 0,0); textprintf(buffer,font,60,2,makecol(255,255,255), "P1=%d", count1); textprintf(buffer,font,540,2,makecol(255,255,255), "P2=%d", count2); p1Move(); p2Move(); moveBall(); checkWin(); if(scored==1) pingpong_score(); if(key[KEY_BACKSPACE]) { count1=0; count2=0; ball_x=320; ball_y=240; p1_x = 20; p1_y = 210; p2_x = 620; p2_y = 210; stop_sample(samSong); openscreen(); } } return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , m_ui(new Ui::MainWindow) , m_model(0) , m_controller(0) { // instantiate settings once here new Settings(this); // acces them later on via instance() /*Settings* s = Settings::instance(); qDebug() << "***** Current settings *****"; qDebug() << "Player name" << s->playerName(); qDebug() << "Player color" << s->playerColor(); qDebug(); qDebug() << "AI name" << s->aiName(); qDebug() << "AI color" << s->aiColor(); qDebug() << "AI level" << s->aiLevel(); qDebug();*/ m_ui->setupUi(this); m_ui->statusbar->setVisible(false); //connect actions to functions connect(m_ui->actionExit, SIGNAL(triggered()), QApplication::instance(), SLOT(quit())); connect(m_ui->action640x480, SIGNAL(triggered()), this, SLOT(resolutionChange())); connect(m_ui->action800x600, SIGNAL(triggered()), this, SLOT(resolutionChange())); connect(m_ui->action1920x1080, SIGNAL(triggered()), this, SLOT(resolutionChange())); connect(m_ui->actionPlayer, SIGNAL(triggered()), this, SLOT(openSettingsDialog())); connect(m_ui->actionNew_Game, SIGNAL(triggered()), this, SLOT(newGame())); connect(m_ui->actionQuicksave, SIGNAL(triggered()), this, SLOT(quickSave())); connect(m_ui->actionQuickload, SIGNAL(triggered()), this, SLOT(quickLoad())); connect(m_ui->actionImpressum_2, SIGNAL(triggered()), this, SLOT(showImpressum())); connect(m_ui->actionHow_to_play, SIGNAL(triggered()), this, SLOT(showRules())); setupGame(); }
void MartianEngine::playGame() { // Initialize Martian Memorandum game-specific objects initObjects(); // Setup the game setupGame(); configSelect(); if (_loadSaveSlot == -1) { // Do introduction doCredits(); if (shouldQuit()) return; // Display Notes screen doSpecial5(4); if (shouldQuit()) return; _screen->forceFadeOut(); } do { _restartFl = false; _screen->clearScreen(); _screen->setPanel(0); _screen->forceFadeOut(); _events->showCursor(); initVariables(); // If there's a pending savegame to load, load it if (_loadSaveSlot != -1) { loadGameState(_loadSaveSlot); _loadSaveSlot = -1; } // Execute the room _room->doRoom(); } while (_restartFl); }
int main(){ allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0); buffer = create_bitmap( 640, 480); setupGame(); while( !key[KEY_ESC]){ p1Move(); p2Move(); moveBall(); checkWin(); } return 0; }
void splash() { REG_DISPCTL = MODE4 | BG2_ENABLE; loadPalette(splash_screenPal); drawBackgroundImage4(splash_screenBitmap); while (1) { oldButtons = buttons; buttons = BUTTONS; if (BUTTON_PRESSED(BUTTON_START)) { init(); setupGame(); playSoundA(gameSong, GAMESONGLEN, GAMESONGFREQ, 1); playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0); state = GAME; return; } if (BUTTON_PRESSED(BUTTON_SELECT)) { playSoundB(menuSound, MENUSOUNDLEN, MENUSOUNDFREQ, 0); state = INSTRUCTIONS; return; } } }
/** Here we setup all the resources. A MeshRenderer for the paddles which we use for both, a MeshRenderer for the ball and a * Text for rendering the score. */ void Pong::create() { setupGraphics(); setupGame(); }
void singlePlayer(GlobalState* globalData) { static int tempScore = 0; static int transition = 0; static int movedone = 0; // First time playing? // Read first time from SRAM if (globalData->firstTime == TRUE) { if (globalData->newKeyboard) { printKeyboard(globalData, "NAME?", 5); } else { processKeyboard(globalData, game.name, 5); } } if (globalData->doneKeyboard) { globalData->firstTime = FALSE; if (globalData->newGame) { globalData->newGame = 0; // Setup new game setupGame(); tempScore = 0; transition = 0; game.turn = rand() % 2; printGame(globalData); getCards(); // Assume cards already read by interrupts on switches (?) } // Wait till someone presses D to continue if (globalData->keyPress == 0x0D) { transition = 1; } // Begin game with computer if (transition) { if (!game.gameOver) { // Situation depends on game.turn if (game.turn) { if (game.moveSel == 0) { pickMove(globalData); } if (game.moveSel == 1) { tempScore = game.oppScore; game.oppScore = attack(game.myMove, game.myMonster, game.oppScore); if (game.oppScore == tempScore) { prints(0, 10, RED, BLACK, " ", 1); prints(0, 18, RED, BLACK, " ", 1); prints(0, 26, RED, BLACK, " ", 1); prints(0, 10, RED, BLACK, "Missed!", 1); } else { prints(0, 10, RED, BLACK, " ", 1); prints(0, 18, RED, BLACK, " ", 1); prints(0, 26, RED, BLACK, " ", 1); prints(0, 10, RED, BLACK, "Your", 1); printrs(30, 10, RED, BLACK, game.myMonster->monsterName, 1); prints(84, 10, RED, BLACK, "used", 1); printrs(0, 18, RED, BLACK, game.myMove->moveName, 1); prints(0, 26, RED, BLACK, "- ", 1); integerprint(6, 26, RED, BLACK, tempScore - game.oppScore, 1); } game.moveSel = 0; movedone = 1; } } else { // Computer randomly picks a monster and attack game.oppMonster = &myMonsterList[rand() % 3 ]; game.oppMove = &game.oppMonster->movelist[rand() % 3]; tempScore = game.myScore; game.myScore = attack(game.oppMove, game.oppMonster, game.myScore); if (game.myScore == tempScore) { prints(0, 10, RED, BLACK, " ", 1); prints(0, 18, RED, BLACK, " ", 1); prints(0, 26, RED, BLACK, " ", 1); prints(0, 10, RED, BLACK, "Enmy Missed!", 1); } else { prints(0, 10, RED, BLACK, " ", 1); prints(0, 18, RED, BLACK, " ", 1); prints(0, 26, RED, BLACK, " ", 1); prints(0, 10, RED, BLACK, "Enmy", 1); printrs(30, 10, RED, BLACK, game.oppMonster->monsterName, 1); prints(84, 10, RED, BLACK, "used", 1); printrs(0, 18, RED, BLACK, game.oppMove->moveName, 1); prints(0, 26, RED, BLACK, "- ", 1); integerprint(6, 26, RED, BLACK, tempScore - game.myScore, 1); } movedone = 1; } if (movedone == 1) { prints(0, 40, YELLOW, BLACK, "Your Score: ", 1); prints(0, 55, YELLOW, BLACK, " ", 1); integerprint(0, 55, YELLOW, BLACK, game.myScore, 1); prints(0, 70, WHITE, BLACK, "Opponent Score: ", 1); prints(0, 85, WHITE, BLACK, " ", 1); integerprint(0, 85, WHITE, BLACK, game.oppScore, 1); // Check game status game.gameOver = gameStatus(); game.turn = !game.turn; transition = 0; movedone = 0; } // if (game.gameOver == 1) { // if (globalData->newGame == 0) { // printResults(); // } // } } else { if (globalData->newGame == 0) { printResults(); } } } // Display results once there is a lost } }
void multiPlayer(GlobalState* globalData) { int connect = 0; int hostOrFind = 0; // 0 host game, 1 find game char* mySelections[2] = {"Host Game", "Find Game"}; setupXbee(); printMenu(mySelections, BLACK, GRAY, WHITE, YELLOW, 2); prints(25, 7, YELLOW, GRAY, "Multiplayer", 1); processPrintCursor(globalData, 2, BLACK, YELLOW); switch (hostOrFind) { case 0: prints(3, 48, YELLOW, GRAY, "Waiting for players...", 1); hostGame(); break; case 1: prints(3, 88, YELLOW, GRAY, "Looking for games...", 1); findGame(); break; case 0xFF: return; break; } setupGame(); // // Find other players // while (!connect) { // connect = findPlayer(); // } // // // NOTE: Need to build something to determine who goes first // // Compare Xbee ID's perhaps? // // // Begin game // while (!game.gameOver && connect) { // if (game.turn) { // // Pick Move // game.myMove = pickMove(globalData); // // Send Move // sendMove(); // // Receive new score after opponent takes damage // game.oppScore = receiveScore(); // printGame(globalData); // prints(0, 10, RED, BLACK, " ", 1); // prints(0, 10, RED, BLACK, "Opponent took damage:", 1); // prints(0, 21, RED, BLACK, "-", 1); // integerprint(6, 21, RED, BLACK, game.myMove, 1); // } else { // // Receive player move and take damage // game.myScore = attack(receiveMove(), game.myScore); // prints(0, 10, RED, BLACK, " ", 1); // prints(0, 10, RED, BLACK, "Taken damage:", 1); // prints(0, 21, RED, BLACK, "-", 1); // integerprint(6, 21, RED, BLACK, game.oppMove, 1); // // Send new score // sendScore(); // } // prints(0, 45, YELLOW, BLACK, " ", 1); // integerprint(0, 45, YELLOW, BLACK, game.myScore, 1); // prints(0, 75, WHITE, BLACK, " ", 1); // integerprint(0, 75, WHITE, BLACK, game.oppScore, 1); // // Check game status // game.gameOver = gameStatus(); // game.turn =!game.turn; // } // if (!connect) { // printBSOD(); // } else { // printResults(); // } }
Common::Error AGOSEngine::init() { if (getGameId() == GID_DIMP) { _screenWidth = 496; _screenHeight = 400; } else if (getGameType() == GType_FF || getGameType() == GType_PP) { _screenWidth = 640; _screenHeight = 480; } else { _screenWidth = 320; _screenHeight = 200; } initGraphics(_screenWidth, _screenHeight, getGameType() == GType_FF || getGameType() == GType_PP); if ((getGameType() == GType_SIMON2 && getPlatform() == Common::kPlatformWindows) || (getGameType() == GType_SIMON1 && getPlatform() == Common::kPlatformWindows) || ((getFeatures() & GF_TALKIE) && getPlatform() == Common::kPlatformAcorn) || (getPlatform() == Common::kPlatformPC)) { int ret = _midi.open(getGameType()); if (ret) warning("MIDI Player init failed: \"%s\"", MidiDriver::getErrorName(ret)); _midi.setVolume(ConfMan.getInt("music_volume"), ConfMan.getInt("sfx_volume")); _midiEnabled = true; } // Setup mixer syncSoundSettings(); // allocate buffers _backGroundBuf = new Graphics::Surface(); _backGroundBuf->create(_screenWidth, _screenHeight, 1); if (getGameType() == GType_FF || getGameType() == GType_PP) { _backBuf = new Graphics::Surface(); _backBuf->create(_screenWidth, _screenHeight, 1); _scaleBuf = new Graphics::Surface(); _scaleBuf->create(_screenWidth, _screenHeight, 1); } if (getGameType() == GType_SIMON2) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(_screenWidth, _screenHeight, 1); } else if (getGameType() == GType_SIMON1) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(_screenWidth, 134, 1); } else if (getGameType() == GType_WW || getGameType() == GType_ELVIRA2) { _window4BackScn = new Graphics::Surface(); _window4BackScn->create(224, 127, 1); } else if (getGameType() == GType_ELVIRA1) { _window4BackScn = new Graphics::Surface(); if (getPlatform() == Common::kPlatformAmiga && (getFeatures() & GF_DEMO)) { _window4BackScn->create(224, 196, 1); } else { _window4BackScn->create(224, 144, 1); } _window6BackScn = new Graphics::Surface(); _window6BackScn->create(48, 80, 1); } setupGame(); _debugger = new Debugger(this); _sound = new Sound(this, gss, _mixer); if (ConfMan.hasKey("music_mute") && ConfMan.getBool("music_mute") == 1) { _musicPaused = true; if (_midiEnabled) { _midi.pause(_musicPaused); } _mixer->setVolumeForSoundType(Audio::Mixer::kMusicSoundType, 0); } if (ConfMan.hasKey("sfx_mute") && ConfMan.getBool("sfx_mute") == 1) { if (getGameId() == GID_SIMON1DOS) _midi._enable_sfx = !_midi._enable_sfx; else { _effectsPaused = !_effectsPaused; _sound->effectsPause(_effectsPaused); } } _copyProtection = ConfMan.getBool("copy_protection"); _language = Common::parseLanguage(ConfMan.get("language")); if (getGameType() == GType_PP) { _speech = true; _subtitles = false; } else if (getFeatures() & GF_TALKIE) { _speech = !ConfMan.getBool("speech_mute"); _subtitles = ConfMan.getBool("subtitles"); if (getGameType() == GType_SIMON1) { // English and German versions don't have full subtitles if (_language == Common::EN_ANY || _language == Common::DE_DEU) _subtitles = false; // Other versions require speech to be enabled else _speech = true; } // Default to speech only, if both speech and subtitles disabled if (!_speech && !_subtitles) _speech = true; } else { _speech = false; _subtitles = true; } // TODO: Use special debug levels instead of the following hack. _debugMode = (gDebugLevel >= 0); if (gDebugLevel == 2) _dumpOpcodes = true; if (gDebugLevel == 3) _dumpVgaOpcodes = true; if (gDebugLevel == 4) _dumpScripts = true; if (gDebugLevel == 5) _dumpVgaScripts = true; return Common::kNoError; }
int main() { cfguInit(); CFGU_GetSystemModel(&MODEL_3DS); FILE * file; shouldRenderDebug = true; if ((file = fopen("settings.bin", "r"))) { fread(&shouldRenderDebug,sizeof(bool),1,file); fread(&shouldSpeedup,sizeof(bool),1,file); osSetSpeedupEnable(shouldSpeedup); fclose(file); } sf2d_init(); csndInit(); noItem = newItem(ITEM_NULL, 0); currentMenu = MENU_TITLE; currentSelection = 0; quitGame = false; icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM); font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM); bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM); dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); loadSound(&snd_playerHurt, "resources/playerhurt.raw"); loadSound(&snd_playerDeath, "resources/playerdeath.raw"); loadSound(&snd_monsterHurt, "resources/monsterhurt.raw"); loadSound(&snd_test, "resources/test.raw"); loadSound(&snd_pickup, "resources/pickup.raw"); loadSound(&snd_bossdeath, "resources/bossdeath.raw"); loadSound(&snd_craft, "resources/craft.raw"); bakeLights(); int i; for (i = 0; i < 5; ++i) { minimap[i] = sf2d_create_texture(128, 128, TEXFMT_RGBA8, SF2D_PLACE_RAM); sf2d_texture_tile32(minimap[i]); } sf2d_set_vblank_wait(true); sf2d_set_clear_color(0xFF000000); k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP; k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN; k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT; k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT; k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR; k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL; k_pause.input = KEY_START; k_accept.input = KEY_A; k_decline.input = KEY_B; k_delete.input = KEY_X; k_menuNext.input = KEY_R; k_menuPrev.input = KEY_L; if ((file = fopen("btnSave.bin", "rb"))) { fread(&k_up.input, sizeof(int), 1, file); fread(&k_down.input, sizeof(int), 1, file); fread(&k_left.input, sizeof(int), 1, file); fread(&k_right.input, sizeof(int), 1, file); fread(&k_attack.input, sizeof(int), 1, file); fread(&k_menu.input, sizeof(int), 1, file); fread(&k_pause.input, sizeof(int), 1, file); fread(&k_accept.input, sizeof(int), 1, file); fread(&k_decline.input, sizeof(int), 1, file); fread(&k_delete.input, sizeof(int), 1, file); fread(&k_menuNext.input, sizeof(int), 1, file); fread(&k_menuPrev.input, sizeof(int), 1, file); fclose(file); } if ((file = fopen("lastTP.bin", "r"))) { char fnbuf[256]; fgets(fnbuf, 256, file); // get directory to texturepack loadTexturePack(fnbuf); fclose(file); } tickCount = 0; initRecipes(); defineTables(); while (aptMainLoop()) { ++tickCount; hidScanInput(); tickKeys(hidKeysHeld(), hidKeysDown()); if (quitGame) break; if (initGame > 0) setupGame(initGame == 1 ? true : false); if (currentMenu == 0) { tick(); sf2d_start_frame(GFX_TOP, GFX_LEFT); offsetX = xscr; offsetY = yscr; sf2d_draw_rectangle(0, 0, 400, 240, 0xFF0C0C0C); //RGBA8(12, 12, 12, 255)); //You might think "real" black would be better, but it actually looks better that way renderLightsToStencil(); renderBackground(xscr, yscr); renderEntities(player.x, player.y, &eManager); renderPlayer(); resetStencilStuff(); offsetX = 0; offsetY = 0; if(shouldRenderDebug){ sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel]); drawText(fpsstr, 2, 225); } sf2d_end_frame(); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); if(!shouldRenderMap){ sf2d_draw_texture(bottombg, 0, 0); renderGui(); } else { renderZoomedMap(); } sf2d_end_frame(); } else { tickMenu(currentMenu); renderMenu(currentMenu, xscr, yscr); } sf2d_swapbuffers(); } freeRecipes(); freeLightBakes(); sf2d_free_texture(icons); sf2d_free_texture(minimap[0]); sf2d_free_texture(minimap[1]); sf2d_free_texture(minimap[2]); sf2d_free_texture(minimap[3]); sf2d_free_texture(minimap[4]); freeSounds(); csndExit(); cfguExit(); sf2d_fini(); return 0; }
/***************************************************************************** * * Description: * Implements example game * ****************************************************************************/ void playExample(void) { gameStatus = GAME_NOT_STARTED; setupGame(FALSE); lcdGotoxy(5,40); lcdColor(0,0xe0); lcdPuts("Press to start"); while(gameStatus != GAME_END) { tU8 anyKey; anyKey = checkKey(); switch(gameStatus) { case GAME_NOT_STARTED: if (anyKey != KEY_NOTHING) { gameStatus = GAME_RUNNING; setupGame(TRUE); } break; case GAME_RUNNING: if (anyKey != KEY_NOTHING) { if (anyKey == KEY_UP) { if(isValid(currXpos, currYpos, shift[currFigure])) currFigure = shift[currFigure]; } else if (anyKey == KEY_DOWN) { if(isValid(currXpos, currYpos+1, currFigure)) currYpos++; } else if (anyKey == KEY_RIGHT) { if(isValid(currXpos+1, currYpos, currFigure)) currXpos++; } else if (anyKey == KEY_LEFT) { if(isValid(currXpos-1, currYpos, currFigure)) currXpos--; } else if (anyKey == KEY_CENTER) gameStatus = GAME_OVER; advanceGame(); osSleep(1); } else { advanceGame(); osSleep(1); } break; case GAME_OVER: { tMenu menu; menu.xPos = 10; menu.yPos = 40; menu.xLen = 6+(12*8); menu.yLen = 4*14; menu.noOfChoices = 2; menu.initialChoice = 0; menu.pHeaderText = "Game over!"; menu.headerTextXpos = 20; menu.pChoice[0] = "Restart game"; menu.pChoice[1] = "End game"; menu.bgColor = 0; menu.borderColor = 0x6d; menu.headerColor = 0; menu.choicesColor = 0xfd; menu.selectedColor = 0xe0; switch(drawMenu(menu)) { case 0: gameStatus = GAME_RUNNING; setupGame(TRUE); break; //Restart game case 1: gameStatus = GAME_END; break; //End game default: break; } } break; default: gameStatus = GAME_END; break; } } }
int main(int argc, char* argv[]) { sSdlWrapper* wrap = initializeSDLWrapper("Snake", 800, 600, 32, 1, 1); game* gameEngine = initGame(wrap, 32, 24); int Selection = 0; sTextGFX* startUnsel = createText(wrap, "Start Game", 0xFFFFFFFF); sTextGFX* startSel = createText(wrap, "Start Game", 0xFFFFF000); sTextGFX* exitUnsel = createText(wrap, "Exit Game" , 0xFFFFFFFF); sTextGFX* exitSel = createText(wrap, "Exit Game" , 0xFFFFF000); sLinkedList* titleList = 0; FILE* titleFile = fopen("snake.pic", "r"); listInitialize(&titleList, sizeofPoint(), NULL); for(int x = 0; x < 32; x++) for(int y = 0; y < 24; y++) if(x == 0 || x == (31) || y == 0 || y == (23)) { point* toAdd = createPoint(x,y); listPushFront(titleList, (void*)toAdd); free(toAdd); } while(isRunning(wrap)) { beginFrame(wrap); if(State == -1) { readTitleFile(titleList, titleFile); renderList(titleList, wrap); } else if(State == 1) tick(gameEngine); else { if(Selection == 0) { renderText(wrap, startSel, 400, 300); renderText(wrap, exitUnsel, 400, 325); } else { renderText(wrap, startUnsel, 400, 300); renderText(wrap, exitSel, 400, 325); } if(keyDown(wrap, SDLK_DOWN)) Selection = 1; if(keyDown(wrap,SDLK_UP)) Selection = 0; if(keyDown(wrap, SDLK_RETURN)) { if(Selection == 0) { State = 1; setupGame(gameEngine); } else toggleRunning(wrap); } renderList(titleList, wrap); } if(keyPressed(wrap, SDLK_ESCAPE)) toggleRunning(wrap); endFrame(wrap); } listClear(titleList); free(titleList); destroyText(startUnsel); destroyText(startSel); destroyText(exitUnsel); destroyText(exitSel); deinitializeWrapper(wrap); destroyGame(gameEngine); free(wrap); return 0; }
int main() { sf2d_init(); csndInit(); noItem = newItem(ITEM_NULL,0); currentMenu = MENU_TITLE; currentSelection = 0; quitGame = false; icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM); font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM); //consoleInit(GFX_BOTTOM, NULL); // printf("Press 'Start' to exit.\n"); loadSound(&snd_playerHurt, "resources/playerhurt.raw"); loadSound(&snd_playerDeath, "resources/playerdeath.raw"); loadSound(&snd_monsterHurt, "resources/monsterhurt.raw"); loadSound(&snd_test, "resources/test.raw"); loadSound(&snd_pickup, "resources/pickup.raw"); loadSound(&snd_bossdeath, "resources/bossdeath.raw"); loadSound(&snd_craft, "resources/craft.raw"); int i; for(i = 0;i < 5;++i){ minimap[i] = sf2d_create_texture(128,128,TEXFMT_RGBA8,SF2D_PLACE_RAM); sf2d_texture_tile32(minimap[i]); } sf2d_set_vblank_wait(true); sf2d_set_clear_color(0xFF); /* Default inputs */ k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP; k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN; k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT; k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT; k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR; k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL; k_pause.input = KEY_START; k_accept.input = KEY_A; k_decline.input = KEY_B; k_delete.input = KEY_X; FILE * file; /* If btnSave exists, then use that. */ if ((file = fopen("btnSave.bin", "rb"))){ fread(&k_up.input, sizeof(int), 1, file); fread(&k_down.input, sizeof(int), 1, file); fread(&k_left.input, sizeof(int), 1, file); fread(&k_right.input, sizeof(int), 1, file); fread(&k_attack.input, sizeof(int), 1, file); fread(&k_menu.input, sizeof(int), 1, file); fread(&k_pause.input, sizeof(int), 1, file); fread(&k_accept.input, sizeof(int), 1, file); fread(&k_decline.input, sizeof(int), 1, file); fread(&k_delete.input, sizeof(int), 1, file); fclose(file); } //screenShot = false; tickCount=0; initRecipes(); defineTables(); while (aptMainLoop()) { ++tickCount; hidScanInput(); tickKeys(hidKeysHeld(),hidKeysDown()); //if (quitGame || hidKeysHeld() & KEY_SELECT) break; if (quitGame) break; //if (hidKeysDown() & (KEY_L | KEY_R)) screenShot = true; // else screenShot = false; if(initGame > 0) setupGame(initGame == 1 ? true : false); if(currentMenu == 0){ tick(); sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),player.x, player.y,eManager.lastSlot[currentLevel]); sf2d_start_frame(GFX_TOP, GFX_LEFT); if(currentLevel == 0){ sf2d_draw_texture_part_scale(minimap[1],(-xscr/3)-256,(-yscr/3)-32,0,0,128,128,12.5,7.5); sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF); } offsetX = xscr;offsetY = yscr; renderBackground(xscr,yscr); renderEntities(player.x, player.y, &eManager); renderPlayer(); offsetX = 0;offsetY = 0; renderItemWithText(player.p.activeItem, 10, 205); // drawText(debugText,2,208); drawText(fpsstr,2,225); sf2d_end_frame(); sf2d_start_frame(GFX_BOTTOM, GFX_LEFT); if(currentLevel == 0 && airWizardHealthDisplay > 0){ sprintf(bossHealthText, "BOSS: %.0f%%", ((float)airWizardHealthDisplay/2000.0)*100); drawText(bossHealthText,2,225); } renderGui(); sf2d_draw_texture(minimap[currentLevel], 192, 112);//y:56 sf2d_end_frame(); } else{ tickMenu(currentMenu); renderMenu(currentMenu,xscr,yscr); } sf2d_swapbuffers(); } freeRecipes(); sf2d_free_texture(icons); sf2d_free_texture(minimap[0]); sf2d_free_texture(minimap[1]); sf2d_free_texture(minimap[2]); sf2d_free_texture(minimap[3]); sf2d_free_texture(minimap[4]); freeSounds(); csndExit(); sf2d_fini(); return 0; }