Hey,
I am just about done with my Pong Clone. Just have the Main Menu to fix after I figure out what is wrong with my scoring.
Now you see...since I am working on the scoring, I have some problems with the text being displayed. Not sure why the text isn't being displayed, so I decided to ask here. I didn't want to, as I wanted to make this game the farthest I could without asking for help. This is making me mad! I am going to show you my function, so you know what everything is, and then I will show you the code that dosen't show my text.
Function Decaration:
void Draw_Text(char* string, int size, int x, int y,
int fr, int fg, int fb,
int br, int bg, int bb)
{
TTF_Font* font=TTF_OpenFont("lazy.ttf", size);
SDL_Color foreground_Color={fr, fg, fb};
SDL_Color background_Color={br, bg, bb};
SDL_Surface* text_surface = TTF_RenderText_Shaded(font, string, foreground_Color, background_Color);
SDL_Rect text_location={x, y, 0, 0};
SDL_BlitSurface(text_surface, NULL, SDL_GetVideoSurface(), &text_location);
SDL_FreeSurface(text_surface);
TTF_CloseFont(font);
}
Code that it won't show up in:
if ( ball_position.x == 0 )
{
player2_score++;
Draw_Text("Player 2 has scored!", 24, 400, 544, 66, 66, 255, 77, 77, 77);
ballXVel=0;
ballYVel=0;
ball_position.x=WINDOW_WIDTH/2;
ball_position.y=WINDOW_HEIGHT/2;
if(player2_score == 10 )
{
Draw_Text("Player 2 has won! Congradulation Player 2!", 24, 400, 544, 255, 255, 255, 0, 0, 0);
}
}
if(ball_position.x + ball_position.w > WINDOW_WIDTH)
{
Draw_Text("Player 1 has scored!", 24, 400, 544, 255, 255, 255, 0, 0, 0);
ballXVel=0;
ballYVel=0;
ball_position.x=WINDOW_WIDTH/2;
ball_position.y=WINDOW_HEIGHT/2;
player1_score++;
if(player1_score == 10 )
{
Draw_Text("Player 1 has won! Congradulation Player 1!", 24, 400, 544, 255, 255, 255, 0, 0, 0);
}
}
I am using text in some of the Main Menu(just need to add functionality to it)and that shows up. So I am wondering why it won't work here? All the other part of the code works except for the text. Can anyone please help?
Also lazyfoo if you read this, you are right I am using your font that you made. I am only using it for testing purposes though. So in the final release, it will not be their.
So what's wrong with it?
Chad.