Thread: Chapter2
View Single Post
  #1 (permalink)  
Old May 25th, 2007, 09:32 PM
netblue netblue is offline
Registered User
 
Join Date: Jan 2005
Location: Baltimore, MD, USA.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to netblue
Default Chapter2

I am looking at the RenderBall / RenderPaddles methods and trying to get a handle on the numbers. At first they look a little random, was wondering if anyone could explain why they are used?

RenderSprite(gameTexture,
                (int)((0.05f + 0.9f * ballPosition.X) * 1024) - GameBallRect.Width/2,
                (int)((0.02f + 0.96f * ballPosition.Y) * 768) - GameBallRect.Height/2,
                GameBallRect);

Where is 0.05, 0.9, 0.96 coming from? I assume this is adjusting for screen scaling in some way. Normally code would use a constant that describes a number vice using real numbers inside a method.