Learning C# by Programming Games

Learning C# by Programming Games

Arjan Egges

Language: English

Pages: 443

ISBN: 3642365795

Format: PDF / Kindle (mobi) / ePub


C# is the language of choice for learning how to program. It is a very well structured object-oriented language and avoids some of the problems of Java.  An excellent free programming environment is available for C#, as well as a game programming framework. And (if necessary) moving from C# to C++ is easy.

Developing computer games is a perfect way to learn how to program in modern programming languages. This book teaches how to program in C# through the creation of computer games – and without requiring any previous programming experience.

Contrary to most programming books, Egges, Fokker and Overmars do not organize the presentation according to programming language constructs, but instead use the structure and elements of computer games as a framework. For instance, there are chapters on dealing with player input, game objects, game worlds, game states, levels, animation, physics, and intelligence. The reader will be guided through the development of four games showing the various aspects of game development. Starting with a simple shooting game, the authors move on to puzzle games consisting of multiple levels, and conclude the book by developing a full-fledged platform game with animation, game physics, and intelligent enemies. They show a number of commonly used techniques in games, such as drawing layers of sprites, rotating, scaling and animating sprites, showing a heads-up display, dealing with physics, handling interaction between game objects, and creating pleasing visual effects such as snow or glitter. At the same time, they provide a thorough introduction to C# and object-oriented programming, introducing step by step important aspects of programming in general, including many  programming constructs and idioms, syntax diagrams, collections, and exception handling.

The book is also designed to be used as a basis for a game-oriented programming course. For each part, there are concluding exercises and challenges, which are generally more complex programming endeavors. Lots of supplementary materials for organizing such a course are available on the accompanying web site http://www.csharpprogramminggames.com, including installation instructions, solutions to the exercises, software installation instructions, game sprites and sounds.

C++ Application Development with Code::Blocks

Writing Efficient Programs

C - A Software Engineering Approach (3rd Edition)

OpenGL SuperBible: Comprehensive Tutorial and Reference (6th Edition)

Scala Design Patterns: Patterns for Practical Reuse and Design

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

framework that we will use for the Tick Tick game. We will build the game upon the library that we have developed and used in the Penguin Pairs game. This means that we already have a basic design for handling game states and settings, a hierarchy of game objects and more. We also show in this chapter how to distribute the code of a complex class with many methods over several files (using partial classes). Furthermore, we discuss exceptions in this chapter and we show how they can be used to

(c)Because the program still contains an error, nothing is drawn on the screen. What error is this, and how can it be corrected? (d)The programmer has duplicated quite some code with copy and paste. Why is that not a good idea? (e)How could this code copying have been avoided? (f)We would like to continue improving the object-oriented approach of this program, so that also the ‘wheel’ and ‘trailer’ concepts are modeled with classes. How can that be done properly? Make sure that code

Different Kinds of Methods We also see in the headers of both the Update and the Draw methods that there is a difference with respect to the Main method. Look at the Draw method for example: protected override void Draw ( GameTime gameTime ) There are some words: protected, override and void, then the name of the method (Draw) and then some stuff between parentheses. Not all of this is relevant for now, but the three words before the name of the method give some information about what kind of

the expression Color.Olive is placed inside the parentheses of the Clear method, this information is passed as a parameter to that method. So now, the Clear method knows that it needs to set the background color to olive and it can do its job. Next to creating the graphics device, there is also another line of code in the BasicGame method: Content . RootDirectory = " Content " ; This instruction indicates where our game program can find sounds, images or other assets that are used in the

Content " ; and Content . RootDirectory = " C o n t e n t " ; But apart from this, extra spaces are allowed everywhere. Good places to put extra whitespace are: behind every comma and semicolon (but not before), left and right of the equals sign (=), you can see an example of this in the instruction Content.RootDirectory = "Content";, at the beginning of lines, so that the bodies of methods and classes are indented (usually four positions) with respect to the braces enclosing the body.

Download sample

Download

About admin