Programming Games With Visual C# Express 

Table of Contents

 

1. Building Projects Using Visual C# Express

Preview 1-1
Introducing Programming Games With Visual C# Express 1-2
Requirements for Programming Games With Visual C# Express 1-3
Introducing Visual C# Express 1-4
Structure of a Visual C# Express Project 1-6
Steps in Developing a Visual C# Express Project 1-8
Starting Visual C# Express 1-9
Visual C# Express Integrated Development Environment (IDE) 1-10
Drawing the User Interface 1-19
Setting Properties of Controls at Design Time 1-22
Setting Properties at Run Time 1-27
How Names are Used in Control Events 1-28
Use of the Form Name Property 1-29
Writing Code 1-31
Saving a Visual C# Express Project 1-40
Running a Visual C# Express Project 1-42
Chapter Review 1-44

2. Overview of Visual C# Express Objects

Review and Preview 2-1
Form Object 2-2
Button Control 2-5
Label Control 2-7
TextBox Control 2-9
CheckBox Control 2-12
RadioButton Control 2-14
GroupBox Control 2-16
Panel Control 2-19
ListBox Control 2-21
PictureBox Control 2-23
ProgressBar Control 2-30
Timer Control 2-32
Random Number Object 2-34
SoundPlayer Object 2-36
Chapter Review 2-38

3. Overview of Visual C# Express Programming

Review and Preview 3-1
A Brief History of C# 3-2
Rules of C# Programming 3-3
Variables 3-4
Visual C# Express Data Types 3-5
Variable Declaration 3-7
Arrays 3-10
Constants 3-11
Variable Initialization 3-12
Intellisense Feature 3-13
Visual C# Express Statements and Expressions 3-14
Type Casting 3-16
Visual C# Express Arithmetic Operators 3-18
Comparison and Logical Operators 3-20
Concatenation Operators 3-22
String Functions 3-23
Math Functions 3-28
Visual C# Express Decisions – If Statements 3-30
Switch – Another Way to Branch 3-35
Visual C# Express Looping 3-38
Visual C# Express Counting 3-41
Chapter Review 3-43

4. Debugging a Visual C# Express Project

Review and Preview 4-1
Errors in Visual C# Express Projects 4-2
Debugging Visual C# Express Projects 4-3
Opening a Visual C# Express Project 4-6
Debugging Example 4-8
Using the Debugging Tools 4-10
Writing to the Output Window 4-11
Breakpoints 4-13
Viewing Variables in the Locals Window 4-16
Viewing Variables in the Watch Window 4-18
Call Stack Window 4-19
Single Stepping (Step Into) an Application 4-20
Procedure Stepping (Step Over) 4-22
Procedure Exit (Step Out) 4-23
Debugging Strategies 4-24
Project Design Considerations 4-25
Chapter Review 4-26

5. Safecracker Project

Review and Preview 15-1
Safecracker Project Preview 15-2
Safecracker Form Design 15-10
Code Design – Initializing Stopped State1 5-18
Code Design – Stopped to Playing State 15-21
Code Design – Playing to Stopped State 15-24
Code Design – Generating Secret Combination 15-26
Handling Multiple Events in a Single Event Procedure 15-30
Code Design – Accepting Player Input 15-33
Code Design – Checking Player Input 15-38
Code Design – Adding Sounds 15-43
Safecracker Game Project Review 15-50
Safecracker Game Project Enhancements 15-51

6. Tic Tac Toe Project

Review and Preview 16-1
Tic Tac Toe Project Preview 16-2
Tic Tac Toe Form Design 16-10
Code Design – Initializing Stopped State 16-19
Code Design – Stopped to Playing State 16-22
Code Design – Playing to Stopped State 16-25
Code Design – Marking Grid 16-27
Using General Functions in Projects 16-30
Code Design – Checking for Win 16-33
Code Design – Number of Players Selection 16-40
Code Design – Random Computer Moves 16-41
Code Design – Smart Computer Moves 16-46
Code Design – Adding Sounds 16-50
Tic Tac Toe Game Project Review 16-57
Tic Tac Toe Game Project Enhancements 16-58

7. Match Game Project

Review and Preview 17-1
Match Game Project Preview 17-2
Match Game Form Design 17-10
Form Design – Photo Selection 17-23
Code Design – Initializing Stopped State 17-27
Code Design – Integer Shuffling 17-33
Code Design – Stopped to Playing to Stopped State 17-37
Code Design – Displaying Photos 17-43
Code Design – One Player, Solitaire Game 17-51
Code Design – Computer Moves 17-57
Code Design – Random Computer 17-65
Code Design – Smart Computer 17-69
Match Game Project Review 17-81
Match Game Project Improvements 17-82

8. Pizza Delivery Project

Review and Preview 18-1
Pizza Delivery Project Preview 18-2
Pizza Delivery Form Design 18-11
Adding Controls at Run-Time 18-22
Form Design – Building Delivery Grid 18-24
Code Design – Initializing Stopped State 18-28
Code Design – Clock 18-29
Code Design – Phone Orders 18-35
Code Design – Pizza Oven 18-41
Code Design – Load Car 18-53
Code Design – Move Car 18-57
Code Design – Deliveries 18-73
Multiple Form Visual C# Express Applications 18-82
Form Design – Sales Results 18-86
Code Design – Sales Results 18-95
Pizza Delivery Game Project Review 18-103
Pizza Delivery Game Project Improvements 18-104

9. Moon Landing Project

Review and Preview 19-1
Moon Landing Project Preview 19-2
Moon Landing Form Design 19-13
Code Design – Initializing Options, Clock 19-26
Code Design – Physics of Moon Landing 19-36
Remaining Work 19-45
Code Design – Landing Pad Distances 19-46
Code Design – Landing Detection 19-54
Code Design – Pilot Levels and Sounds 19-60
Graphics Methods 19-74
Graphics Object 19-75
Colors 19-78
Pen Object 1
9-80
DrawLine Method 19-81
Code Design – Trajectory Display, Suggested Path 19-82
Rectangle Structure 19-88
DrawEllipse Method 19-90
Code Design – Trajectory Display, Actual Path 19-91
DrawImage Method – Scrolling Background 19-95
Code Design – Scrolling Landscape 19-96
Sprite Animation 19-106
Code Design – Lander Animation 19-109
Code Design – Autopilot 19-117
Moon Landing Game Project Review 19-130
Moon Landing Game Project Improvements 19-131

10. Leap Frog Project

Review and Preview 20-1
Leap Frog Project Preview 20-2
Game Design – Prelude to Form Design 20-11
Leap Frog Form Design 20-14
Introduction to Object-Oriented Programming (OOP) 20-21
Code Design – Sprite Class, Properties 20-23
DrawImage Method 20-26
Brush Object 20-27
FillRectangle Method 20-28
Code Design – Sprite Class, Methods 20-29
Code Design – Road Panel 20-32
Code Design – River Panel 20-45
Code Design – Snake Panel 20-53
Code Design – Moving the Frog 20-60
Collision Detection 20-73
Code Design – Vehicle Collisions 20-76
Code Design – Snake Collisions 20-79
Code Design – Log Collisions 20-82
Code Design – Home Collisions 20-89
Code Design – Game Levels 20-103
Code Design – Scoring 20-114
Form Design – High Scores 20-121
Code Design – Displaying High Scores 20-131
Code Design – Saving High Scores 20-134
Code Design – Reading High Scores 20-138
Code Design – Adding to High Scores 20-141
Leap Frog Game Project Review 20-152
Leap Frog Game Project Enhancements 20-153