Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


game scoring


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 05 March 2013 - 08:28 PM

I am almost done with my breakout  game. I have a small problem with the scoring system. I have been able to print to the screen the numbers used in scoring. Basically I can print out 100 and then overwrite it with 200 points.  What want to do is print the number then print black numbers to overwrite the text and then print the next highest score. here is my code.
void drawBitmapText(char *string,float x,float y,float z)
{
	char *c;
	glRasterPos3f(x, y,z);
	for (c=string; *c != '\0'; c++)
	{
		glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *c);
	}
}

void brick_collision()
{
	GLint n=0;
	if(bricks[2][4]==true)
	{
		n+=100;
		str=itoa(n,buffer,10);
		drawBitmapText(str,4.0f,2.0f,0.0f);
	}
	if(bricks[2][3]==true)
	{
		n+=100;
		str=itoa(n,buffer,10);
		drawBitmapText(str,4.0f,2.0f,0.0f);
	}
	if(bricks[2][2]==true)
	{
		n+=100;
		str=itoa(n,buffer,10);
		drawBitmapText(str,4.0f,2.0f,0.0f);
	}
	if(bricks[2][1]==true)
	{
		n+=100;
		str=itoa(n,buffer,10);
		drawBitmapText(str,4.0f,2.0f,0.0f);
	}
	if(bricks[2][0]==true)
	{
		n+=100;
		str=itoa(n,buffer,10);
		drawBitmapText(str,4.0f,2.0f,0.0f);
	}
 

Edited by JTippetts, 06 March 2013 - 11:28 AM.
Fix code tags


Sponsor:

#2 NightCreature83   Crossbones+   -  Reputation: 2937

Like
0Likes
Like

Posted 06 March 2013 - 09:57 AM

Because the first thing you do before you start drawing is clear your back buffer so that non of the old frame is there any more, you need to issue two draw calls for your effect one with the old score and one with your new score.


Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, Mad Max

#3 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 06 March 2013 - 10:03 PM

how do you clear the back buffer?



#4 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 07 March 2013 - 04:07 PM

well I have almost solved my problem. here is my code all I need is some tweaking

void
 
 
drawBitmapText(char *string,float x,float y,float z) 
{ 
char
 
 
*c;
glPushAttrib(
 
GL_CURRENT_BIT);
glColor3f(1.0f,1.0f,1.0f);
glRasterPos3f(
 
x, y,z);
for
 
 
(c=string; *c != '\0'; c++) 
{
glutBitmapCharacter(
 
GLUT_BITMAP_TIMES_ROMAN_24, *c);
}
glPopAttrib();
}
void
 
 
drawBitmapText_clear(char *string,float x,float y,float z) 
{ 
char
 
 
*c;
glPushAttrib(
 
GL_CURRENT_BIT);
glColor3f(0.0f,0.0f,0.0f);
glRasterPos3f(
 
x, y,z);
for
 
 
(c=string; *c != '\0'; c++) 
{
glutBitmapCharacter(
 
GLUT_BITMAP_TIMES_ROMAN_24, *c);
}
glPopAttrib();
}
void
 
 
brick_collision()
{
 
 
GLint n=0;
 
 
if(bricks[2][4]==true)
{
n+=100;
str=itoa(n,buffer,10);
drawBitmapText_clear(str,0.0f,2.0f,0.0f); 
drawBitmapText(str,0.0f,2.0f,0.0f);
}
 
 
if(bricks[2][3]==true)
{
n+=100;
str=itoa(n,buffer,10);
drawBitmapText_clear(str,0.0f,2.0f,0.0f); 
drawBitmapText(str,0.0f,2.0f,0.0f); 
}
 
 
if(bricks[2][2]==true)
{
n+=100;
str=itoa(n,buffer,10);
drawBitmapText_clear(str,0.0f,2.0f,0.0f); 
drawBitmapText(str,0.0f,2.0f,0.0f); 
}
 
 
if(bricks[2][1]==true)
{
n+=100;
str=itoa(n,buffer,10);
drawBitmapText_clear(str,0.0f,2.0f,0.0f); 
drawBitmapText(str,0.0f,2.0f,0.0f); 
}
 
 
if(bricks[2][0]==true)
{
n+=100;
str=itoa(n,buffer,10);
drawBitmapText_clear(str,0.0f,2.0f,0.0f); 
drawBitmapText(str,0.0f,2.0f,0.0f); 
}
 
 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS