XNA Game-Themed CS1 Examples (XGC1)

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

XGC1: Mapping to C# For Programmer

Mappings of Examples to:
C# ForProgrammer


Shows mapping of examples to C# for Programmers. 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(1)
Ex_2 Simple input and output 3.3(2)
Ex_3
  • Local variable
  • Variable assignment
  • Displaying multiple items in a statement
3.3
Ex_4 Instance variable 4.2
Ex_5 Rectangle data type and drawing 4.5
Ex_6 Circle data type and instances
Ex_7 Multiple data types and instances
Ex_8 Multiple rectangles
Ex_9 Floating point addition 4.10
Ex_10 Integer and floating point subtraction
Ex_11 Multiplication and percentage 3.8, 5.7
Ex_12 Division and average 3.8
Ex_13 Evaluation of simple formula 3.8
Ex_14 Constants 8.4 (arrays; 9.11 (OOP-readonly, not const)
Topic 3: Modules and Functions Chap 4
Ex_1 Simple function call, simple print, introduce texture. 4.2 (Overview)
Ex_2 Simple function call with return value, RandomFloat and RandomInt functions 4.5
Ex_3 Functions accessing instance variables: naming convention for instance variables (with m_) initialize circle. 4.5
Ex_4 Functions with local variable store circle y-Pos to local, use it to compute new radius 4.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. 4.4
Ex_8 Spotlight example on passing parameter, take a second look at 2000.700 (formula). 4.4
Ex_9 Passing by value and by ref. 7.14
Ex_10 Math library functions 7.3
Topic 4: Decision Structures Chap 5
Ex_1 Simple ball and two paddles: ball travels to infinity and paddle are controlled by left/right thumbsticks. 5.2 (overview)
Ex_2 Simple floating point comparison: check ball position to re-start it. 5.3
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. 5.4
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. 5.4
Ex_7 Multiple nested conditional:
  • check the world boundary by number testing.
  • keep track of numBalls generated.
5.4
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. 6.6
Ex_10 AND logical operator: winning condition 6.8
Ex_11 OR logical operator: left and right paddle same action. 6.8
Ex_12 Combine all of the above.
Topic 5: Repetition Structures Chap 5, 6
Ex_1 Zap Game: Empty game (template).
Ex_2 Simple while loop: draw a series of balls 5.5, 5.6
Ex_3 Spot light example with while loop: plot sine/cosine with the interactive control 6.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 6.5
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 6.3
Ex_10 Zap Game: Hero zap path with for loop.
Ex_11 For loop with increment != 1 6.3, 6.4
Ex_12 Zap Game: for loop with position as iterator.
Ex_13 Spotlight example with for 6.3, 6.4
Ex_14 Count backward 6.3, 6.4
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 7
Ex_1 Simple array of integers 7.1, 7.2, 7.3
Ex_2 Simple loop through an array 7.4
Ex_3 Example of loop through an array: array of soccer balls 7.4
Ex_4 Spotlight example of array and loop: Pong Soccer with blocks in arrays 7.4
Ex_5 Linear searching through array
Ex_6 Example of linear searching of arrays: Pong soccer with proper while linear search 7.8.1
Ex_7 Parallel arrays: example, for each block, remember a hit-count
Ex_8 Processing array elements (sum): sum, average, largest, smallest 7.4
Ex_9 Copy array and passing array to function 7.5, 7.6
Ex_10 Spotlight example: pong soccer with stats
Topic 7: Objects and Classes Chap 9-11
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
(1) This is specific to C# console apps, and has a lot of syntatic detail about that.
(2) This is specific to C# console apps, and has a lot of syntatic detail about that.

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