Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 25th, 2007, 10: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, 10: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, 02: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)

 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

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 09:21 AM
Compiled error of executing chapter2 source code williamlin BOOK Beginning Linux Programming, 3rd Edition 10 August 25th, 2006 11:23 AM
chapter2-src\src\ch02\sample5 _ need help M7777777bill BOOK: Professional Java Development with the Spring Framework 0 June 14th, 2006 11:00 PM



All times are GMT -4. The time now is 06:57 PM.


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