XNA Game-Themed CS1 Examples (XGC1)

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

XGC1: Example to Textbooks Mapping

Example to Textbook Mappings


References are made to the following text books. Format for the references: Section/Page/Example. For example, "2.1/41/2.3", refers to Section 2.1, on Page 41, and Example 2.3. Here are individual textbook links.
ID Topics PLD C# FP C# HTP
Topic 1: Working with XNACS1Lib None
None
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
Chap 3
Chap 3
Ex_1
  • Displaying screen output
  • Sequence structures
  • Strings and string literal
2.2/35/2.1
3.2//(1)
3.2//
Ex_2 Simple input and output 2.2/41/2.4
3.3//(2)
3.6//
Ex_3
  • Local variable
  • Variable assignment
  • Displaying multiple items in a statement
2.3/43/2.5
2.3/44/2.6
3.3//
3.6//
Ex_4 Instance variable //
4.2//
8.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 2.3/46/2.7
4.10//
4.9//
Ex_10 Integer and floating point subtraction //
//
//
Ex_11 Multiplication and percentage 2.3/47/2.8
3.8, 5.7//
4.9, 3.5//
Ex_12 Division and average 2.3/51/2.9
3.8//
//
Ex_13 Evaluation of simple formula 2.3/54/2.10
3.8//
//
Ex_14 Constants 2.4/66/2.13
8.4 (arrays; 9.11 (OOP-readonly, not const)//
7.4.1 (arrays);8.12 (OOP)//
Topic 3: Modules and Functions Chap 3+6(3)
Chap 4
Chap 6
Ex_1 Simple function call, simple print, introduce texture. 3.2/79/3.1
4.2 (Overview)//
6.1, 6.2 (Overview)//
Ex_2 Simple function call with return value, RandomFloat and RandomInt functions //
4.5//
6.5//
Ex_3 Functions accessing instance variables: naming convention for instance variables (with m_) initialize circle. 3.2/85/3.2
4.5//
6.5//
Ex_4 Functions with local variable store circle y-Pos to local, use it to compute new radius 3.3/89/3.3
4.5//
6.5//
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/3.4
3.4/92/3.5
3.4/94/3.6
4.4//
6.5//
Ex_8 Spotlight example on passing parameter, take a second look at 2000.700 (formula). 3.4/97/3.7
4.4//
6.5//
Ex_9 Passing by value and by ref. 3.4/98/3.8
3.4/99/3.9
7.14//
6.8//
Ex_10 Math library functions 6.4/240-245/6.9-6.12
7.3//
6.3//
Topic 4: Decision Structures Chap 4
Chap 5
Chap 4
Ex_1 Simple ball and two paddles: ball travels to infinity and paddle are controlled by left/right thumbsticks. //
5.2 (overview)//
4.1, 4.4 (overview)//
Ex_2 Simple floating point comparison: check ball position to re-start it. 4.1/123/4.1
5.3//
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.2/127/4.2
5.4//
4.6//
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
5.4//
4.6//
Ex_7 Multiple nested conditional:
  • check the world boundary by number testing.
  • keep track of numBalls generated.
4.4/139/4.6
5.4//
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
6.6//
5.4//
Ex_10 AND logical operator: winning condition 4.6/151/4.8
6.8//
5.8//
Ex_11 OR logical operator: left and right paddle same action. 4.6/152/4.9
6.8//
5.8//
Ex_12 Combine all of the above. //
//
//
Topic 5: Repetition Structures Chap 5
Chap 5, 6
Chap 4, 5
Ex_1 Zap Game: Empty game (template). //
//
//
Ex_2 Simple while loop: draw a series of balls 5.2/166/5.1
5.5, 5.6//
4.7, 4.8//
Ex_3 Spot light example with while loop: plot sine/cosine with the interactive control 5.2/170/5.2
6.2 (counting loop)//
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. 5.2/172/5.4
//
//
Ex_6 Simple do while loop: identical to 100 5.2/176/5.5
6.5//
5.6//
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
6.3//
5.3//
Ex_10 Zap Game: Hero zap path with for loop. //
//
//
Ex_11 For loop with increment != 1 5.3/191/5.10
6.3, 6.4//
5.3, 4.9//
Ex_12 Zap Game: for loop with position as iterator. //
//
//
Ex_13 Spotlight example with for 5.3/192/5.11
6.3, 6.4//
5.3, 4.9//
Ex_14 Count backward 5.3/194/5.12
6.3, 6.4//
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. 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
Chap 7
Chap 8
Ex_1 Simple array of integers 8.1/272/8.1
7.1, 7.2, 7.3//
8.1, 8.2 (overview);8.3//
Ex_2 Simple loop through an array 8.1/274/8.2
7.4//
8.4//
Ex_3 Example of loop through an array: array of soccer balls 8.1/274/8.3
7.4//
8.4//
Ex_4 Spotlight example of array and loop: Pong Soccer with blocks in arrays 8.1/276/8.4
7.4//
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
7.8.1//
//
Ex_7 Parallel arrays: example, for each block, remember a hit-count 8.4/301/8.14(4)
//
//
Ex_8 Processing array elements (sum): sum, average, largest, smallest 8.3/287/8.8
8.3/287/8.9
8.3/289/8.10
8.3/291/8.11
7.4//
8.4//
Ex_9 Copy array and passing array to function 8.3/292/8.12
7.5, 7.6//
8.7, 8.8//
Ex_10 Spotlight example: pong soccer with stats 8.3/293/8.13
//
//
Topic 7: Objects and Classes Chap 13
Chap 9-11
Chap 8-10
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) 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.
(3) Section 6.1-6.3 repeats chapter 3 and are skipped. More elaborate examples will be presented when we present working with functions.
(4) 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