Ok well I can draw text to the Directdraw screen but now I am trying to dispaly my varibles.
draws my text
void DrawFont(int x, int y, const char *pszText)
{
RECT rectSrc;
int location = 0;
int letterSpacing;
char curr;
// Go through each character in the given string
for (int i = 0; i < (int)strlen(pszText); i++)
{
// Get the current character
curr = pszText;
// Capital letter?
if (curr >= 'A' && curr <= 'Z')
{
rectSrc.left = ALPHA_LARGE_STARTX + ((curr - 'A') * ALPHA_LARGE_WIDTH);
rectSrc.top = ALPHA_LARGE_STARTY;
rectSrc.right = rectSrc.left + ALPHA_LARGE_WIDTH - 1;
rectSrc.bottom = rectSrc.top + ALPHA_LARGE_HEIGHT - 1;
letterSpacing = ALPHA_LARGE_WIDTH;
}
// Small letter?
else if (curr >= 'a' && curr <= 'z')
{
rectSrc.left = ALPHA_SMALL_STARTX + ((curr - 'a') * ALPHA_SMALL_WIDTH);
rectSrc.top = ALPHA_SMALL_STARTY;
rectSrc.right = rectSrc.left + ALPHA_SMALL_WIDTH - 1;
rectSrc.bottom = rectSrc.top + ALPHA_SMALL_HEIGHT - 1;
letterSpacing = ALPHA_SMALL_WIDTH;
}
// Number?
else if (curr >= '0' && curr <= '9')
{
rectSrc.left = NUMERIC_STARTX + ((curr - '0') * NUMERIC_WIDTH);
rectSrc.top = NUMERIC_STARTY;
rectSrc.right = rectSrc.left + NUMERIC_WIDTH - 1;
rectSrc.bottom = rectSrc.top + NUMERIC_HEIGHT - 1;
letterSpacing = NUMERIC_WIDTH;
}
// Other (space or non-supported character)
else
{
// If it's a space, move over one character (screen position)
if (curr == ' ') location++;
// Skip to the next character in the string
continue;
}
// Draw this character to the backbuffer at the proper location
lpBackBuffer->BltFast(x + (location++ * letterSpacing), y,
g_pText,
&rectSrc,
DDBLTFAST_WAIT | DDBLTFAST_NOCOLORKEY);
}
}
Draws my tiles
void draw_tiles(void)
{
RECT tile_src;
for(Tileset.y=0; Tileset.y<Tileset.Screen_sizey;Tileset.y++)
{for(Tileset.x=0; Tileset.x<Tileset.Screen_sizex; Tileset.x++)
{ //what does this do?
Tileset.scroll_x = Tileset.x + (Tileset.world_camerax/Tileset.Tile_size);//this allows scrolling on y axis
Tileset.scroll_y = Tileset.y + (Tileset.world_cameray/Tileset.Tile_size);//this allows scrolling on x axis
Tileset.offset_x = Tileset.scroll_x & (Tileset.Tile_size - 1); // not sure what this does
Tileset.offset_y = Tileset.scroll_y & (Tileset.Tile_size - 1);
Tileset.tiles = map[Tileset.scroll_y][Tileset.scroll_x];
if (Tileset.tiles <= 1 || Tileset.tiles >= 3)
{ Tileset.wakable = true;}
else if (Tileset.tiles == 2)
{ Tileset.wakable = false;}
char Ntiles = 'Tileset.tiles';
tile_src.left =(Tileset.tiles - 1) *Tileset.Tile_size;
tile_src.top = 0;
tile_src.right= Tileset.tiles * Tileset.Tile_size;
tile_src.bottom=Tileset.Tile_size;
dstr.left= (Tileset.x*Tileset.Tile_size) - Tileset.offset_x;
dstr.top= (Tileset.y*Tileset.Tile_size) - Tileset.offset_y ;
dstr.right = (Tileset.x*Tileset.Tile_size) - Tileset.offset_x + tile_src.right ;
dstr.bottom = (Tileset.y*Tileset.Tile_size) - Tileset.offset_y + tile_src.bottom ;
lpBackBuffer->Blt(&dstr,g_pddTile,&tile_src,DDBLT_WAIT,NULL);
} }}
and im my game main I have
DrawFont(100, 100, "Tile ");
How can I have it display 'Tileset.tiles'
How do I know which tile is one or two?
How can I have my player not go over tile two?
were in my game loop would I put
if (Tileset.tiles <= 1 || Tileset.tiles >= 3)
{ Tileset.wakable = true;}
else if (Tileset.tiles == 2)
{ Tileset.wakable = false;}
I need for my player to tell the differnce between tile one and tile 2.
So i need some way to print on the screen what tile the player is on.
Does any one know how to do that?