// called by touching the screen (see main.c) void Cube::restart() { lifeCounter = 100; playSample(StartSND); initDisplay(); if (IDcounter++ == 0) AudioChannel(0).resume(); // loop }
/** * Handles cube touches */ void Game::handleCubeTouch(GameCube* gameCube, bool isDown) { LOG("isDown is %d\n", isDown); if(isDown) { int x = gameCube->m_x; int y = gameCube->m_y; BG1Drawable& draw = gameCube->m_vid.bg1; if(chestX == x && chestY == y) { if(gotChest) { LOG("Restarting game.\n"); restartGame(); gameCube->render(); gameCube->highlight(); } if(gotKey) { gotChest = true; AudioChannel(0).play(CoinSound); LOG("Chest got!\n"); draw.maskedImage(ChestOpen, Transparent); gameCube->highlight(); } } if(!gotKey && keyX == x && keyY == y) { AudioChannel(0).play(KeySound); LOG("Key got!\n"); gotKey = true; gameCube->render(); gameCube->highlight(); } //draw.setPanning(vec(-32, -32)); } }
// Game Over: Conan The Simpsonian is dead ! void Cube::win() { playSample(WinSND); if (--IDcounter == 0) AudioChannel(0).pause(); // loop reset(); vid.bg0.fill(vec(0,0), LCD_size/8, whiteTile); System::paint(); vid.bg0.image(vec(2,2), EndIMG); System::paint(); String<16> message; vid.initMode(BG0_ROM); message << "Touch: restart"; vid.bg0rom.text(vec(1,0), message); vid.setWindow(4, 8); System::paint(); }