15,886,035 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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