Presentation is loading. Please wait.

Presentation is loading. Please wait.

Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming.

Similar presentations


Presentation on theme: "Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming."— Presentation transcript:

1 Rob Miles

2 How does an XNA game program work?

3 Programs tell computers what to do A program is written in a programming language – C# is a programming language XNA is a framework that provides program resources for writing games Programs describe Data and the Actions that are performed on it

4 Computer Games and Programs A Computer Game is a program that plays a game with us All computer game programs work in the same way – Load all the pictures, sounds and models Update the game world Draw the game world Repeat as fast as possible This is true whether the game is GTA IV, Pac Man or The Sims

5 The Anatomy of Program A program contains two things A description of the Data it works with – Like a list of ingredients for a recipe for a cake A description of the actions that the program should perform on the data – Like the steps to perform to make the cake Data Actions

6 The Anatomy of an XNA Game In an XNA program the data describes the “game world” The actions describe how to update and draw the world – Update moves items around, detects collisions etc – Draw produces a view of the world for the player to see Game Data Update action Draw action Other actions...

7 Computer Games and XNA The Update and Draw behaviours in an XNA game are expressed as methods When you make a new game XNA creates a template game file with empty Draw and Update methods for you to fill in

8 Here is an empty XNA game with no graphics This is the starting point for every game It just draws a blue screen Empty Game

9 Performing Actions in Programs A C# statement is a single step in a program – Like an action in a recipe : “Turn on oven” – Each statement is separated from the next by a semi-colon A C# method is a number of statements in a block which have been given a name – Like an entire set of steps: “Boil the kettle”

10 The XNA Draw method A method is a block of C# with a particular name Draw The Draw method draws the game display Above is the method you get with a new game The most important part has been shaded protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here base.Draw(gameTime); } protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // TODO: Add your drawing code here base.Draw(gameTime); }

11 How Clear Works graphics.GraphicsDevice.Clear(Color.CornflowerBlue); The graphics device manager The graphics device itself The Clear method The Colour value to use, in this case it is a kind of blue

12 Making Sense of a Method Call backBedroom.SatelliteTV.SwitchChannel(Channel.BBC); Something that holds items The item we want to use The instruction we want obeyed Information for the instruction

13 A Different Colour graphics.GraphicsDevice.Clear(Color.Red); The graphics device manager The graphics device itself The Clear method The Color value to use, in this case it is red

14 We can modify the call of Clear in the Draw method It is told the colour to clear the screen We can change that colour Yellow Screen

15 A program contains data and actions Two of the actions in an XNA game program are the ones that Update the game and Draw the screen An “empty” XNA game contains a Draw method that draws a blue screen using a Clear method We can change the colour of the screen by changing the information sent into the Clear method

16 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

17 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

18 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

19 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

20 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

21 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal

22 XNA games do not use data A method is a block of code with a name Your program must call the Draw method The C# language contains the Clear method The Clear method is told the colour to clear the screen There is a colour called Teal


Download ppt "Rob Miles. How does an XNA game program work? Programs tell computers what to do A program is written in a programming language – C# is a programming."

Similar presentations


Ads by Google