3 Replies - 299 Views - Last Post: 05 February 2013 - 11:45 PM Rate Topic: -----

#1 pbivens  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 28
  • Joined: 29-January 12

game scoring

Posted 05 February 2013 - 06:16 PM

I am working on game scoring for a breakout game. I am able to write 100 to the screen but then I want to erase the old score and put 200 on the screen and so on. here is the code I am using.
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);
	glRasterPos3f(4.0f,2.0f,0.0f);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '\0');
	drawBitmapText(str,4.0f,2.0f,0.0f);	
	}

	if(bricks[2][3]==true)
	{
	n+=100;
	str=itoa(n,buffer,10);
	glRasterPos3f(4.0f,2.0f,0.0f);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24,'\0');
	drawBitmapText(str,4.0f,2.0f,0.0f);	
	}

	if(bricks[2][2]==true)
	{
	n+=100;
	str=itoa(n,buffer,10);
	glRasterPos3f(4.0f,2.0f,0.0f);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '\0');
	drawBitmapText(str,4.0f,2.0f,0.0f);	
	}

	if(bricks[2][1]==true)
	{
	n+=100;
	str=itoa(n,buffer,10);
	glRasterPos3f(4.0f,2.0f,0.0f);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '\0');
	drawBitmapText(str,4.0f,2.0f,0.0f);	
	}

	if(bricks[2][0]==true)
	{
	n+=100;
	str=itoa(n,buffer,10);
	glRasterPos3f(4.0f,2.0f,0.0f);
	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, '\0');
	drawBitmapText(str,4.0f,2.0f,0.0f);	
	}


I am almost done with my game I just need a little help. let me know if you need more code.

Is This A Good Question/Topic? 0
  • +

Replies To: game scoring

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: game scoring

Posted 05 February 2013 - 07:03 PM

I don't understand your problem. Are you saying that the old score rendering remains when you try to render the new score in its place?

This post has been edited by ButchDean: 05 February 2013 - 07:03 PM

Was This Post Helpful? 0
  • +
  • -

#3 pbivens  Icon User is offline

  • New D.I.C Head

Reputation: -2
  • View blog
  • Posts: 28
  • Joined: 29-January 12

Re: game scoring

Posted 05 February 2013 - 07:34 PM

yes you are correct I want to overwrite the old score with a new score.
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: game scoring

Posted 05 February 2013 - 11:45 PM

Your score display is not being redrawn as you update the rest of the display. You need to place the score code in your screen update routines.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1