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 June 1st, 2007, 03:08 PM
Authorized User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2006
Location: La Vergne, TN, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jnbutler
Default Chapter 2 problem

I have been following along in the book and was trying to put just the code from the first part of chapt 2 in my project to run just the TestMenuSprites unit test. I was also looking at the download source so I did not miss anything I may need for that part. I loaded the 3 sprites, did the spriteBatch code, put in the Rectangle constants, implemented the TestMenuSprites method, and the TestDelegate, TestPongGame class, StartGame method, the two overloaded RenderSprite method stubs, change program.cs to call StartGame or TestMenuSprites based on which one is not commented out. At this point in the chapter I should be able to press F5 and see a screen with just the SpaceBackground image. But I get an error about the width and height parameters in this code:
Code:
spritBatch.Draw(backgroudTexture, new Rectangle(0, 0, width, height), Color.LightGray);
There are two errors, one for each of those parameters that state "The name 'width/height' does not exist in the current context"
I can't debug this since it will not compile to have an executable to debug. I have search through the downloaded code and even compiled the downloaded code and I can't figure out what I'm doing wrong in my project. Any help is greatly appreciated.

Very Confused


jnbutler
__________________
jnbutler
  #2 (permalink)  
Old June 1st, 2007, 08:54 PM
Authorized User
Points: 40, Level: 1
Points: 40, Level: 1 Points: 40, Level: 1 Points: 40, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2006
Location: La Vergne, TN, USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jnbutler
Default

Well, there is nothing like learning from experience. Upon further investigation I discovered that I had indeed left out a couple of lines of code. In the Variables region I left out:
Code:
/// <summary>
/// Resolution of our game.
/// </summary>
int width, height;
And in the Initialize method I left out:
Code:
// Remember resolution
width = graphics.GraphicsDevice.Viewport.Width;
height = graphics.GraphicsDevice.Viewport.Height;
Maybe this will help others who do the same at this part of chapter 2.
On with the Pong journey.................
Oh, BTW, I first played pong on an Atari arcade machine in a Seven Eleven back in the 80's and then later on the first Atari console system. Man I'm old!

jnbutler


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having a problem in chapter 2 Okie BOOK: Beginning Access 2003 VBA 1 August 9th, 2007 10:30 AM
Chapter 5 Problem gogeo BOOK: Beginning Access 2003 VBA 1 October 10th, 2005 10:34 AM
Problem in chapter 7 gpauta JSP Basics 1 June 1st, 2004 04:31 AM
problem in chapter 4 gpauta JSP Basics 3 May 11th, 2004 06:31 AM





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