p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 (http://p2p.wrox.com/forumdisplay.php?f=325)
-   -   Chapter2 (http://p2p.wrox.com/showthread.php?t=58386)

netblue May 25th, 2007 09:32 PM

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?

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

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.

gavdraper June 3rd, 2007 09:45 AM

I'm stumped on this one too, would be gratefull if anyone could explain this.

skipg June 5th, 2007 01:19 AM

I wondered about it, too. I think the .05f comes from the paddle positions being located at .05 and at (1-.05) in the X direction. That leaves 0.90 for the distance between the paddles. Haven't worked out the Y axis, but it looks to be something similar (1.0 = 0.02 + 0.96 + 0.02)

All times are GMT -4. The time now is 05:58 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.