Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

breakout lives

This topic is 1940 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to print out the number of lives left to the screen,
void drawBitmapText(char *string,float x,float y,float z) 
{  
char *c;
glPushAttrib(GL_CURRENT_BIT);
glClear(GL_COLOR_BUFFER_BIT);
brick();
paddle();
ball();
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 lives()
{
	num--;
	strng=itoa(num,buffer_two,10);
	drawBitmapText(strng,0.0f,2.0f,0.0f);	
}

void Timer(int value)
{
	if(x > windowWidth) 
	{
	xstep = -xstep;
	}

	if( x < -windowWidth)
	{
	xstep=-xstep;
	}

	if(y > windowHeight)
	{
	ystep=-ystep;
	}

	if(y < -windowHeight)
	{
	x=0.0f;
	y=0.0f;
	lives();
	ball();
	}

Share this post


Link to post
Share on other sites
Advertisement
well I am trying to print to the screen the number of lives left in my game. I am using the lives() function to print out to the screen but I don't get anything. When the ball goes off the bottom of the screen I want the lives counter to decrement by one. Let me know if you need any more code or information.

Share this post


Link to post
Share on other sites
I'm not particularly familiar with OpenGL, but here are some good questions to consider. Are you sure (0, 2, 0) is actually within the window? Is your window background white (you're printing white text)? Does the current raster position refer to the bottom left or top left of a character? Try outputting the text at (100, 100, 0) and see what happens.

Share this post


Link to post
Share on other sites
try setting all your matrices to identity matrices right before you draw the text. You might be translating the text without your knowing.

EDIT: Also, it appears as if glColor and glRasterPos are not OpenGL 4 compliant. They may have been deprecated because I can't seem to find them here.

EDIT2: Lighting and texturing may also effect the color of your text because it seems when lighting is on, a lighting equation is used to compute a new primary color for the rasterized pixel. Edited by incertia

Share this post


Link to post
Share on other sites
I am using glut 3.7.6 which works with glColor and glRasterPos. Actually this piece of code works.
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);	
	}

Share this post


Link to post
Share on other sites

Can you explain why you are calling:

 

brick();

paddle();

ball();

 

inside your drawBitmapText function.

 

 

Also can you explain what brick_collision() does?


 

Though my guess is that you are clearing the screen every frame, however you are only drawing the "num" for one frame when the "y" leaves the screen.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!