XNA Game-Themed CS1 Examples (XGC1)

Release 2.0 (XNA V3.1)
2/8/2010

XGC1: Mapping to C# How to Program

Mappings of Examples to:
C# How to Program


Shows mapping of examples to C# How to Program. Here is the link to all textbook mappings.
ID Topics Section Page Example
Topic 1: Working with XNACS1Lib None
Ex_1 This explains what sort of files, etc, goes into a basic XNA project -- -- --
Ex_2 This explains, in detail, what an XNACS1 project is composed of. -- -- --
Topic 2: Basic I/O and Variables Chap 3
Ex_1
  • Displaying screen output
  • Sequence structures
  • Strings and string literal
3.2
Ex_2 Simple input and output 3.6
Ex_3
  • Local variable
  • Variable assignment
  • Displaying multiple items in a statement
3.6
Ex_4 Instance variable 8.2
Ex_5 Rectangle data type and drawing
Ex_6 Circle data type and instances
Ex_7 Multiple data types and instances
Ex_8 Multiple rectangles
Ex_9 Floating point addition 4.9
Ex_10 Integer and floating point subtraction
Ex_11 Multiplication and percentage 4.9, 3.5
Ex_12 Division and average
Ex_13 Evaluation of simple formula
Ex_14 Constants 7.4.1 (arrays);8.12 (OOP)
Topic 3: Modules and Functions Chap 6
Ex_1 Simple function call, simple print, introduce texture. 6.1, 6.2 (Overview)
Ex_2 Simple function call with return value, RandomFloat and RandomInt functions 6.5
Ex_3 Functions accessing instance variables: naming convention for instance variables (with m_) initialize circle. 6.5
Ex_4 Functions with local variable store circle y-Pos to local, use it to compute new radius 6.5
Ex_5 Functions as steps in an algorithm
Ex_6 Functions as steps in an algorithm. Example: parabolic free fall
Ex_7 Parameter passing to functions Two parabolic fee falling soccer Point out local vars and passed in parameters (3.5: is local var 3.6: is multiple parameters. 6.5
Ex_8 Spotlight example on passing parameter, take a second look at 2000.700 (formula). 6.5
Ex_9 Passing by value and by ref. 6.8
Ex_10 Math library functions 6.3
Topic 4: Decision Structures Chap 4
Ex_1 Simple ball and two paddles: ball travels to infinity and paddle are controlled by left/right thumbsticks. 4.1, 4.4 (overview)
Ex_2 Simple floating point comparison: check ball position to re-start it. 4.5
Ex_3 If statement with simple conditional function: collide ball with paddles, bounce.
Ex_4 Simple if-then-else: novice vs expert by checking for numBounces. If then else on left and right paddle collision. 4.6
Ex_5 String equality comparison: store skillLevel as a string, compare to play the victory cue.
Ex_6 Paddle: if left fails then test for right. World: if top fails then bottom, etc. 4.6
Ex_7 Multiple nested conditional:
  • check the world boundary by number testing.
  • keep track of numBalls generated.
4.6
Ex_8 Multiple nested conditional: collision with 3 blocks in the middle.
Ex_9 Case statement: testing with the boundary of the world by function call. 5.4
Ex_10 AND logical operator: winning condition 5.8
Ex_11 OR logical operator: left and right paddle same action. 5.8
Ex_12 Combine all of the above.
Topic 5: Repetition Structures Chap 4, 5
Ex_1 Zap Game: Empty game (template).
Ex_2 Simple while loop: draw a series of balls 4.7, 4.8
Ex_3 Spot light example with while loop: plot sine/cosine with the interactive control 5.2 (counting loop)
Ex_4 Add a new basketball following the sine locus of the sine-plot
Ex_5 Zap Game: Functions in loop body, hero sends zap path.
Ex_6 Simple do while loop: identical to 100 5.6
Ex_7 Spot light example with do-while loop
Ex_8 Zap Game: Hero zap path with do/while loop.
Ex_9 Simple for loop: identical to 100 5.3
Ex_10 Zap Game: Hero zap path with for loop.
Ex_11 For loop with increment != 1 5.3, 4.9
Ex_12 Zap Game: for loop with position as iterator.
Ex_13 Spotlight example with for 5.3, 4.9
Ex_14 Count backward 5.3, 4.9
Ex_15 Zap Game: Count backward from target to hero.
Ex_16 Zap Game: Count backward with while loop from target to hero.
Ex_17 Zap Game: Compound condition in while loop termination for enemy zip path.
Ex_18 Nested for loops: pattern over 2D space --
Ex_19 Zap Game: Nested for loops - Hero zap path warps around BlockA.
Ex_20 Nesting while inside a for loop --
Ex_21 Zap Game: nesting for/while loops for hero zap path wrappings.
Topic 6: Arrays Chap 8
Ex_1 Simple array of integers 8.1, 8.2 (overview);8.3
Ex_2 Simple loop through an array 8.4
Ex_3 Example of loop through an array: array of soccer balls 8.4
Ex_4 Spotlight example of array and loop: Pong Soccer with blocks in arrays 8.4
Ex_5 Linear searching through array
Ex_6 Example of linear searching of arrays: Pong soccer with proper while linear search
Ex_7 Parallel arrays: example, for each block, remember a hit-count
Ex_8 Processing array elements (sum): sum, average, largest, smallest 8.4
Ex_9 Copy array and passing array to function 8.7, 8.8
Ex_10 Spotlight example: pong soccer with stats
Topic 7: Objects and Classes Chap 8-10
Ex_1 Simple object: instance variables and interface methods
Ex_2 Object constructor with parameters
Ex_3 Always moving the soccer
Ex_4 Spot light example: design a class and interaction of objects
Ex_5 Multiple instances of a class
Ex_6 Inheritance: Base class
Ex_7 Derived class: Block and Paddle
Ex_8 SoccerBall as a derived class of circle
Ex_9 Block as a derived class of rectangle.
Ex_10 Special breakable blocks
Ex_11 Array of objcets (normal and breakable blocks)
Ex_12 End game: improved Pong Soccer game

Project home page: The Game-Themed Introductory Programming Project.
Kelvin Sung
Computing and Software Systems
University of Washington, Bothell
ksung@u.washington.edu
Michael Panitz
Business And Information Technology
Cascadia Community College
mpanitz@cascadia.eduu

Microsoft Logo This work is supported in part by a grant from Microsoft Research under the Computer Gaming Curriculum in Computer Science RFP, Award Number 15871 and 16531.
2/8/2010