| home | |||
|
|||
| links |
|
||
|
developer's mag main page article part 1 part 2 part 3 part 4 part 5 part 6 part 7 part 8 part 9 |
8 - ...And a Little Graphical ImprovementAs the final touch to the program, we ned to redo the small X and O characters. Because the DrawImage() routine contains all of the original drawing code for these elements, we just replace it with a bitmap draw:
#include "x_and_o.cpp"
void paTicTacToe::DrawItem(int index)
{
// draw individual item here in proper place
int dx=52, dy=52, xPos=0; // assume 'o'
if ( 1==m_owner[index] ) // player 1 ('X')?
xPos=53; // 'x' image offset
else if ( 2!=m_owner[index] ) // not player 2?
return; // if not x or o, nothing to draw
// center image and draw it
RECT *rect=&m_rect[index];
int x=rect->x+(rect->width-dx)/2; // center it
int y=rect->y+(rect->height-dy)/2;
DrawImage(x,y,&g_gameTiles,0,0,xPos,0,52,52,IMG_CMB_SRC);
}
This also allows us to remove all the code
involving the m_gridFont variable previously used to draw
the X and O entries.
Previous Section Next Section |
||
| Copyright © 2001-2006 ebmDevMag.com - Legal Notice | |||