Learn 2D Game Development with C#.pdf
(
7486 KB
)
Pobierz
www.it-ebooks.info
For your convenience Apress has placed some of the front
matter material after the index. Please use the Bookmarks
and Contents at a Glance links to access them.
www.it-ebooks.info
Contents at a Glance
About the Authors�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xv
About the Technical Reviewer �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xvii
Acknowledgments �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xix
Introduction �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½
xxi
■
Chapter 1: Introducing 2D Game Development in C#�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½1
■
Chapter 2: Getting to Know the MonoGame Framework �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½11
■
Chapter 3: 2D Graphics, Coordinates, and Game State �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½41
■
Chapter 4: Getting Things Moving �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½87
■
Chapter 5: Pixel-accurate collisions�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½123
■
Chapter 6: Game object states and Semiautonomous Behaviors �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½147
■
Chapter 7: Sprites, Camera, Action! �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½183
■
Chapter 8: Particle Systems �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½213
■
Chapter 9: Building Your First 2D Game �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½227
Index �½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½�½261
v
www.it-ebooks.info
Introduction
Welcome to
Learn 2D Game Development with C#.
Because you have picked up this book, you are likely interested in
creating your own games with the C# programming language. This book teaches you how to develop 2D games with
C# and MonoGame by giving you background and conceptual information so you can play, examine, and develop
2D games.
This book identifies and presents relevant concepts from software engineering, computer graphics, mathematics,
physics, and game development—all in the context of building 2D games. The projects you’ll develop in this book are
based on MonoGame, the open source implementation of of the popular XNA Framework discontinued by Microsoft.
The presentations are tightly integrated with the analysis and development of source code; you’ll spend much of the
book building gamelike concept projects that demonstrate game principles and components. By building on concepts
introduced early on, the book leads you on a journey through which you will master the basic concepts behind game
development while simultaneously gaining hands-on experience developing simple but working 2D games.
By the end of the book, you will be familiar with the implementation details of 2D games, and you should feel
competent in implementing commonly encountered 2D game behaviors using MonoGame.
Who should read this book
This book is targeted toward programmers who are familiar with basic object-oriented programming concepts and
have a basic to intermediate knowledge of an object-oriented programming language like C# or Java. For example,
if you are a student who has taken a few introductory programming courses, an experienced developer who is new to
games and graphics programming, or a self-taught programming enthusiast, you will be able to follow the concepts
and code presented in this book with little trouble. If you’re new to programming in general, it is suggested that you
first become comfortable with the C# programming language before tackling the content provided in this book.
Assumptions
You should be experienced with programming in an object-oriented programming language, such as C# or Java.
The examples in this book were created with the assumption that readers understand data encapsulation and
inheritance. In addition, you should also be familiar with basic data structures such as linked lists and dictionaries
and be comfortable working with the fundamentals of algebra and geometry, particularly linear equations and
coordinate systems.
Who should not read this book
This book is not designed to teach readers how to program, nor does it attempt to explain intricate details of C# or
MonoGame. If you have no prior experience developing software with an object-oriented `programming language,
you will probably find the examples in this book difficult to follow.
xxi
www.it-ebooks.info
■
IntroduCtIon
On the other hand, if you have an extensive background in game development for other platforms and with
other programming languages, the content here will be too basic; this is a book intended for developers without
2D game development experience.
Organization of this book
This book divides the process of building 2D games into essential topic areas: tools, graphics, special effects, math and
physics, and logic and behavior. These topics are organized into chapters. Each topic area (chapter) is then subdivided
into essential concepts; for example, concepts related to computer graphics include coordinate spaces and camera
abstraction. The book introduces each concept via a gamelike example organized as a section in a chapter. Each
has an associated step-by-step project workflow. In this way, each section in the book corresponds to a single project
or concept.
The first section begins with a simple project that you will build from scratch. Throughout the text, each
subsequent section builds upon the sections that precede it. While this makes it a bit difficult to skip around in the
book, it will give you practical experience and a solid understanding of how the different concepts relate to one
another. In addition, rather than always working with new and minimalistic projects, you gain experience with
building larger and more interesting projects.
The projects themselves start with simple concepts, such as creating objects and moving them across the screen,
but quickly move to more complex concepts, such as implementing pixel-accurate collision detection and working
with user-defined coordinate systems. In this way, while the concepts are presented in simple 2D gamelike examples,
by the end of the book, your code base for the projects will include all the essential concepts covered.
That final code base, which you will have developed incrementally over the course of the entire book, serves as a
great platform on which you can begin building your own 2D games. This is exactly what the very last chapter of the
book does, leading you from conceptualization, to design, to implementation of a not-so-simple casual 2D game.
Finding your best starting point in this book
As a reader, there are several ways for you to follow along with this book. The first and most obvious is to enter the
code into your project as you follow through each step in the book. From a learning perspective, this is probably the
most effective way to absorb the information presented; however, we understand that it may not be the most realistic,
due to the amount of code or debugging that approach may require. To help ameliorate this, each of the sections and
projects in this book has two corresponding source code folders: the starter project in a
1.Starting
folder, and the
completed project in a
2.Completed
folder. You can see an example of this structure in Figure
1.
The starter projects
allow you to follow along in the corresponding section by entering the code as you encounter it in the book, while the
completed project lets you run and see the project in its completed state.
xxii
www.it-ebooks.info
Plik z chomika:
Phoob
Inne pliki z tego folderu:
ActiveMQ in Action.pdf
(16962 KB)
Ant in Action, 2nd Edition.pdf
(19155 KB)
Asembler.podrecznik.uzytkownika.-.Stanislaw.Kruk.www!OSIOLEK!com.pdf
(5265 KB)
beginning_silverlight_4_in_c_3rd_edition.pdf
(9373 KB)
coding_interviews.pdf
(5729 KB)
Inne foldery tego chomika:
Microsoft
Rozne
Subversion
Zgłoś jeśli
naruszono regulamin