Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions > Development Help

Development Help For help from coding to error finding to that one thing you just can't get right

Reply
 
LinkBack Thread Tools
Old 09-25-2009, 03:14 PM   #1 (permalink)
Jr. Member
 
BlackFox's Avatar
 
Join Date: Mar 2009
Posts: 489
BlackFox is on a distinguished road
Default Racing Game Help

I'm making a racing game for the zune using this website:
Movement Help
This is the only problem I'm running into so far.
Operator '&&' cannot be applied to operands of type 'Microsoft.Xna.Framework.Input.Buttons' and 'bool'

Here is the code:



carPosition.X += (float)(CarMove * Math.Cos(carRotation));
carPosition.Y += (
float)(CarMove * Math.Sin(carRotation));
}
if (GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.DPadDown && !BackgroundCollisionDetection(newX, newY) == true))
{
carPosition.X -= (
float)(CarMove * Math.Cos(carRotation));
carPosition.Y -= (
float)(CarMove * Math.Sin(carRotation));
}
// TODO: Add your update logic here
base.Update(gameTime);
}
privatebool BackgroundCollisionDetection(float newX, float newY)
{
Color[] bgColorArr = newColor[1];
trackCollision.GetData<
Color>(0, newRectangle((int)(newX)
, (
int)(newY), 1, 1), bgColorArr, 0, 1);
Color bgColor = bgColorArr[0];
if (bgColor == Color.Gray)
{
returnfalse;
}
elseif (bgColor == Color.White)
{
returntrue;
}
returnfalse;
}
__________________




BlackFox is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old 09-25-2009, 10:42 PM   #2 (permalink)
Experienced Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 803
ShotgunSnipist has a spectacular aura aboutShotgunSnipist has a spectacular aura about
Send a message via AIM to ShotgunSnipist
Default

if (GamePad.GetState(PlayerIndex.One)Buttons.DPad == ButtonState.Pressed && !BackgroundCollisionDetection(newX, newY) == true)

I think that is more what you were going for.
__________________
Invisible Text. =P



ShotgunSnipist is offline   Reply With Quote
Old 09-26-2009, 08:17 AM   #3 (permalink)
Jr. Member
 
BlackFox's Avatar
 
Join Date: Mar 2009
Posts: 489
BlackFox is on a distinguished road
Default

How would it now whether the "up" button is pressed or not?
__________________




BlackFox is offline   Reply With Quote
Old 09-26-2009, 02:59 PM   #4 (permalink)
Experienced Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 803
ShotgunSnipist has a spectacular aura aboutShotgunSnipist has a spectacular aura about
Send a message via AIM to ShotgunSnipist
Default

Quote:
Originally Posted by BlackFox View Post
How would it now whether the "up" button is pressed or not?
Oh whoops. Sorry.

if (GamePad.GetState(PlayerIndex.One)Buttons.DPad.Up == ButtonState.Pressed && !BackgroundCollisionDetection(newX, newY) == true)
__________________
Invisible Text. =P



ShotgunSnipist is offline   Reply With Quote
Old 09-26-2009, 03:00 PM   #5 (permalink)
Jr. Member
 
BlackFox's Avatar
 
Join Date: Mar 2009
Posts: 489
BlackFox is on a distinguished road
Default

EDIT: Now I get this error:

'Microsoft.Xna.Framework.Input.GamePadButtons' does not contain a definition for 'DPad' and no extension method 'DPad' accepting a first argument of type 'Microsoft.Xna.Framework.Input.GamePadButtons' could be found (are you missing a using directive or an assembly reference?)

EDIT: Nevermind, fixed.
__________________


Last edited by BlackFox; 09-26-2009 at 07:28 PM.



BlackFox is offline   Reply With Quote
Old 09-27-2009, 12:30 PM   #6 (permalink)
Experienced Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 808
Tiptup300 has disabled reputation
Default

Let me piece this apart for yah.

Code:
if 
(
     GamePad.GetState(PlayerIndex.One).IsButtonDown
     (
          Buttons.DPadDown
          && !BackgroundCollisionDetection(newX, newY) == true
     )
)



Tiptup300 is offline   Reply With Quote
Old 09-27-2009, 01:03 PM   #7 (permalink)
Jr. Member
 
BlackFox's Avatar
 
Join Date: Mar 2009
Posts: 489
BlackFox is on a distinguished road
Default

Thanks.
__________________




BlackFox is offline   Reply With Quote
Old 09-27-2009, 09:00 PM   #8 (permalink)
Experienced Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 808
Tiptup300 has disabled reputation
Default

Quote:
Originally Posted by BlackFox View Post
Thanks.
Did you figure out what was wrong?



Tiptup300 is offline   Reply With Quote
Old 09-28-2009, 07:45 AM   #9 (permalink)
Jr. Member
 
BlackFox's Avatar
 
Join Date: Mar 2009
Posts: 489
BlackFox is on a distinguished road
Default

Yea everything's good.
__________________




BlackFox is offline   Reply With Quote
Reply

Bookmarks

Thread Tools