A Gamer's Introduction to Programming in C#: Welcome Brave Adventurer!

A Gamer's Introduction to Programming in C#: Welcome Brave Adventurer!

A Gamer's Introduction to Programming in C#: Welcome Brave Adventurer!
Автор: Langille Aaron
Дата выхода: 2025
Издательство: CRC Press is an imprint of Taylor & Francis Group, LLC
Количество страниц: 343
Размер файла: 3,1 МБ
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Cover....-1

Half Title....2

Title Page....4

Copyright Page....5

Dedication....6

Contents....8

Acknowledgements....14

1. Cutscene 1: Backstory....16

Press Start to Begin....16

Why These Books?....16

Visual Studio, the Console, and MonoGame....18

Books That Are Like Games....20

How to Use These Books (for Instructors and Everyone Else)....21

What Is Not Covered in These Books....23

What About AI That Writes Code?....23

Introducing Your Coding Journey Companions....24

A Brief Pep Talk....27

2. Level 1: Prepare for Adventure....28

Video Games Are Software That Use Hardware....28

Software vs. Hardware....29

Common Computer Hardware Components....29

CPU or Central Processing Unit....29

RAM or Random Access Memory....30

Hard Drive Storage....30

Input and Output Devices....31

GPU or Graphics Processing Unit....31

Software Tools for Our Adventure....32

How We Program - Write-Compile-Run (and Debug)....34

Write....34

Compile....34

Run (Finally!)....38

Side Quests....40

Want to Know More?....40

Want to Do More?....41

3. Code Quest 1: Hello, World!....42

Main Quest: Hello, World!....42

Creating a New Console Project in Visual Studio....43

Compiling and Running a Console Project in Visual Studio....46

Your Own Hello!....48

Side Quests....49

4. Level 2: Adventure Begins....50

Video Games Show Us Things....50

Displaying to the Console....51

Built-In Data Types....54

Frequently Used C Built-in Data Types (and Some Special Case Ones)....55

Data Literals....57

Revisiting Output - Now with Concatenation!....59

Revisiting "Hello, World!" - Basic Console Program Structure....62

namespace CodeQuest1....62

internal class Program....63

static void Main(string[] args)....63

Curly Braces { }....64

Revisiting Top-Level Statements....64

Side Quests....65

Want to Know More?....65

Want to Do More?....66

5. Code Quest 2: Great Game Quotes....68

Main Quest - Great Game Quotes....68

Side Quests....69

6. Level 3: A Variable Inventory of Items....70

Video Games Use Dynamic Data and Information....70

The What and Why of Variables?....71

Declaring Variables....73

Assigning and Accessing Variables....75

Reassigning Variables....79

Common Assignment and Reassignment Errors....80

Initialization Declaration Assignment....82

Naming Your Variables....84

Rules....84

Conventions....84

Side Quests....85

Want to Know More?....85

Want to Do More?....86

7. Code Quest 3: Character Builder (Part 1)....87

Main Quest - Character Builder (Part 1)....87

Side Quests....88

8. Level 4: Some Friendly Input....89

Video Games Use Input....89

Getting Console Input from Our Player....90

Steps to Collect User Input....91

Inputting Numbers and Other Fun Things....93

Parsing Can Be Tricky....95

Don't Know, Don't Care - The True Power of Variables Input....96

Comments (They Matter)....97

Side Quests....101

Want to Know More?....101

Want to Do More?....101

Code Reward - The Player Introduction....101

9. Code Quest 4: Character Builder (Part 2)....105

Main Quest - Character Builder (Part 2)....105

Side Quests....107

10. Cutscene 2: Recipes for Success....108

Video Games Are Made of Algorithms....108

Algorithms Are Recipes for Code....109

Collecting Player Name (from the Player)....110

Updating the High Score in a Video Game....110

The Properties of Algorithms....111

Algorithmic Problem Solving....112

Side Quests....113

Want to Know More?....113

Want to Do More?....113

11. Level 5: Divide and Conquer....114

Video Games Use Math....114

Common Built-in Math Operators....115

Order of Operations and ()....119

Unary Negation....121

Updating Variables....122

Compound Assignment Operators....124

Increment and Decrement ( and --)....125

Revisiting Concatenation, Addition, and Automatic Conversion....127

Math Functions....129

Side Quests....130

Want to Know More?....130

Want to Do More?....131

Code Reward - The Amazingly Silly Score Calculator....131

12. Code Quest 5: Tiny Tournament Stats....134

Main Quest - Tiny Tournament Stats....134

Side Quests....136

13. Level 6: A Random Opportunity....137

Video Games Use Random Numbers....137

Setting Up a Random Number Generator....138

Generating Random Integers....139

Simulating Dice....142

Generating Random Decimals and Casting....143

Side Quests....146

Want to Know More?....146

Want to Do More?....146

Code Reward - The Higher Roll....147

14. Code Quest 6: A Random Encounter (Part 1)....149

Main Quest - A Random Encounter (Part 1)....149

Side Quests....151

15. Level 7: A Fork in the Road....152

Video Games Use Simple Decisions....152

Conditional Execution....153

Simple Ifs (or Nothing but the Truth)....156

Else Handles the False Case....159

Comparison Operators....162

Comparing Strings and Characters....163

Introducing Logic Errors....165

A Few Last Words on Simple Ifs....167

Side Quests....169

Want to Know More?....169

Want to Do More?....170

Code Reward - A Simple Encounter....170

16. Code Quest 7: A Random Encounter (Part 2)....174

Main Quest - A Random Encounter (Part 2)....174

Side Quests....176

17. Level 8: Decisions, Decisions....177

Video Games Use "Complex" Decisions....177

If-Else-If (More than Two Paths)....178

Things to Think About with If-Else-If....183

Nested Ifs....184

Strict Decisions with && (and)....186

Relaxed Decisions with (Or)....190

Multiple Decisions with && and (Together)....195

The Not Operator (!)....196

Side Quests....197

Want to Know More?....197

Want to Do More?....197

Code Reward - A Professional Choice....198

18. Code Quest 8: My First Loot Box (Part 1)....201

Main Quest - My First Loot Box (Part 1)....202

Side Quests....203

19. Level 9: Here We Go Again, and Again....204

Video Games Do the Same Things Over and Over....204

While Loops Are Ifs That Repeat....205

Some While Loops Count....207

Some While Loops Don't Count....210

Boolean Flags Can Help with Some While Loops....211

&& (and) and (or) Work for Loops....213

For Loops Are Compact Counting Loops....214

Before, During, and After Loops....217

Nested Loops....218

Infinite Loops....220

Loops That Never Run....220

Side Quests....221

Want to Know More?....221

Want to Do More?....221

Code Reward - A More Possible Guessing Game....222

20. Code Quest 9: My First Loot Box (Part 2)....225

Main Quest - My First Loot Box (Part 2)....226

Side Quests....228

21. Cutscene 3: Yikes, Gremlins!....229

Video Games Have Errors....229

Bugs, Glitches, and Gremlins. Oh My!....229

Kinds of Errors....230

Reduce Code....231

Test, Then Test Again....233

Tracer (or Debug) Code....235

A Bit of Style Goes a Long Way....238

Stay Calm, Errors Happen....239

Side Quests....241

Want to Know More?....241

Note....242

22. Level 10: Crafting Custom Objects....243

Games Are Made of Objects (Part 1)....243

Why Object-Oriented Programming?....244

A Change in Thinking - Object-Oriented Programming....245

My Approach to Teaching and Learning OOP....247

Creating a New Object Class for Our Project....248

Attributes - The Heart of Our Objects....251

Constructors - Setting the Default Attribute Values....255

GetterAccessor Methods - Retrieving Attribute Values....260

SetterMutator Methods - Changing Attribute Values....263

Object Helper Methods....266

Full-Object Classes from This Level....267

Side Quests....269

Want to Know More?....269

Want to Do More?....270

Code Reward - An Objectively Better Loot Box....270

23. Code Quest 10: A Companion for Our Hero (Part 1)....274

Main Quest - A Companion for Our Hero (Part 1)....274

Side Quests....275

24. Level 11: A Factory for Our Objects....277

Games Are Made of Objects (Part 2)....277

An Object Class Isn't an Object....278

The Lifecycle of Objects....279

Don't Panic - You've Done This Before....280

Back to Our Regular Program.cs....281

Creating Objects with Constructors....282

Accessing or Getting Object Properties by Calling....288

Mutating or Setting Object Properties....290

Side Quests....293

Want to Know More?....293

Want to Do More?....293

Code Reward - An Epic Battle....293

25. Code Quest 11: A Companion for Our Hero (Part 2)....299

Main Quest - A Companion for Our Hero (Part 2)....299

Side Quests....301

26. Cutscene 4: The Adventure Ends ... Or Does It?....302

Game Over!....302

Actually, the Adventure Is Just Beginning?....303

What's Left in This Book?....303

A Fond Farewell....304

27. Bonus Code Quest: Cornflower Blue! (MonoGame Sneak Peek)....305

Main Quest: Cornflower Blue! (MonoGame Sneak Peek)....305

Creating a New MonoGame Project in Visual Studio....305

Compiling and Running a MonoGame Project in Visual Studio....307

A More Fiery Start....308

Side Quests....308

28. Bonus Level 1: A Bit about Binary....309

Storing Data in Bits....309

Different Bits for Different Data Types....311

Bits & Bytes (and Kilos, Megas, Gigas ...)....312

29. Bonus Level 2: A Slight Miscalculation....314

Overflow....314

Decimal Errors....315

Integer Division and Integer Remainder....317

Casting Revisited - Converting from One Type to Another....319

30. Bonus Level 3: Input Made (A Little Bit) Friendlier....323

TryParse() - Dealing with Unparsable Input....323

TryParse() and Input Validation....325

ToLower() Makes String Input (A Bit) Less Sensitive....326

31. Bonus Level 4: The Return of Decisions, Decisions....329

The Bare Truth....329

Switching Things Up with Switch Statements....331

32. Bonus Level 5: A Matter of Scope....334

Curly Braces { } Define Variable Scope....334

33. Bonus Level 6: Let's Take This Online....338

WelcomeBraveAdventurer.ca....338

Example Code and Visual Studio Projects....338

Index....340

Turn your love of video games into a new love of programming by learning the ins and outs of writing code while also learning how to keep track of high scores, what video game heroes and loot boxes are made of, how the dreaded RNG (random number generation) works, and much, much more. This book is the first in an ongoing series designed to take readers from no coding knowledge to writing their own video games and interactive digital experiences using industry standard languages and tools.

But coding books are technical, boring, and scary, aren’t they? Not this one. Within these pages, readers will find a fun and approachable adventure that will introduce them to the essential programming fundamentals like variables, computer-based math operations, RNG, logic structures, including if-statements and loops, and even some object-oriented programming. Using Visual Studio and C#, readers will write simple but fun console programs and text-based games that will build coding skills and confidence.

Packed with practical examples and plain-language explanations, this book is structured like a video game, complete with levels to progress through, bonus levels for extra practice, cutscenes that offer info-packed coding breaks, and end-of-level code rewards to illustrate how everything fits together. Gain even more experience by exploring the resources and bonus materials at the companion website: https://welcomebraveadventurer.ca. Engaging and concise, this book is appealing to both a general readership as well as course convenors and students of programming.

Put on your cap of +5 courage and level up by joining the coding adventure that awaits you inside!


Похожее:

Список отзывов:

Нет отзывов к книге.