// Keep the dart stationary relative to the dartboard (move with the dartboard), also allows dart to // scroll off the screen, hides any darts that are entirely off the screen void Dart::UpdateDart(int BGPos[]) { int actualloc[2]; bool wrapping[2] = {false, false}; actualloc[0] = loc[0] - BGPos[0]-2*8; actualloc[1] = loc[1] - BGPos[1]-2*8; if (actualloc[0] < 0) { actualloc[0] += 512; wrapping[0] = true; } if (actualloc[1] < 0) { actualloc[1] += 256; wrapping[1] = true; } Animate(); if ((wrapping[0] == true && actualloc[0]+8*8 < 512) || (wrapping[1] == true && actualloc[1]+8*8 < 256) || (wrapping[0] == false && actualloc[0] > SCREEN_WIDTH) || (wrapping[1] == false && actualloc[1] > SCREEN_HEIGHT)) { SetObject(dartnumber, ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(0) | ATTR0_HIDE, ATTR1_SIZE(2) | ATTR1_X(0), ATTR2_ID8(64) | ATTR2_PRIO(2)); } else { SetObject(dartnumber, ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(actualloc[1]) | ATTR0_AFF | ATTR0_AFF_DBL, ATTR1_SIZE(2) | ATTR1_X(actualloc[0]) | ATTR1_AFF(dartnumber-1), ATTR2_ID8(64) | ATTR2_PRIO(2)); } }
/** Updates all gba objects in Level */ void Level::UpdateLevelObjects(int framecounter) { DetermineBackgroundOffsets(); ApplyEntityOffsets(); REG_BG2HOFS = backgroundoffsetx; REG_BG2VOFS = backgroundoffsety; uint16_t facing = 0; if (player.direction == player.LEFT) { facing = ATTR1_HFLIP; } int playertileoffset = 0; if (player.IsMoving()) { if ((framecounter % 15 == 0) && ((!paused) || (!indimensionsmenu))) { player.animationframe = !player.animationframe; } if (player.animationframe == true) { playertileoffset = 2; } else { playertileoffset = 4; } } if (player.isholding) { //Allows for height change when carrying cubes on the head SetObject(player.GetObjNum(), ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(player.drawy + cube[player.cubeheld].GetHeight()), ATTR1_SIZE(2) | ATTR1_X(player.drawx) | facing, ATTR2_ID8(playertileoffset) | ATTR2_PRIO(2)); } else { SetObject(player.GetObjNum(), ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(player.drawy), ATTR1_SIZE(2) | ATTR1_X(player.drawx) | facing, ATTR2_ID8(playertileoffset) | ATTR2_PRIO(2)); } int cubetile = 6 + DimensionTileOffset(curdimension); //Draw cubes for (int i = 0; i < numofcubes; i++) { SetObject(cube[i].GetObjNum(), ATTR0_SHAPE(0) | ATTR0_8BPP | ATTR0_REG | ATTR0_Y(cube[i].drawy), ATTR1_SIZE(1) | ATTR1_X(cube[i].drawx), ATTR2_ID8(cubetile) | ATTR2_PRIO(2)); } UpdateObjects(); }
#include "math.h" #include "overworld/sprite.h" extern u16 gfx_anim_staraptor_frontTiles[]; extern u16 gfx_anim_staraptor_backTiles[]; graphic anim_staraptor_front_graphic = { gfx_anim_staraptor_frontTiles, 0x400, 0xCD72 }; graphic anim_staraptor_back_graphic = { gfx_anim_staraptor_backTiles, 0x400, 0xCD73 }; sprite anim_staraptor_sprite = { ATTR0_SHAPE_SQUARE, ATTR1_SIZE_32_32, ATTR2_PRIO(0), 0 }; sprite anim_staraptor_sprite_hiro = { ATTR0_SHAPE_VERTICAL, ATTR1_SIZE_16_32, ATTR2_PRIO(0), 0 }; gfx_frame anim_staraptor_wings[] = { {0, 16}, {16, 24}, {GFX_ANIM_JUMP, 0} }; gfx_frame anim_staraptor_wings_flipped[] = { {0, 16 | GFX_ANIM_HFLIP}, {16, 24 | GFX_ANIM_HFLIP}, {GFX_ANIM_JUMP, 0}
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(); } } }
graphic trainerschool_test_graphic_correct = { &gfx_trainerschool_correctTiles, 0x800, 0xA0E0 }; graphic trainerschool_test_graphic_wrong = { &gfx_trainerschool_wrongTiles, 0x800, 0xA0E1 }; sprite trainerschool_test_sprite = { ATTR0_SHAPE_SQUARE | ATTR0_ROTSCALE | ATTR0_DSIZE, ATTR1_SIZE_64_64, ATTR2_PRIO(0), 0 }; rotscale_frame trainerschool_test_rotscal_anim[] = { {0x200, 0x200, 0, 0, 0}, {-36, -36, 0, 12, 0}, {ROTSCALE_ANIM_END, 0, 0, 0, 0} }; rotscale_frame *trainerschool_test_rotscale_table[] = {trainerschool_test_rotscal_anim}; oam_template trainerschool_test_oam_template_correct = { 0xA0E0, 0xA0E0, &trainerschool_test_sprite, oam_gfx_anim_table_null,