コード例 #1
0
static void DrawInventory(void)
{
int x, y, w, i, c;

	// draw the box
	TextBox::DrawFrame(inv.x, inv.y, inv.w, inv.h);
	
	// - draw the weapons ----
	x = inv.x + ARMS_X;
	y = inv.y + ARMS_Y;
	draw_sprite(x, y, SPR_TEXT_ARMS, 0, 0);
	y += sprites[SPR_TEXT_ARMS].h;
	
	DrawSelector(&inv.armssel, x, y);
	
	// draw the arms
	for(w=1;w<WPN_COUNT;w++)
	{
		if (!player->weapons[w].hasWeapon) continue;
		
		draw_sprite(x+1, y+1, SPR_ARMSICONS, w, 0);
		DrawWeaponLevel(x+1, y+16, w);
		DrawWeaponAmmo(x+1, y+16+8, w);
		
		x += inv.armssel.spacing_x;
	}
	
	// - draw the items ----
	x = inv.x + ITEMS_X;
	y = inv.y + ITEMS_Y;
	draw_sprite(x, y, SPR_TEXT_ITEMS, 0, 0);
	y += sprites[SPR_TEXT_ITEMS].h;
	
	DrawSelector(&inv.itemsel, x, y);
	
	c = 0;
	for(i=0;i<inv.itemsel.nitems;i++)
	{
		draw_sprite(x, y, SPR_ITEMIMAGE, inv.itemsel.items[i], 0);
		
		x += inv.itemsel.spacing_x;
		
		if (++c >= inv.itemsel.rowlen)
		{
			x = inv.x + ITEMS_X;
			y += inv.itemsel.spacing_y;
			c = 0;
		}
	}
}
コード例 #2
0
ファイル: Game.cpp プロジェクト: ajorians/nHitori
void Game::UpdateDisplay()
{
	m_ColorIntensity.Animate();

	//Draw background
	if( !is_classic ) {
		SDL_BlitSurface(m_pBackground, NULL, m_pScreen, NULL);
	} else {
		SDL_FillRect(m_pScreen, NULL, SDL_MapRGB(m_pScreen->format, 255, 255, 255));
	}

	int nWidth = GetHitoriBoardWidth(m_Hitori);
	int nHeight = GetHitoriBoardHeight(m_Hitori);

	int nPieceWidth = (SCREEN_WIDTH-1)/nWidth;//The -1 is just so range of pixels is 0->Dimension-1; instead of 0->Dimension
	int nPieceHeight = (SCREEN_HEIGHT-1)/nHeight;

        int nPieceSize = nPieceWidth < nPieceHeight ? nPieceWidth : nPieceHeight;

	int nBoardWidth = nPieceSize * nWidth;
	int nBoardHeight = nPieceSize * nHeight;

	int nTop = (SCREEN_HEIGHT - nBoardHeight) / 2;
	int nLeft = (SCREEN_WIDTH - nBoardWidth) / 2;

	/*SDL_Rect rectBoard;
	rectBoard.x = nLeft;
	rectBoard.y = nTop;
	rectBoard.w = nBoardWidth;
	rectBoard.h = nBoardHeight;
	SDL_FillRect(m_pScreen, &rectBoard, SDL_MapRGB(m_pScreen->format, GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B));*/
	boxRGBA(m_pScreen, nLeft, nTop, nLeft + nBoardWidth, nTop + nBoardHeight,  GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B, 180);

	for(int nX=0; nX<=nWidth; nX++) {
		vlineRGBA(m_pScreen, nLeft + nX*nPieceSize, nTop, nTop + nBoardHeight, 0, 0, 0, 255);
	}

	for(int nY=0; nY<=nHeight; nY++) {
		hlineRGBA(m_pScreen, nLeft, nLeft + nBoardWidth, nTop + nY*nPieceSize, 0, 0, 0, 255);
	}

	for(int nX=0; nX<nWidth; nX++) {
                for(int nY=0; nY<nHeight; nY++) {
			DrawCell(nX, nY, nLeft, nTop, nPieceSize);
                }
        }

        DrawSelector(nLeft, nTop, nPieceSize);

#ifdef USE_GRAPHIC_YOU_WIN
	if( m_bGameOver ) {
		if( m_pWinGraphic == NULL ) {
		m_pWinGraphic = nSDL_LoadImage(image_HitoriYouWin);
                SDL_SetColorKey(m_pWinGraphic, SDL_SRCCOLORKEY, SDL_MapRGB(m_pWinGraphic->format, 255, 255, 255));
		}

		SDL_Rect rectWin;
		rectWin.x = (SCREEN_WIDTH - m_pWinGraphic->w)/2;
		rectWin.y = (SCREEN_HEIGHT - m_pWinGraphic->h)/2;
		rectWin.w = m_pWinGraphic->w;
		rectWin.h = m_pWinGraphic->h;
	
		SDL_BlitSurface(m_pWinGraphic, NULL, m_pScreen, &rectWin);	
	}
#else
	if( !m_YouWinMessage.Animate() )
#endif
        {
                SDL_UpdateRect(m_pScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
        }
}