More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  XBox 360 games: Halo3 or...ProfileFriendsBlogMore Tools Explore the Spaces community

XBox 360 games: Halo3 or build it yourself?

XNA Express, building fun games!
No list items have been added yet.
February 03

Pong in 5 Minutes

Work along with the video, use the code snippets below to follow along, along with the simple graphics:

 

This video, along with the code snippet file that you can find at my sky drive:

>>Pong in 5 minutes code snippets and image files<<

 

Investigating the Point concept in XNA and Pong

What is the Point in XNA?  Take a look at this video, and use the code snippets below to follow along, the simple graphic is included.

 

 

 

>>Code Snippet zipped file<<

December 28

PONG: The Adventure begins! Adding graphics to XNA Express!


Speaking Notes


Steps to Reproduce


"Now let's add graphics to our game. First, I'll create a folder called media and in it, I will now add a new ball and paddle. As you can see, the paddle and ball are the same as in the classic game."

First let's add a folder to hold the media material for the content pipeline.

 

  • Right-click on Pong project in Solution
    Explorer
  • Click Add > New Folder
  • Call the folder Media

Now we will add the two media files:

Ball.png and paddle.png

  • Right-click on Media folder
  • Select Add Existing Item
  • Using the Ctrl key: Select ball.png and paddle.png from your "DevelopMental XNA Files" folder on your desktop
  • Click Add button


"Now I'm going to change the properties of the images to copy if newer. This specifies if the image will be copied to the output directory when I'm building my solution. I want to make sure that if I decide to make changes to my graphics, that they are reflected in the build."

  • Click on ball.png
  • Go to the Properties window
  • Select the Copy to Output Directory property
  • Set the property to Copy if newer
  • Click on ball.png
  • Go to the Properties window
  • Select the Copy to Output Directory property
  • Set the property to Copy if newer
  • Repeat for paddle.png

 


"Now we will create a class called Paddle. In order to do this, we'll create a new class file called Paddle.cs. Then, we have to add the Xna namespace and our implementation code. We have two variables to set the position of the paddle, one defining the coordinates and the other defining the speed. Next, we have a constructor to set the paddles properties. "


1. Right-click on the Pong project in
Solution Explorer
2. Click Add > New Item
3. Select a C# Class
4. Call the class Paddle.cs
5. Edit the file
6. Add using Microsoft.Xna.Framework;
namespace to the namespaces
7. Highlight the class code inside Paddle class
8. Right-click and select Insert Snippet
9. Add the Paddle code snippet, titled:

Demo 2-Step 6 (Paddle Class)

 

 


"Then, we'll create a class called Ball and reproduce the same steps. The difference here is that instead of a constant speed, the horizontal and vertical speed is randomized."

<<Adding the code is similar to the paddle.cs component, refer to that for instructions, this is the previous demo component.>>


1. Right-click on the Pong project in
Solution Explorer
2. Click Add > New Item
3. Select a C# Class
4. Call the class Ball.cs
5. Edit the file
6. Add using Microsoft.Xna.Framework;
namespace to the namespaces
7. Highlight the class code inside Ball class
8. Right-click and select Insert Snippet
9. Add the Ball code snippet, titled

Demo 2- Step 6 (Ball Class)


"The next thing we need to do is add the variables. Let's open the main class and add variables to initialize graphics in our game."

 

 


1. Edit Game1.cs
2. Scroll to right after the ContentManager
variable declaration in the Game1 class
3. Right-click and select Insert Snippet
4. Add the variables code snippet, titled

Demo 2- Step 7 (Variables)

 


"Next, we'll add a ResetGame method to initialize the elements in the game."

 

  1. Scroll right after the variable declarations in the Game1 constructor
  2. Right-click and select Insert Snippet
    1. Demo 2 –Step 9 (Reset Method)
  3. Go to the Intialize method and add ResetGame(); after the TODO comment.


"We need to load the textures and initialize the sprites that we are using in the game. As you can see, the textures are 2D and are referenced from our Media folder."


1. Scroll to the LoadGraphicsContent
method
2. Right-click inside the loadAllContent
conditional block
3. Right-click and select Insert Snippet
4. Select Code Snippet
5. Insert the code to load the Textures
and initialize the SpriteBatch


"Finally, we need to add some code to our Draw method. This will draw the graphics on the screen from the SpriteBatch including the two paddles and the ball. "

  1. Scroll to the Draw method after the TODO comment.
  2. Right-click inside the Draw constructor
  3. Right-click and select Insert Snippet
  4. Select Code Snippet
  5. Insert the snippet titled:
  • Demo 2 – Step 11(Code for Draw Method)


"The last step is to build and launch our game. As you can see, the graphics now appear."

(Remember the game doesn't move, you have only loaded the graphics.)


1. Click on the F5 function key to launch
the application

December 27

Creating Games with the XNA Framework - Part 1 (starting over again, hang in there)

GETTING READY TO Build Pong

 

Before you get going make sure you have done these steps:

  1. Install Visual C# Express.
  2. Install XNA Game Studio Express
  3. Extract the files from the Develop Mental Game kit.
  4. Copy the Develop Mental XNA Files folder to your desktop.
  5. Open Game Studio Express and install the snippet file.
    1. Select the Tools Menu.
    2. Select Code Snippet Manager.
    3. Click Add.
    4. Navigate to the Develop Mental XNA Files folder and then the Code Snippets folder.
    5. Click Open. (You will not see any files listed.)

XNA Game Studio Express
“Creating Games with the XNA Framework - Part 1”
Working with the XNA Framework, no code attached to this one,


Steps to Reproduce

“In this session, I will be showing you how to build a game step by step using XNA Game Studio Express. The game we will be building is Pong - a game that should be quite familiar to you. Let’s start by launching XNA Game Studio Express and creating a brand new project.”

1. Launch XNA Game Studio Express
2. Create a new Windows Game using the XNA templates
3. Call the game PongClassic

“All XNA games have a standard template and format. First, you’ll notice that we are leveraging the XNA namespaces within our application, which provides support for audio, content, graphics, input controls and storage.”

1. Expand the Using Statements region
2. These are the XNA Namespaces, which are located in special files that are referenced automatically when you use the template.  Go to http://msdn.microsoft.com and search for more information about Using statements in C#.

“Notice that Game1 inherits from the Microsoft.Xna.Framework.Game interface which helps you easily manage the game’s logic and rendering code. We also define the GraphicDeviceManager object which handles the configuration and management of your graphic device. The ContentManager object is a run-time component that loads in managed objects from the binary files produced by the design time content pipeline.”

1. Scroll to the Game1 class
2. Show the code as per the speaking
notes

“The Initialize() method sets up the initialization of the game. This is where you set up your game elements such as the sound effects.”

1. Scroll to the Initialize() method
2. Show the code as per the speaking
notes

“LoadGraphicsContent() loads your games’ graphical content into the Resource Management Mode pools. You can use this method to load in the individual bitmap graphics for your game.”

1. Scroll to the LoadGraphicsContent()
method
2. Show the code as per the speaking
notes

“UnloadGraphicsContent() is self-explanatory. It unloads your graphics contents and empties the pool. It will be called once the game screen is shut down.

1. Scroll to the UnloadLoadGraphicsContent()
method
2. Show the code as per the speaking
notes

“Let’s now compile and run the game and take a look at the output. The result is simply a blank pale blue window. In case you are wondering, the exact color is CornflowerBlue.”

1. Hit F5 to compile and launch the
solution
2. A pale blue window will appear
on the screen

“As you know, the classic version of Pong does not have a blue background, it has a black background. So let’s make the first change to our application and change the color to black.”

1. Go to the Draw() method in your code
2. Change:

graphics.GraphicsDevice.Clear(Color.CornflowerBlue) to

graphics.GraphicsDevice.Clear(Color.Black).

All of the color options should appear in Intellisense

“Now we’ll recompile and launch – now the game is starting to look more like the Pong we all know and love. In the next demo, I’ll show you how to implement the graphics within the game.”

1. Click F5 to compile and launch the
solution
2. The background of the game window
should now be black

 

More to follow, hang in there!

Awesome blog entry about pong!

If I was looking for a diligent and good worker, I would look no further than this blog: http://yazmartinez.spaces.live.com/blog/cns!F6DEBFBE98555B1E!127.entry

A question about models, 3D models that is...

A blogger has a question about how to use 3D Models at this link: http://adamlebo.spaces.live.com/blog/cns!D1BDFEB82C6722B4!128.entry
 
If you can help out with XNA 3D Models take a look. 
October 20

Another excellent student blog

Take a look a this blog, JT really gets what to use a Blog for: To tell his story about having fun with technology!
View more entries
 
Thanks for visiting!
No list items have been added yet.
View space
Fun Time 70
View space
Jason
View space
Turbo Drive
View space
Dan Beam
View space
Yazmin
View space
Adam
View space
Ronald
View space
Martin Schray
View space
Philip
View space
sharkolomew@hotmail.
View space
Jason
View space
Andrew Davis Design
View space
Justin Olbrantz
View space
Yen-Shan
View space
Calvin
View space
abby
View space
XNAIreland
View space
Ternado Yung
View space
Josh
View space
Jesse
View space
Joshua
View space
jay
View space
Digvijay Singh Rathore
View space
CD001
View space
Quang
View space
Sina
View space
JJCSGEEK
View space