XNA Game-Themed CS1 Examples (XGC1)

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

XGC1: Mapping to Programming Logic and Design

Mappings of Example to:
Programming Logic and Design


Shows mapping of examples to Programming Logic and Design. 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 2
Ex_1
  • Displaying screen output
  • Sequence structures
  • Strings and string literal
2.2 35 2.1
Ex_2 Simple input and output 2.2 41 2.4
Ex_3
  • Local variable
  • Variable assignment
  • Displaying multiple items in a statement
2.3 43, 44 2.5, 2.6
Ex_4 Instance variable
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 2.3 46 2.7
Ex_10 Integer and floating point subtraction
Ex_11 Multiplication and percentage 2.3 47 2.8
Ex_12 Division and average 2.3 51 2.9
Ex_13 Evaluation of simple formula 2.3 54 2.10
Ex_14 Constants 2.4 66 2.13
Topic 3: Modules and Functions Chap 3+6(1)
Ex_1 Simple function call, simple print, introduce texture. 3.2 79 3.1
Ex_2 Simple function call with return value, RandomFloat and RandomInt functions
Ex_3 Functions accessing instance variables: naming convention for instance variables (with m_) initialize circle. 3.2 85 3.2
Ex_4 Functions with local variable store circle y-Pos to local, use it to compute new radius 3.3 89 3.3
Ex_5 Functions as steps in an algorithm 3.2 85 3.2
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. 3.4 91, 92, 94 3.4, 3.5, 3.6
Ex_8 Spotlight example on passing parameter, take a second look at 2000.700 (formula). 3.4 97 3.7
Ex_9 Passing by value and by ref. 3.4 98, 99 3.8, 3.9
Ex_10 Math library functions 6.4 240-245 6.9-6.12
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.
Ex_2 Simple floating point comparison: check ball position to re-start it. 4.1 123 4.1
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.2 127 4.2
Ex_5 String equality comparison: store skillLevel as a string, compare to play the victory cue. 4.3 131 4.3
Ex_6 Paddle: if left fails then test for right. World: if top fails then bottom, etc. 4.4 136 4.5
Ex_7 Multiple nested conditional:
  • check the world boundary by number testing.
  • keep track of numBalls generated.
4.4 139 4.6
Ex_8 Multiple nested conditional: collision with 3 blocks in the middle. 4.4 139 4.6
Ex_9 Case statement: testing with the boundary of the world by function call. 4.4 145 4.7
Ex_10 AND logical operator: winning condition 4.6 151 4.8
Ex_11 OR logical operator: left and right paddle same action. 4.6 152 4.9
Ex_12 Combine all of the above.
Topic 5: Repetition Structures Chap 5
Ex_1 Zap Game: Empty game (template).
Ex_2 Simple while loop: draw a series of balls 5.2 166 5.1
Ex_3 Spot light example with while loop: plot sine/cosine with the interactive control 5.2 170 5.2
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. 5.2 172 5.4
Ex_6 Simple do while loop: identical to 100 5.2 176 5.5
Ex_7 Spot light example with do-while loop 5.2 178 5.6
Ex_8 Zap Game: Hero zap path with do/while loop.
Ex_9 Simple for loop: identical to 100 5.3 186 5.8
Ex_10 Zap Game: Hero zap path with for loop.
Ex_11 For loop with increment != 1 5.3 191 5.10
Ex_12 Zap Game: for loop with position as iterator.
Ex_13 Spotlight example with for 5.3 192 5.11
Ex_14 Count backward 5.3 194 5.12
Ex_15 Zap Game: Count backward from target to hero.
Ex_16 Zap Game: Count backward with while loop from target to hero. 5.3 199 5.17
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 272 8.1
Ex_2 Simple loop through an array 8.1 274 8.2
Ex_3 Example of loop through an array: array of soccer balls 8.1 274 8.3
Ex_4 Spotlight example of array and loop: Pong Soccer with blocks in arrays 8.1 276 8.4
Ex_5 Linear searching through array 8.2 282 8.5
Ex_6 Example of linear searching of arrays: Pong soccer with proper while linear search 8.2 285 8.7
Ex_7 Parallel arrays: example, for each block, remember a hit-count 8.4(2) 301 8.14
Ex_8 Processing array elements (sum): sum, average, largest, smallest 8.3 287, 287, 289, 291 8.8, 8.9, 8.10, 8.11
Ex_9 Copy array and passing array to function 8.3 292 8.12
Ex_10 Spotlight example: pong soccer with stats 8.3 293 8.13
Topic 7: Objects and Classes Chap 13
Ex_1 Simple object: instance variables and interface methods 13.2 488 13.1
Ex_2 Object constructor with parameters 13.2 492 13.2
Ex_3 Always moving the soccer
Ex_4 Spot light example: design a class and interaction of objects 13.4 497
Ex_5 Multiple instances of a class
Ex_6 Inheritance: Base class 13.5 510 13.4
Ex_7 Derived class: Block and Paddle 13.5 513 13.5
Ex_8 SoccerBall as a derived class of circle 13.6 518 13.6
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) Section 6.1-6.3 repeats chapter 3 and are skipped. More elaborate examples will be presented when we present working with functions.
(2) Out of sequence

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