/** Deals with dimensions menu control and pause */ void Level::TakeInput(Buttons &buttons) { if (buttons.LIsHeld() && !paused && !player.isholding) { indimensionsmenu = true; } else { indimensionsmenu = false; } if (buttons.StartJustPressed() && !buttons.LIsHeld()) { paused = !paused; } if (!paused && !indimensionsmenu) { player.ReadButtons(buttons, *this); } if (indimensionsmenu) { DimensionMenuControl(buttons); } }
int main() { // Set display options. // DCNT_MODE0 sets mode 0, which provides four tiled backgrounds. // DCNT_OBJ enables objects. // DCNT_OBJ_1D make object tiles mapped in 1D (which makes life easier). REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ; REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32 | BG_PRIO(0); REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32 | BG_PRIO(1); REG_BG2CNT = BG_CBB(0) | BG_SBB(25) | BG_8BPP | BG_REG_64x64 | BG_PRIO(2); REG_BG2HOFS = 0; REG_BG2VOFS = 0; ClearObjects(); SetPaletteBG(1, RGB(31, 31, 31)); // white //Load each tile in font_bold into it's corresponding position in charblock 0 for (int i = 0; i < 128; i++) { LoadTile8(0, i, font_bold[i]); } DrawText(5, (SCREEN_HEIGHT / 16) - 2, "DECEPTIVE DIMENSIONS"); DrawText(5, (SCREEN_HEIGHT / 16), "Press start to begin"); Buttons buttons; int framecounter = 0; //Title screen (under construction) while (true) { buttons.Update(); if (buttons.StartJustPressed()) { break; } WaitVSync(); } while (true) { //Load Custom spritesheet LoadPaletteObjData(0, spritesheet4Pal, sizeof spritesheet4Pal); LoadPaletteBGData(0, backgroundnewnewPal, sizeof backgroundnewnewPal); LoadTileData(4, 0, spritesheet4Tiles, sizeof spritesheet4Tiles); LoadTileData(0, 0, backgroundnewnewTiles, sizeof backgroundnewnewTiles); int levelnumber = 1; Level level(levelnumber); for (int screenblock = 21; screenblock < 31; screenblock++) { level.FillScreenblock(screenblock, 0); } level.DrawBackground(level.curdimension); bool gamerunning = true; //Main game loop while (gamerunning) { buttons.Update(); gamerunning = level.CheckIfLevelComplete(); level.TakeInput(buttons); level.MoveObjects(); level.Draw(); level.UpdateLevelObjects(framecounter); framecounter++; WaitVSync(); FlipBuffers(); } //Reload each tile in font_bold into it's corresponding position in charblock 0 for (int i = 0; i < 128; i++) { LoadTile8(0, i, font_bold[i]); } SetPaletteBG(0, RGB(0, 0, 0)); // black SetPaletteBG(1, RGB(31, 31, 31)); // white for (int screenblock = 25; screenblock < 31; screenblock++) { for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { SetTile(screenblock, x, y, 0); } } } level.player.drawx = SCREEN_WIDTH; SetObject(level.player.GetObjNum(), ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_HIDE, ATTR1_SIZE(2) | ATTR1_X(level.player.drawx), ATTR2_ID8(0) | ATTR2_PRIO(2)); UpdateObjects(); DrawText(6, (SCREEN_HEIGHT / 16) - 2, "That's all folks!!"); DrawText(3, (SCREEN_HEIGHT / 16), "Press start to try again"); while (true) { buttons.Update(); if (buttons.StartJustPressed()) { break; } WaitVSync(); } } }