Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 15 of 15

Thread: breakout game scoring

  1. #11
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    26
    I am trying to draw numbers to the screen, I want to erase the 1 in 100 to 2 in 200 for game scoring. Here is the code I am working on.
    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()
    {
    	if(bricks[2][4]==true)
    	{
    	drawBitmapText("100",4.0f,2.0f,0.0f);	
    	}
     
    	if(bricks[2][3]==true)
    	{
    	drawBitmapText("200",4.0f,2.0f,0.0f);	
    	}

  2. #12
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    26
    I am still stuck on how to print a blank character to the screen using glutBitmapCharacter command.

  3. #13
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    26
    well I have almost solved my problem here is the code I am using.
    Code :
    	if(bricks[1][4]==true)
    	{
    	n+=200;
    	str=itoa(n,buffer,10);
    	glRasterPos3f(4.0f,2.0f,0.0f);
    	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 32);
    	drawBitmapText(str,4.0f,2.0f,0.0f);	
    	}
     
    	if(bricks[1][3]==true)
    	{
    	n+=200;
    	str=itoa(n,buffer,10);
    	glRasterPos3f(4.0f,2.0f,0.0f);
    	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 32);
    	drawBitmapText(str,4.0f,2.0f,0.0f);	
    	}
     
    	if(bricks[1][2]==true)
    	{
    	n+=200;
    	str=itoa(n,buffer,10);
    	glRasterPos3f(4.0f,2.0f,0.0f);
    	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 32);
    	drawBitmapText(str,4.0f,2.0f,0.0f);	
    	}
     
    	if(bricks[1][1]==true)
    	{
    	n+=200;
    	str=itoa(n,buffer,10);
    	glRasterPos3f(4.0f,2.0f,0.0f);
    	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 32);
    	drawBitmapText(str,4.0f,2.0f,0.0f);	
    	}
     
    	if(bricks[1][0]==true)
    	{
    	n+=200;
    	str=itoa(n,buffer,10);
    	glRasterPos3f(4.0f,2.0f,0.0f);
    	glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, 32);
    	drawBitmapText(str,4.0f,2.0f,0.0f);	
    	}
    I am so close I need only a little bit of help.

  4. #14
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,105
    I want to erase the 1 in 100 to 2 in 200 for game scoring.
    You don't normally erase anything - since you are redrawing the frame each time click; when you draw the text they is only the new image underneath.

    Likewise a space can be "drawn" by just incrementing your x position by how ever many pixels you want a space to be.

  5. #15
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    26
    so is there anyway to draw a blank character over a regular character.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •