Пример #1
0
void LoadAssets()
{
    SetPaletteObj(0, RGB(0, 0, 0));
    for(int i = 0; i < OBJ_PALETTE_SIZE; i++)
        SetPaletteObj(1 + i, _objPalette[i]);

    SetPaletteBG(0, RGB(0, 0, 0));
    for(int i = 0; i < TILE_PALETTE_SIZE; i++)
        SetPaletteBG(1 + i, _tilePalette[i]);


    int tileCount = 0;
    _tileNames[WHITE_TILE] = AddSquareBGTile(_whiteTile, tileCount);
    tileCount++;
    _tileNames[BLACK_TILE] = AddSquareBGTile(_blackTile, tileCount);
    tileCount++;
    _tileNames[WHITE_R_TILE] = AddSquareBGTile(_whiteRedTile, tileCount);
    tileCount++;
    _tileNames[BLACK_R_TILE] = AddSquareBGTile(_blackRedTile, tileCount);
    tileCount++;
    _tileNames[WHITE_G_TILE] = AddSquareBGTile(_whiteGreenTile, tileCount);
    tileCount++;
    _tileNames[BLACK_G_TILE] = AddSquareBGTile(_blackGreenTile, tileCount);
    tileCount++;
    _pieces[WHITE][KING] = AddSquareBGTile(_whiteKingTile, tileCount);
    tileCount++;
    _pieces[WHITE][QUEEN] = AddSquareBGTile(_whiteQueenTile, tileCount);
    tileCount++;
    _pieces[WHITE][BISHOP] = AddSquareBGTile(_whiteBishopTile, tileCount);
    tileCount++;
    _pieces[WHITE][KNIGHT] = AddSquareBGTile(_whiteKnightTile, tileCount);
    tileCount++;
    _pieces[WHITE][ROOK] = AddSquareBGTile(_whiteRookTile, tileCount);
    tileCount++;
    _pieces[WHITE][PAWN] = AddSquareBGTile(_whitePawnTile, tileCount);
    tileCount++;
    _pieces[BLACK][KING] = AddSquareBGTile(_blackKingTile, tileCount);
    tileCount++;
    _pieces[BLACK][QUEEN] = AddSquareBGTile(_blackQueenTile, tileCount);
    tileCount++;
    _pieces[BLACK][BISHOP] = AddSquareBGTile(_blackBishopTile, tileCount);
    tileCount++;
    _pieces[BLACK][KNIGHT] = AddSquareBGTile(_blackKnightTile, tileCount);
    tileCount++;
    _pieces[BLACK][ROOK] = AddSquareBGTile(_blackRookTile, tileCount);
    tileCount++;
    _pieces[BLACK][PAWN] = AddSquareBGTile(_blackPawnTile, tileCount);

    for(int i = 0; i < 4; i++)
        LoadTile8(4, 0 + i, _cursorTile[i]);

    for(int i = 0; i < 128; i++)
        LoadTile8(0, i, font_bold[i]);
}
Пример #2
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();
		}
	}
}
Пример #3
0
int AddSquareBGTile(uint8_t t[4][64], int pos)
{
    for(int i = 0; i < 4; i++)
        LoadTile8(1, 1 + (pos * 4) + i, t[i]);
    return 1 + (pos * 4);
}