Advertisement

win 32 pong

Started by July 01, 2019 09:49 PM
40 comments, last by phil67rpg 5 years, 5 months ago

well I tried this code but it does nothing


if(comp_move < (0.0f)) 
{ 
  comp_move = 0.0f; 
  comp_velocity = 1.0f; 
}
if(comp_move > (600.0f)) 
{ 
  comp_move = 600.0f; 
  comp_velocity = -1.0f; 
}

comp_move += 5.0f * comp_velocity;	

 

Advertisement

now you're getting it...refer to the overall sample code I gave you earlier. It's the same minus the velocity concept.

Dev careful. Pixel on board.

can we work on the code snippet  you gave me I have almost got it.


comp_move += 5.0f * comp_velocity;	

if(comp_move < (0.0f)) 
{ 
  comp_velocity = 1.0f; 
}
if(comp_move > (600.0f)) 
{ 
  comp_velocity = -1.0f; 
}

 

You are entertaining predictable consistent, I'll give you that. 

Sure. How would you like to work. Perhaps show us how you use that constant rate ping ponging value. Please. By all means. 

https://en.wikipedia.org/wiki/Ping-pong_scheme (Only the first paragraph directly applies)

Making pong here right?

Dev careful. Pixel on board.

3 minutes ago, GoliathForge said:

Perhaps show us how you use that constant rate ping ponging value.

what do you mean?

Advertisement
14 minutes ago, phil67rpg said:

can we work on the code snippet

what do you mean?

As soon as page three came, I was going to pull a Drew and poof... 

Dev careful. Pixel on board.

here is the code almost working I just want it to hit the left edge of the screen


comp_move += 0.1f * comp_velocity;	

if(comp_move <= (0.0f)) 
{ 
  comp_velocity = 1.0f; 
}
if(comp_move >= (710.0f)) 
{ 
  comp_velocity = -1.0f; 
}

 

well you will be happy that I solved my problem.

I believe I would...sort of...I disagree with trying to compare exact float values...go back to where you were. Just use the source I unscrambled. You'll find it very familiar because you wrote most of it. Don't let the timer thing bother you, or the c++ string stream dirty usage or extracting out unnecessary continual brush creation.

Kick it in the corner if it pleases. Only software. 

Dev careful. Pixel on board.

well you will be happy that I solved my problem.

This topic is closed to new replies.

Advertisement