Developing Game-Themed Applications with XNA Game Studio

Section III: The Block Breaker Game
b. The Ball class

back to workshop main page


References:

Goals: In this tutorial we want to experience:

Library functions to notice:



Implementation:
  1. Game1.cs:
  2.  add in the following code in the beginning of the file. This is the general utility for generating random number for our application.

    #region __CODE_ADDED__ random number support
         private static Random m_Rand = new Random();
         static public float RandomNumber() {
             return (float)m_Rand.NextDouble();  
         }
        
    #endregion


  3. Create a new file: Ball.cs. Here is the link to the file. Interesting features of this class includes:
  4. Changes to: Game1.cs


Lesson Learned:

Most classes we create will have the following two functions:


This document and the related materials are developed with support from Microsoft Research Computer Gaming Initiative under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871, and 16531.


Kelvin Sung
Computing and Software Systems
University of Washington, Bothell
ksung@u.washington.edu