void InitState_HowToPlay() { // initialize the text InitText(); // draw the text PrintStr(1, 1, "How To Play:"); SetTile(2, 3, 20); PrintStr(4, 3, "This is a two-player game"); PrintStr(4, 4, "so get a friend!"); SetTile(2, 6, 20); PrintStr(4, 6, "First player places their"); PrintStr(4, 7, "marble on an empty board"); PrintStr(4, 8, "space"); SetTile(2, 10, 20); PrintStr(4, 10, "That player then rotates"); PrintStr(4, 11, "one of the sub-boards by"); PrintStr(4, 12, "90 degrees. Turn is over"); SetTile(2, 14, 20); PrintStr(4, 14, "Whoever can get 5 of"); PrintStr(4, 15, "their marbles in a row"); PrintStr(4, 16, "(straight or diagonal)"); PrintStr(4, 17, "first, at any time, wins!"); PrintStr(1, 26, "Press B to return..."); // fade in FadeIn(1, true); }
/** Draws the cursor for selecting dimensions in the dimensions menu */ void Level::DrawDimensionsCursor() { int cursorx = 0; int cursory = 0; if (curdimension == NORMAL) { cursorx = 2; cursory = 2; } else if (curdimension == FLUFFY) { cursorx = 2; cursory = 0; } else if (curdimension == HEAVY) { cursorx = 2; cursory = 4; } else if (curdimension == SLOWMOTION) { cursorx = 0; cursory = 2; } else { cursorx = 4; cursory = 2; } SetTile(30, cursorx, cursory, 11); SetTile(30, cursorx + 1, cursory, 12); SetTile(30, cursorx, cursory + 1, 27); SetTile(30, cursorx + 1, cursory + 1, 28); }
void EraseFourTilesAt(int x, int y, int sbb) { SetTile(sbb, x, y, 0); SetTile(sbb, x + 1, y, 0); SetTile(sbb, x, y + 1, 0); SetTile(sbb, x + 1, y + 1, 0); }
void DoState_MainMenu() { // move the selector if((padPressed[0] | padPressed[1]) & BTN_DOWN && currentOpt < 2) { TriggerFx(4, 0xFF, true); SetTile(10, 11 + (2 * currentOpt), ' '); currentOpt++; SetTile(10, 11 + (2 * currentOpt), 127); } if((padPressed[0] | padPressed[1]) & BTN_UP && currentOpt > 0) { TriggerFx(4, 0xFF, true); SetTile(10, 11 + (2 * currentOpt), ' '); currentOpt--; SetTile(10, 11 + (2 * currentOpt), 127); } // take the selection input if((padPressed[0] | padPressed[1]) & BTN_A) { TriggerFx(5, 0xFF, true); nextState = currentOpt + 2; } }
/** Sets a tile tilenumber at position (x, y) in the correct screenblock. */ void Level::SetTileInCorrectScreenblock(int startingscreenblock, int x, int y, int tilenumber) { if (x < 32) { if (y < 32) { SetTile(startingscreenblock, x, y, tilenumber); } else { SetTile(startingscreenblock + 2, x, y - 32, tilenumber); } } else { if (y < 32) { SetTile(startingscreenblock + 1, x - 32, y, tilenumber); } else { SetTile(startingscreenblock + 3, x - 32, y - 32, tilenumber); } } }
void DrawFourTilesAt(int x, int y, int sbb, int tileStart) { SetTile(sbb, x, y, tileStart); SetTile(sbb, x + 1, y, tileStart + 1); SetTile(sbb, x, y + 1, tileStart + 2); SetTile(sbb, x + 1, y + 1, tileStart + 3); }
void DrawMetaTileFrame(uint8_t x, uint8_t y, uint8_t f){ uint16_t toff = f*4; SetTile(x+0,y+0,pgm_read_byte(&tile_frame_table[toff++])); SetTile(x+1,y+0,pgm_read_byte(&tile_frame_table[toff++])); SetTile(x+0,y+1,pgm_read_byte(&tile_frame_table[toff++])); SetTile(x+1,y+1,pgm_read_byte(&tile_frame_table[toff])); }
void Level::Reset_Water(int x, int y, int desiredLength){ for(int i = 0; i < desiredLength; i += 2){ SetTile(29, (x + i), (y - 1), 9); SetTile(29, ((x + 1) + i), (y - 1), 10); SetTile(29, (x + i), y, 11); SetTile(29, ((x + 1) + i), y, 12); } }
void UpdateStatusBar(){ if(paused){ SetTile(1,0,93); SetTile(2,0,94); }else{ SetTile(1,0,91); SetTile(2,0,92); } PrintInt(12,0,gen,true); }
void World::MakeExample() { for (int x = 0; x < GetSizeX(); x ++) { for ( int y = 0; y < GetSizeY(); y++) { if (x > 10 && x < 20 && y > 5 && y <25) { SetTile(x, y, tileManager->GetId("clay")); } else { SetTile(x, y, tileManager->GetId("grass")); } } } }
/** * Draws molecule */ void draw_molecule(uint8_t sx, uint8_t sy) { for (uint8_t x = 0; x < LEVEL_MOLECULE_WIDTH; x++) { for (uint8_t y = 0; y < LEVEL_MOLECULE_HEIGHT; y++) { SetTile(sx + x, sy + y, pgm_read_byte(&(levels[(level - 1) * LEVEL_BYTE_SIZE + LEVEL_NAME_LENGTH + LEVEL_FIELD_WIDTH * LEVEL_FIELD_HEIGHT + x + y * LEVEL_MOLECULE_HEIGHT]))); } } }
/** Draws background of the level */ void Level::Draw() { if (curdimension != prevdimension) { DrawBackground(curdimension); } DrawDoor(); //Clear dimensions menu and cursor for (int screenblock = 29; screenblock < 31; screenblock++) { for (int y = 0; y < 6; y++) { for (int x = 0; x < 6; x++) { SetTile(screenblock, x, y, 0); } } } if (indimensionsmenu) { DrawDimensionsMenu(); DrawDimensionsCursor(); } }
TItem::TItem(const TGfxVec2 & tPos, float fRadius, EItemType eType) :TCircle( tPos, 0.f, fRadius ), m_eType( eType ) { //Sprite settup SpriteSettup(ETextureData_Item, TGfxVec2(m_fRadius, m_fRadius)); SetTile(0, eType); }
/** * Draws field */ void draw_field() { for (uint8_t x = 0; x < LEVEL_FIELD_WIDTH; x++) { for (uint8_t y = 0; y < LEVEL_FIELD_HEIGHT; y++) { SetTile(SCREEN_FIELD_X + x, SCREEN_FIELD_Y + y, level_field[x + y * LEVEL_FIELD_WIDTH]); } } }
/********************************************************************* * * _GetField() * * Function description * Get the field for the new tile depending on the position fo click * Calculate Column, * Set the tile in the column * Check if the game has ended with this move * * Return values * 0 succes (stone is set) * -1 selectet row is full * 1 win * 2 end */ int GetField(int PosX) { int ColumWidth; int FieldX; int FieldY; // // Calculate X field number // ColumWidth = _TileSize + BORDER_TILE*2; if (PosX <= ColumWidth * 1) { FieldX = 0; } else if (PosX <= ColumWidth * 2) { FieldX = 1; } else if (PosX <= ColumWidth * 3) { FieldX = 2; } else if (PosX <= ColumWidth * 4) { FieldX = 3; } else if (PosX <= ColumWidth * 5) { FieldX = 4; } else if (PosX <= ColumWidth * 6) { FieldX = 5; } else if (PosX <= ColumWidth * 7) { FieldX = 6; } else { return -1; } // // Call animation function which returns Y field number // FieldY = SetTile(FieldX); if (FieldY < 0) { // Column full? return -1; } return IncreaseRoundCntCheckEnd(FieldX, FieldY); }
void PBImage::SetProperties(int properties) { SetAlign(properties); SetValign(properties); SetStretch(((properties & STRETCH) > 0)); SetTile(((properties & TILE) > 0)); }
/** Outputs string string to screen at position (x, y) */ void DrawText(int x, int y, const char string[]) { for (int i = 0; i < int(strlen(string)); i++) { SetTile(30, x, y, string[i]); x++; } }
int main() { ClearVram(); SetTileTable(graphicsTiles); Screen.overlayTileTable = overlayTiles; for(int y=0;y<32;y++){ for(int x=0;x<32;x++){ SetTile(x,y,0); } } Screen.scrollHeight = SCREEN_SCROLL_HEIGHT; Screen.overlayHeight = SCREEN_OVERLAY_HEIGHT; Map_Init(); int cameraSpeed = 1; while(1) { uint16_t joypad = ReadJoypad(0); if((joypad & BTN_A)) { cameraSpeed = 4; } else { cameraSpeed = 1; } if((joypad & BTN_LEFT) && Camera_Position.x > cameraSpeed) { Camera_Position.x -= cameraSpeed; } if((joypad & BTN_RIGHT) && Camera_Position.x < (Map_Header.width - MAP_TILE_SCROLL_WRAP_X - 1) * MAP_TILE_PIXEL_SIZE - cameraSpeed) { Camera_Position.x += cameraSpeed; } if((joypad & BTN_UP) && Camera_Position.y > cameraSpeed) { Camera_Position.y -= cameraSpeed; } if((joypad & BTN_DOWN) && Camera_Position.y < (Map_Header.height - MAP_TILE_SCROLL_WRAP_Y - 1) * MAP_TILE_PIXEL_SIZE - cameraSpeed) { Camera_Position.y += cameraSpeed; } Map_Update(); // Screen.scrollX = Camera_Position.x; // Screen.scrollY = Camera_Position.y; WaitVsync(1); } return 0; }
// Draw the players name to location (x,y) void Player::DrawName(int x, int y){ int i = 0; while (p_name[i] != '\0') { SetTile(25, x, y, int(p_name[i])); x++; i++; } }
/** * \brief Helper function to draw the reusable menu frame. */ void drawFrame(void) { SetSpriteVisibility(false); //turn off sprites for now, the menus only use background tiles anyway //to minimize weird problems with drawing a static screen due to mode 3 scrolling, or VRAM_TIES_H vs SCREEN_TILES_H (or something, couldn't figure it out) //scroll the game back to its starting position then turn scrolling back off scrollingOn=true; while(scroll != 0) //reset to align edge of screen to a tile, not part way in between { processScrollSpeed(); } while(drawX != (VRAM_TILES_H-1)) //scroll until the screen is aligned with its starting position (tile position 0 at far left) { processScrollSpeed(); } scrollingOn=false; ClearVram(); //clear screen to prep for drawing the frame u8 drawXTemp = fakemod((drawX+2),VRAM_TILES_H);//variable used for tracking horizontal position of tiles as we draw them. drawing is done top to bottom left to right SetTile(drawXTemp, 1, FRAME_TL); //place top left corner tile for(u8 y=2; y<VRAM_TILES_V-2; y++)//draw lefthand border { SetTile(drawXTemp, y, FRAME_L); } SetTile(drawXTemp, VRAM_TILES_V-2, FRAME_BL); //place bottom left corner tile for(u8 x=0; x<24; x++)//draw middle portion of frame until we reach the right hand side { drawXTemp=fakemod((drawXTemp+1),VRAM_TILES_H); SetTile(drawXTemp, 1, FRAME_T); //draw top piece for(u8 y=2; y<VRAM_TILES_V-2; y++) //fill middle with black { SetTile(drawXTemp, y, BLACK); } SetTile(drawXTemp, VRAM_TILES_V-2, FRAME_B); //draw bottom piece } drawXTemp=fakemod((drawXTemp+1),VRAM_TILES_H); SetTile(drawXTemp, 1, FRAME_TR); //place top right corner tile for(u8 y=2; y<VRAM_TILES_V-2; y++) //draw righthand border { SetTile(drawXTemp, y, FRAME_R); } SetTile(drawXTemp, VRAM_TILES_V-2, FRAME_BR); //place bottom right corner tile }
void Level::InsertCharTile( int x, int y, char charTile ) { if ( charTile == Tile_Dirt::GetId() ) SetTile( x, y, new Tile_Dirt() ); else if ( charTile == Tile_Pipe::GetId() ) SetFTile( x, y, new Tile_Pipe() ); else if ( charTile == Tile_Stone::GetId() ) SetTile( x, y, new Tile_Stone() ); else if ( charTile == Tile_StonePlatform::GetId() ) SetTile( x, y, new Tile_StonePlatform() ); else if ( charTile == '$' ) { // Create a spawn point and it add it to the list of spawn points Vector2f spawn = Vector2f::Zero(); spawn.x = (float)( x * Tile::WIDTH ); spawn.y = (float)( y * Tile::HEIGHT ); spawnPoints.push_back( spawn ); } }
void CreateStatusBar(){ SetTile(14,0,95); SetTile(15,0,96); SetTile(16,0,97); SetTile(17,0,98); SetTile(18,0,62); Print(19,0,PSTR("Start/Stop")); SetTile(30,0,95); SetTile(31,0,99); SetTile(32,0,100); SetTile(33,0,98); SetTile(34,0,62); Print(35,0,PSTR("Menu")); Print(4,0,PSTR("Gen:")); UpdateStatusBar(); }
/** Fills screenblock with a single tile. */ void Level::FillScreenblock(int screenblock, int tile) { for (int y = 0; y < 32; y++) { for (int x = 0; x < 32; x++) { SetTile(screenblock, x, y, tile); } } }
void init(){ // Set display options. REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_BG3; // Set background 0 options. REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32; REG_BG0HOFS = 0; REG_BG0VOFS = 0; // Set background 1 options. REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32; REG_BG1HOFS = 0; REG_BG1VOFS = 0; // Set background 2 options. REG_BG2CNT = BG_CBB(0) | BG_SBB(28) | BG_8BPP | BG_REG_32x32; REG_BG2HOFS = 0; REG_BG2VOFS = 0; // Set background 3 options. REG_BG3CNT = BG_CBB(0) | BG_SBB(27) | BG_8BPP | BG_REG_32x32; REG_BG3HOFS = 0; REG_BG3VOFS = 0; LoadTileData(0, 0, backgroundTiles, backgroundTilesLen); LoadPaletteBGData(0, menuBGPal, menuBGPalLen); LoadTileData(4, 0, spritesTiles, spritesTilesLen); LoadTileData(4, 64, font_bold, 8192); LoadPaletteObjData(0, spritesPal, spritesPalLen); //Clear backgrounds for (int y = 0; y < 32; ++y){ for (int x = 0; x < 32; ++x){ SetTile(30, x, y, 0); SetTile(29, x, y, 0); SetTile(28, x, y, 0); SetTile(27, x, y, 0); } } //Set-up backgrounds from maps for(int i = 0; i < cloudBGMapLen; i++){ SetTile(27, i%32, i/32, cloudBGMap[i]); }; for(int i = 0; i < buildingBGMapLen; i++){ SetTile(28, i%32, i/32, buildingBGMap[i]); }; for(int i = 0; i < fenceBGMapLen; i++){ SetTile(29, i%32, i/32, fenceBGMap[i]); }; for(int i = 0; i < girderMapLen; i++){ SetTile(30, i%32, i/32, girderMap[i]); }; }
void Level::Water_Tile(int x, int y, int desiredLength){ waterFrameCounter++; if(waterFrameCounter % 60 == 0){ waterFrameCounter = 0; if(Water.activeFrameTopLeft == 0){ Water.activeFrameTopLeft = 4; Water.activeFrameTopRight = 5; Water.activeFrameBottomLeft = 6; Water.activeFrameBottomRight = 7; } for(int i = 0; i < desiredLength; i += 2){ SetTile(29, (x + i), (y - 1), Water.spriteNum[Water.activeFrameTopLeft]); SetTile(29, ((x + 1) + i), (y - 1), Water.spriteNum[Water.activeFrameTopRight]); SetTile(29, (x + i), y, Water.spriteNum[Water.activeFrameBottomLeft]); SetTile(29, ((x + 1) + i), y, Water.spriteNum[Water.activeFrameBottomRight]); } } }
void Tilemap::MakeRoom() { for(u32 y = 0; y < m_height; ++y) { for(u32 x = 0; x < m_width; ++x) { if(y == 0 || y == m_height - 1) { SetTile(x, y, TileType::Brick); } else if(x == 0 || x == m_width - 1) { SetTile(x, y, TileType::Brick); } else { SetTile(x, y, TileType::Empty); } } } }
void redraw() { int ay,ax; SetTileTable(mazetiles); // this tells "SetTile" to use teh graphics starting at mazetiles[] for (ay=0;ay<Y_SIZE-1;ay++) // go over the maze array depth for (ax=0;ax<X_SIZE;ax++) // ...and across the width switch (maze[ay][ax]) { case WALL: SetTile(ax+3,ay,0); break; // for each case, check to see what the symbol in the maze is, case BLANK: // then translate it to a tile from 'mazetiles[]'. The numbers SetTile(ax+3,ay,5); break; // are direct tile numbers as seen in Tile Studio case EXIT: SetTile(ax+3,ay,10); break; case PLAYER: SetTile(ax+3,ay,7); break; default: SetTile(ax+3,ay,2); break; }; for (ax=3;ax<40;ax++) // draw an 'empty' border along the bottom edge of the maze (cosmetics) SetTile(ax,24,5); //PrintChar(ax+2,ay,maze[ay][ax]); //this is the 'draw' command from the old text-only version Print(3,26,strCred); // vanity string }
void Level::Big_Cloud(int x, int y){ SetTile(28, x, y, 50); SetTile(28, (x + 1), y, 51); SetTile(28, (x + 2), y, 52); SetTile(28, x, (y + 1), 66); SetTile(28, (x + 1), (y + 1), 67); SetTile(28, (x + 2), (y + 1), 68); }
void loadNextStripe(){ static unsigned int srcX=30; static unsigned char destX=30; for(int y=0;y<22;y++){ SetTile(destX,y+1,pgm_read_byte(&(map_main[(y*MAP_MAIN_WIDTH)+srcX+2]))); } srcX++; if(srcX>=MAP_MAIN_WIDTH)srcX=0; destX++; if(destX>=32)destX=0; }
// Draw current points onto screen void Player::DrawPoints(int x, int y) { // int tile = 0; y -= 4; y = (y > 12 ? 12 : y); if (y < 12) { p_pointsdisplay[y] = p_points; DrawNumber(x, y+4, p_points, 25); if (y > 0) { DrawText(x, y+3, "---", 26); } } else { for (int i = 0; i < 11; i++) { p_pointsdisplay[i] = p_pointsdisplay[i+1]; } p_pointsdisplay[11] = p_points; for (int i = 0; i < 12; i++) { SetTile(25, x, i+4, 0); SetTile(25, x+1, i+4, 0); SetTile(25, x+2, i+4, 0); DrawNumber(x, i+4, p_pointsdisplay[i], 25); } } }