Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6
This is the forum to discuss the Wrox book Professional XNA Game Programming: For Xbox 360 and Windows by Benjamin Nitschke; ISBN: 9780470126776
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old May 25th, 2007, 09:32 PM
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.

  #2 (permalink)  
Old June 3rd, 2007, 09:45 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



  #3 (permalink)  
Old June 5th, 2007, 01:19 AM
Registered User
 
Join Date: May 2007
Location: franklin, MA, USA.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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)



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter2:problem in rendering weather table samouille666 JSP Basics 0 January 17th, 2007 10:50 AM
Question for Chapter2 NameSpace and Fold structure lovehorse BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 16th, 2006 08:21 AM
Compiled error of executing chapter2 source code williamlin BOOK Beginning Linux Programming, 3rd Edition 10 August 25th, 2006 10:23 AM
chapter2-src\src\ch02\sample5 _ need help M7777777bill BOOK: Professional Java Development with the Spring Framework 0 June 14th, 2006 10:00 PM





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