Click here to Skip to main content
15,886,035 members

Comments by Member 9813019 (Top 5 by date)

Member 9813019 6-Feb-13 14:05pm View    
Please post a copy of the new/fixed code, I do not know what to do. :S
Member 9813019 6-Feb-13 13:17pm View    
I do not think I do at any point, if I need to for this to work then would you please mind putting something which will allow me to see how (I am new to XNA and am trying to learn what is neccessary along the way).

Thanks for the tip about moving the code.
Member 9813019 6-Feb-13 12:55pm View    
Here is the Ball.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace XNA_Pong
{
class Ball : Microsoft.Xna.Framework.Game
{
public Vector2 position;
public Texture2D texture;
public int width, height;
public float speed;
public bool downleft, upleft, downright, upright;

public Ball()
{
Content.RootDirectory = "Content";
speed = 6;
width = 20;
height = 20;
downleft=true;
downright = false;
upleft=false;
upright = false;
texture = null;
position = Vector2.Zero;
}
//Ball Draw Function
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(texture, position, Color.White);
}
public void Update()
{
//upleft
if (upleft)
{
position.Y -= speed;
position.X -= speed;
}
//downleft
if (downleft)
{
position.Y += speed;
position.X -= speed;
}
//downright
if (downright)
{
position.Y += speed;
position.X += speed;
}
//upright
if (upright)
{
position.Y -= speed;
position.X += speed;
}
//Moving upleft + bouncing off top wall

if (upleft && position.Y <= 0+25)
{
downleft = true;
upleft=false;

}
//Moving upleft + bouncing off left wall
else if (upleft && position.X <= 0)
{
upright = true;
upleft = false;

}
//Moving upright + bouncing off top wall
else if (upright && position.Y <= 0+25)
{
downright = true;
upright = false;

}
//Moving upright + bouncing off right wall
else if (upright && position.X >= 1024 - width)
{
upleft = true;
upright = false;

}
//Moving downright + bouncing off bottom wall

else if (downright && position.Y >= 768-45)
{
upright = true;
downright = false;

}
//Moving downright + bouncing off right wall
else if (downright && position.X >= 1024 - width)
{
downleft = true;
downright = false;

}
//Moving downleft + bouncing off bottom wall
else if ((downleft) && position.Y >= 768-45)
{
upleft = true;
downleft = false;

}

//Moving downleft + bouncing off left wall
else if (downleft && position.X <= 0)
{
downright = true;
downleft = false;

}


}
}
}

Member 9813019 5-Feb-13 11:40am View    
Deleted
Now the code isn't drawing P1 or P2? Anyone have a solution for this?

Thankyou for the fix Marcus Kramer. :)
Member 9813019 5-Feb-13 11:18am View    
It pops up with:
Invalid token '(' in class, struct, or interface member declaration
Invalid token ',' in class, struct, or interface member declaration
Invalid token ',' in class, struct, or interface member declaration
Invalid token ')' in class, struct, or interface member declaration