GAME:IT Advanced. C# XNA Bouncing Ball First Game Part 1

Size: px
Start display at page:

Download "GAME:IT Advanced. C# XNA Bouncing Ball First Game Part 1"

Transcription

1 GAME:IT Advanced C# XNA Bouncing Ball First Game Part 1

2 Objectives By the end of this lesson, you will have learned about and will be able to apply the following XNA Game Studio 4.0 concepts. Intro XNA Game Studio 4.0 Overview of XNA Game Concepts Review the core game methods and events Review the Bouncing Ball Code

3 XNA Game Studio XNA Game Studio is a programming environment integrated with Visual Studio that allows you to create 2D and 3D games for Xbox 360, Windows, and Windows Phone. XNA Game Studio includes the XNA Framework, which is a set of managed libraries designed for game development purposes. These libraries have been built with the Microsoft.NET Framework, which means they integrate with all versions of Visual Studio, including Visual C# Express. Some of the game development features provided by XNA Game Studio and the XNA Framework include: 2D and 3D graphics / textures Enhanced Audio / Video Playback Networking / Multi-player support Xbox Live Features Windows Phone-specific Feature Support Data Access / Storage

4 Before you begin: 1. Open MyFirstGame_Tutorial solution. 2. Confirm that you can successfully build the solution. Refer to the setup file if you have trouble building the solution. 3. Expand the projects and verify the files match the files on the right. 4. In Part 1 of the lesson we will be reviewing the core components and fundamentals that make up every XNA game. 5. In Part 2 of the lesson we will extend upon the MyFirstGame project that was previously completed or downloaded and setup as a starting point.

5 Game application entry point 1. Click and open Program.cs 2. The Program class in an XNA game project is similar to that of a console application. The Main method only performs one function, and that is to launch the game. 3. The using statement is used to instantiate an instance of Game1 and call its Run method. When the game exits, the using statement ensures it releases its resources. /// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) using (Game1 game = new Game1()) game.run();

6 XNA Game application overview 1. Click and open Game1.cs 2. By default, when you create an XNA game application, both Program.cs and Game1.cs are automatically created. 3. The Content project is also created by default and it sets up a place to store media and content files used in the game. 4. There are a number of methods in the Game1 class that will appear by default as overrides from the base class Game. Another nice feature is that the methods and events have been documented with a summary of intended purpose and function. Be sure to read this information to help you better understand the purpose and structure. 5. Starting from the top down, we will briefly review each of the following: Using Statements Inheritance Game1 Constructor Initialize LoadContent UnloadContent Update Draw UpdateSprite

7 Using Statements Game1.cs using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input.Touch; using Microsoft.Xna.Framework.Media; Note: The using statements reference the Microsoft XNA Framework libraries that the Game1 class can make use of. If you recall from previous lessons, this allows you to refer to the type names directly without having to reference the type along with the namespace in code. It keeps the code much cleaner. The libraries are added as references to the XNA game project by default. The installation of XNA game studio installs them locally on your computer and therefore allows them to be referenced from your project and in turn at the class level.

8 Inheritance Game1.cs namespace MyFirstGame /// <summary> /// This is the main type for your game /// </summary> public class Game1 : Microsoft.Xna.Framework.Game Note: Game1 inherits from Microsoft.Xna.Framework.Game, which means it takes on all the properties, methods, events and other members from this class giving Game1 the core functionality it needs to build a XNA game from. From the Program.cs class, Game1 calls the Run method, which is defined in the base type Game. The run method initializes the game, begins running the game loop, and starts processing the events for the game. Many of these events appear as overrides in the Game1 class.

9 Constructor Game1.cs GraphicsDeviceManager graphics; SpriteBatch spritebatch; public Game1() graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; Note: The Game1 constructor does not take in any parameters by default. If we had an overloaded constructor with parameters, we would need to pass those in from the Program.cs class at the time Game1 is instantiated. Above the constructor there are a couple of class level variables declared. The constructor instantiates a new GraphicsDeviceManager class passing in this, or the Game1 class as parameter of type Game. The constructor also sets the Content.RootDirectory, which refers to the MyFirstGameContent project. Clicking on MyFirstGameContent, you will notice the name Content in the properties window, which is what this refers to.

10 Initialize Game1.cs /// <summary> /// Allows the game to perform any initialization it needs to /// before starting to run. /// This is where it can query for any required services and /// load any non-graphic /// related content. Calling base.initialize will enumerate /// through any components /// and initialize them as well. /// </summary> protected override void Initialize() // TODO: Add your initialization logic here base.initialize(); Note: Initialize is called after the Game and GraphicsDevice are created, but before LoadContent. As the summary points out, you can load non-graphic content such as sound effects.

11 LoadContent Game1.cs /// <summary> /// LoadContent will be called once /// per game and is the place to load all of your content. /// </summary> protected override void LoadContent() // Create a new SpriteBatch, which can be used to draw //textures. spritebatch = new SpriteBatch(GraphicsDevice); mytexture = Content.Load<Texture2D>("mytexture"); Note: LoadContent is called when graphics resources need to be loaded. The spritebatch is instantiated here. What is a sprite? A sprite is a image or texture that is integrated into the game. A game can be made up of many sprites and a SpriteBatch simply enables a group of sprites to be drawn with the same settings. mytexture is of type Texture2D and is added to the spritebatch and drawn to the screen in the Draw method. Content.Load loads the texture from the Content project and refers to the texture by its Asset Name. You can view the Asset Name by selecting the texture and viewing the properties window.

12 UnloadContent Game1.cs /// <summary> /// UnloadContent will be called once per game and is the place /// to unload all content. /// </summary> protected override void UnloadContent() // TODO: Unload any non ContentManager content here Note: UnloadContent is called when graphics resources need to be unloaded. Override this method to unload any game-specific graphics resources. One recommendation for this method is to call the Dispose method on any resources that were initialized in the LoadContent method. If a graphics device was to reset, this method would be called to cleanup resources and free up memory and then LoadContent would be called again.

13 Update & Draw Method Summary The Update and Draw methods make up what can be described as the Game loop. These methods are called multiple times a second. The Update method is used to call game logic while the Draw method is used to draw the game. Executing at multiple times a second provides the game the ability to perform many code operations a second while moving graphics on the screen. The number of times the Draw method executes per second is known as the games FPS or frame rate per second. The Update and Draw methods can be setup as Fixed Step or Variable Step. The default is Fixed Step and is set with the Game.IsFixedTimeStep property. In Fixed Step mode, it will call Update with every Tick method specified by the interval in Game.TargetElapsedTime. In Fixed Step mode it s possible to have multiple calls to the Update method for every Draw method call on slower computers. The reason this can occur is that the computer running the game attempts to catch up to the clock s TargetElapsedTime and skips Draw in order to do so. In Variable Step mode, the game does not try to maintain the frame rate and therefore there is a one-to-one ratio between Update and Draw. The GameWindow sometimes calls Paint for certain situations, which results in the possibility of Draw being called more than Update.

14 Update Game1.cs /// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing /// audio. /// </summary> /// <param name="gametime">provides a snapshot of timing /// values.</param> protected override void Update(GameTime gametime) // Allows the game to exit if(gamepad.getstate(playerindex.one).buttons.back == ButtonState.Pressed) this.exit(); #if WINDOWS if (Keyboard.GetState().IsKeyDown(Keys.Escape)) this.exit(); #endif

15 Update Game1.cs (continued) // Move the sprite around. UpdateSprite(gameTime); base.update(gametime); Note: The MyFirstGame project does not have a lot going on in the Update method, but there are a few notable statements. There are a couple of conditional statements that deal with input from the user in order to exit the game. this.exit(); refers to the Game1 class and thus calls Exit on the base class Game. #if WINDOWS is a conditional compilation symbol that only calls the code within the statement if the game is a Windows Game. The same code is often used for Xbox, Windows, and Windows mobile games so #if XBOX and #if WINDOWS_PHONE are also available. UpdateSprite is a local method not an override from Game. This helper method is responsible for the logic that changes the position of the Sprite. The position change of the Sprite is not reflected in the game window until the Draw method is called, which is generally called right after Update.

16 Draw Game1.cs /// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gametime">provides a snapshot of timing /// values.</param> protected override void Draw(GameTime gametime) graphics.graphicsdevice.clear(color.cornflowerblue); // Draw the sprite. spritebatch.begin(spritesortmode.backtofront, BlendState.AlphaBlend); spritebatch.draw(mytexture, spriteposition, Color.White); spritebatch.end(); base.draw(gametime);

17 Draw Game1.cs (continued) Note: The Draw method is used for the game-rendering specific code. It s important that you call the base.draw method in order to enumerate through any graphics that were added to the Components collection. Remember that base refers to the base class, even though you override a method from the base class, sometimes you still want to call the base method. You will see base calls used throughout XNA development. GraphicsDevice.Clear flushes the graphics in the window and sets the background color. This method is called first in the Draw method in order to clear the window. Any new sprites will be added on top of the color specified. spritebatch.begin,.draw, and.end is used to render the Texture2D sprite to the window. The Begin method takes in sort mode and BlendState. The default color BlendState is AlphaBlend. Draw simply specifies the sprite texture, position, and color. The color is used to tint a sprite. Use Color.White for full color with no tinting.

18 UpdateSprite Game1.cs void UpdateSprite(GameTime gametime) // Move the sprite by speed, scaled by elapsed time. spriteposition += spritespeed * (float)gametime.elapsedgametime.totalseconds; Note: The UpdateSprite method is where all the logic happens to change the position of the sprite and prepares it to be redrawn in the Draw method. Both spriteposition and spritespeed are Vector2 graphics, which means they have x and y coordinates. The spriteposition adds the value of the result of the fixed spritespeed value of x=50 and y=50 multiplied by the ElapsedGameTime TotalSeconds. This represents a fraction of a second since the Update method is called several times a second, usually 60 or more on most computers. This means that the spriteposition moves a small amount every few milliseconds, which makes for a smooth moving graphic at a steady speed. Example: 50 * TotalSeconds( ) = A spriteposition of x=100, y=100 would be x= ,y= in 17 milliseconds at a 60 FPS.

19 XNA Game Window

20 Note: As the photo depicts, X is 0 at the left edge of the window and 800 at the right edge of the window. The value is in pixels. The value of Y is 0 at the top and 480 at the bottom of the window. The upper left hand corner would be X=0,Y=0 and the lower right hand corner would be X=800,Y=480. The change in value of X and Y determines the angle of movement the graphic is traveling in. This assumes a window size of 800 x 480. The window size may vary depending on the game, monitor, and settings. You can also set the size of the window with code. A graphic with a X or Y coordinate outside the range of the window will not show after a draw method. Setting negative values for X and Y is a technique that can be used to bring graphics in your game on and off the screen between draw method calls.

21 UpdateSprite Game1.cs (continued) int MaxX = graphics.graphicsdevice.viewport.width - mytexture.width; int MinX = 0; int MaxY = graphics.graphicsdevice.viewport.height - mytexture.height; int MinY = 0; // Check for bounce. if (spriteposition.x > MaxX) spritespeed.x *= -1; spriteposition.x = MaxX; else if (spriteposition.x < MinX) spritespeed.x *= -1; spriteposition.x = MinX;

22 UpdateSprite Game1.cs (continued) if (spriteposition.y > MaxY) spritespeed.y *= -1; spriteposition.y = MaxY; else if (spriteposition.y < MinY) spritespeed.y *= -1; spriteposition.y = MinY; Note: MaxX,MaxY,MinX, and MinY establish the range for the game window. The rest of the conditional logic compares the current position of x and y and if the min or max is true, it sets the position and reverses the direction by multiplying the value of spritespeed x or y by -1. Recall that spritespeed is used in calculating the spriteposition. Adding a negative value to a positive number causes the position of x or y to move towards 0. This technique causes the bounce effect and remains true to Newton s 3 rd law of motion.

23 Explore Concepts Learned (optional) Visit: Search for keywords in part 1 of this lesson: Xna game class, xna game update, xna game draw, xna SpriteBatch, xna Texture2D, xna graphics, etc. Visit: Explore the APP HUB for Windows, Phone, and Xbox Games.

A camera with a projection and view matrix

A camera with a projection and view matrix A camera with a projection and view matrix Drikus Kleefsman January 25, 2010 Keywords: Xna, world, projection, view, matrix Abstract The first thing you want to have in a 3d scene is a camera to look at

More information

Creating a Role Playing Game with XNA Game Studio 3.0 Part 4 Adding the Action Screen and Tile Engine

Creating a Role Playing Game with XNA Game Studio 3.0 Part 4 Adding the Action Screen and Tile Engine Creating a Role Playing Game with XNA Game Studio 3.0 Part 4 Adding the Action Screen and Tile Engine To follow along with this tutorial you will have to have read the previous tutorials to understand

More information

XNA Game Studio 4.0.

XNA Game Studio 4.0. Getting Started XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to http://www.microsoft.com/download/en/details.aspx?id=23714 XNA Game Studio 4.0 needs the Microsoft Visual Studio 2010 development

More information

Xna0118-The XNA Framework and. the Game Class

Xna0118-The XNA Framework and. the Game Class OpenStax-CNX module: m49509 1 Xna0118-The XNA Framework and * the Game Class R.G. (Dick) Baldwin This work is produced by OpenStax-CNX and licensed under the Creative Commons Attribution License 4.0 Abstract

More information

XNA (2D) Tutorial. Pong IAT410

XNA (2D) Tutorial. Pong IAT410 XNA (2D) Tutorial Pong IAT410 Creating a new project 1. From the Start Menu, click All Programs, then the Microsoft XNA Game Studio Express folder, and finally XNA Game Studio Express. 2. When the Start

More information

IWKS 3400 Lab 3 1 JK Bennett

IWKS 3400 Lab 3 1 JK Bennett IWKS 3400 Lab 3 1 JK Bennett This lab consists of four parts, each of which demonstrates an aspect of 2D game development. Each part adds functionality. You will first just put a sprite on the screen;

More information

XNA Workshop at CS&IT Symposium 7/11/11

XNA Workshop at CS&IT Symposium 7/11/11 XNA Workshop at CS&IT Symposium 7/11/11 Time 9:00 to 9:20 9:20 to 9:40 9:40 to 10:10 Mood Light 10:15 to 10:45 Manual Mood Light 10:50 to 11:20 Placing and Moving Image 11:25 to 11:45 Windows Phone Touch

More information

Compile and run the code. You should see an empty window, cleared to a dark purple color.

Compile and run the code. You should see an empty window, cleared to a dark purple color. IWKS 3400 LAB 10 1 JK Bennett This lab will introduce most of the techniques required to construct flight simulator style game. Our primary goal is to demonstrate various techniques in the MonoGame environment,

More information

Visual C# 2010 Express

Visual C# 2010 Express Review of C# and XNA What is C#? C# is an object-oriented programming language developed by Microsoft. It is developed within.net environment and designed for Common Language Infrastructure. Visual C#

More information

XNA 4.0 RPG Tutorials. Part 2. More Core Game Components

XNA 4.0 RPG Tutorials. Part 2. More Core Game Components XNA 4.0 RPG Tutorials Part 2 More Core Game Components I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of

More information

Next, we re going to specify some extra stuff related to our window such as its size and title. Add this code to the Initialize method:

Next, we re going to specify some extra stuff related to our window such as its size and title. Add this code to the Initialize method: IWKS 3400 LAB 7 1 JK Bennett This lab will introduce you to how to create terrain. We will first review some basic principles of 3D graphics, and will gradually add complexity until we have a reasonably

More information

Creating a Role Playing Game with XNA Game Studio 3.0 Part 7 Adding Sprites

Creating a Role Playing Game with XNA Game Studio 3.0 Part 7 Adding Sprites Creating a Role Playing Game with XNA Game Studio 3.0 Part 7 Adding Sprites To follow along with this tutorial you will have to have read the previous tutorials to understand much of what it going on.

More information

Unit 5 Test Review Name: Hour: Date: 1) Describe two ways we have used paint to help us as we studied images in monogame.

Unit 5 Test Review Name: Hour: Date: 1) Describe two ways we have used paint to help us as we studied images in monogame. Unit 5 Test Review Name: Hour: Date: Answer the following questions in complete sentences. 1) Describe two ways we have used paint to help us as we studied images in monogame. a) b) 2) Where do you DECLARE

More information

XNA 4.0 RPG Tutorials. Part 3. Even More Core Game Components

XNA 4.0 RPG Tutorials. Part 3. Even More Core Game Components XNA 4.0 RPG Tutorials Part 3 Even More Core Game Components I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list

More information

Slides adapted from 4week course at Cornell by Tom Roeder

Slides adapted from 4week course at Cornell by Tom Roeder Slides adapted from 4week course at Cornell by Tom Roeder Interactive Game loop Interactive Game Loop Core Mechanics Physics, AI, etc. Update() Input GamePad, mouse, keybard, other Update() Render changes

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 13. Leveling Up

A Summoner's Tale MonoGame Tutorial Series. Chapter 13. Leveling Up A Summoner's Tale MonoGame Tutorial Series Chapter 13 Leveling Up This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials will make

More information

XNA 4.0 RPG Tutorials. Part 22. Reading Data

XNA 4.0 RPG Tutorials. Part 22. Reading Data XNA 4.0 RPG Tutorials Part 22 Reading Data I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of tutorials on

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 9. Conversations Continued

A Summoner's Tale MonoGame Tutorial Series. Chapter 9. Conversations Continued A Summoner's Tale MonoGame Tutorial Series Chapter 9 Conversations Continued This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 3. Tile Engine and Game Play State

A Summoner's Tale MonoGame Tutorial Series. Chapter 3. Tile Engine and Game Play State A Summoner's Tale MonoGame Tutorial Series Chapter 3 Tile Engine and Game Play State This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The

More information

Session 5.1. Writing Text

Session 5.1. Writing Text 1 Session 5.1 Writing Text Chapter 5.1: Writing Text 2 Session Overview Show how fonts are managed in computers Discover the difference between bitmap fonts and vector fonts Find out how to create font

More information

Computer Games 2011 Selected Game Engines

Computer Games 2011 Selected Game Engines Computer Games 2011 Selected Game Engines Dr. Mathias Lux Klagenfurt University This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 libgdx features High-performance,

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 11. Battling Avatars

A Summoner's Tale MonoGame Tutorial Series. Chapter 11. Battling Avatars A Summoner's Tale MonoGame Tutorial Series Chapter 11 Battling Avatars This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials will

More information

Eyes of the Dragon - XNA Part 33 Non-Player Character Conversations

Eyes of the Dragon - XNA Part 33 Non-Player Character Conversations Eyes of the Dragon - XNA Part 33 Non-Player Character Conversations I'm writing these tutorials for the XNA 4.0 framework. Even though Microsoft has ended support for XNA it still runs on all supported

More information

XNA 4.0 RPG Tutorials. Part 5. The Tile Engine - Part 2

XNA 4.0 RPG Tutorials. Part 5. The Tile Engine - Part 2 XNA 4.0 RPG Tutorials Part 5 The Tile Engine - Part 2 I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of tutorials

More information

IWKS 3400 LAB 11 1 JK Bennett

IWKS 3400 LAB 11 1 JK Bennett IWKS 3400 LAB 11 1 JK Bennett This lab dives a little bit deeper into HLSL effects, particularly as they relate to lighting and shading. We will begin by reviewing some basic 3D principles, and then move

More information

Game1.cs class that derives (extends) Game public class Game1 : Microsoft.Xna.Framework.Game {..}

Game1.cs class that derives (extends) Game public class Game1 : Microsoft.Xna.Framework.Game {..} MonoGames MonoGames Basics 1 MonoGames descends from XNA 4, is a framework for developing C# games for Windows, Linux, Mac, Android systems. Visual Studio MonoGames projects will create: Program.cs class

More information

2D Graphics in XNA Game Studio Express (Modeling a Class in UML)

2D Graphics in XNA Game Studio Express (Modeling a Class in UML) 2D Graphics in XNA Game Studio Express (Modeling a Class in UML) Game Design Experience Professor Jim Whitehead February 5, 2008 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Announcements

More information

ICS3C/4C/3U/4U Unit 2 Workbook Selection: If Statement

ICS3C/4C/3U/4U Unit 2 Workbook Selection: If Statement Selection: If Statement Selection allows a computer to do different things based on the situation. The if statement checks if something is true and then runs the appropriate code. We will start learning

More information

msdn Hands-On Lab 3D Game Development with XNA Framework Lab version: Last updated: 12/8/2010 Page 1

msdn Hands-On Lab 3D Game Development with XNA Framework Lab version: Last updated: 12/8/2010 Page 1 msdn Hands-On Lab 3D Game Development with XNA Framework Lab version: 1.0.0 Last updated: 12/8/2010 Page 1 CONTENTS OVERVIEW... 2 EXERCISE 1: BASIC XNA GAME STUDIO GAME WITH GAME STATE MANAGEMENT... 4

More information

XNA Development: Tutorial 6

XNA Development: Tutorial 6 XNA Development: Tutorial 6 By Matthew Christian (Matt@InsideGamer.org) Code and Other Tutorials Found at http://www.insidegamer.org/xnatutorials.aspx One of the most important portions of a video game

More information

Hands-On Lab. 3D Game Development with XNA Framework. Lab version: Last updated: 2/2/2011. Page 1

Hands-On Lab. 3D Game Development with XNA Framework. Lab version: Last updated: 2/2/2011. Page 1 Hands-On Lab 3D Game Development with XNA Framework Lab version: 1.0.0 Last updated: 2/2/2011 Page 1 CONTENTS OVERVIEW... 3 EXERCISE 1: BASIC XNA GAME STUDIO GAME WITH GAME STATE MANAGEMENT... 5 Task 1

More information

Collision Detection Concept

Collision Detection Concept Collision Detection Collision Detection Concept When two fireflies collide we tag them for removal and add an explosion to the blasts list. The position and velocity of the explosion is set to the average

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 12. Battling Avatars Continued

A Summoner's Tale MonoGame Tutorial Series. Chapter 12. Battling Avatars Continued A Summoner's Tale MonoGame Tutorial Series Chapter 12 Battling Avatars Continued This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials

More information

2D Graphics in XNA Game Studio Express (Plus, Random numbers in C#)

2D Graphics in XNA Game Studio Express (Plus, Random numbers in C#) 2D Graphics in XNA Game Studio Express (Plus, Random numbers in C#) Game Design Experience Professor Jim Whitehead January 16, 2009 Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0

More information

Slides built from Carter Chapter 10

Slides built from Carter Chapter 10 Slides built from Carter Chapter 10 Animating Sprites (textures) Images from wikipedia.org Animating Sprites (textures) Images from wikipedia.org Lets Add to Our XELibrary Going to add a CelAnimationManager

More information

Hands-On Lab. 2D Game Development with XNA Framework. Lab version: Last updated: 2/2/2011. Page 1

Hands-On Lab. 2D Game Development with XNA Framework. Lab version: Last updated: 2/2/2011. Page 1 Hands-On Lab 2D Game Development with XNA Framework Lab version: 1.0.0 Last updated: 2/2/2011 Page 1 CONTENTS OVERVIEW... 3 EXERCISE 1: BASIC XNA FRAMEWORK GAME WITH GAME STATE MANAGEMENT... 4 General

More information

Session A First Game Program

Session A First Game Program 1 Session 11.1 A First Game Program Chapter 11.1: A First Game Program 2 Session Overview Begin the creation of an arcade game Learn software design techniques that apply to any form of game development

More information

XNA 4.0 RPG Tutorials. Part 16. Quests and Conversations

XNA 4.0 RPG Tutorials. Part 16. Quests and Conversations XNA 4.0 RPG Tutorials Part 16 Quests and Conversations I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of

More information

Creating a Role Playing Game with XNA Game Studio 3.0 Part 11 Creating a Textbox Control

Creating a Role Playing Game with XNA Game Studio 3.0 Part 11 Creating a Textbox Control Creating a Role Playing Game with XNA Game Studio 3.0 Part 11 Creating a Textbox Control To follow along with this tutorial you will have to have read the previous tutorials to understand much of what

More information

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C5: Dice with Texture

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C5: Dice with Texture Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C5: Dice with Texture 1 XBox 360 Controller Project dice1 The Complete Code of Game1.cs The Complete Data of dice.x Experiments Copyright by V. Miszalok,

More information

Explain the significance of using a computer programming language. Describe the basic template of the Monogame framework.

Explain the significance of using a computer programming language. Describe the basic template of the Monogame framework. I can Explain the significance of using a computer programming language. Describe the basic template of the Monogame framework. A series of steps (actions) performed in a specific order Specifies The ACTIONS

More information

Developing Games with MonoGame*

Developing Games with MonoGame* Developing Games with MonoGame* By Bruno Sonnino Developers everywhere want to develop games. And why not? Games are among the best sellers in computer history, and the fortunes involved in the game business

More information

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C3: Drunken Tiger

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C3: Drunken Tiger 1 Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C3: Drunken Tiger Copyright by V. Miszalok, last update: 10-01-2010 Project TigerRot1 Version 1: Minimum Version 2: In a Quadratic Resizable Window

More information

Windows Phone SDK 8.0 omogućuje kreiranje aplikacija za Windows Phone 8 and Windows Phone 7.5 uređaje. SDK 7.1

Windows Phone SDK 8.0 omogućuje kreiranje aplikacija za Windows Phone 8 and Windows Phone 7.5 uređaje. SDK 7.1 Igor Mirković SDK 8.0 Windows Phone SDK 8.0 omogućuje kreiranje aplikacija za Windows Phone 8 and Windows Phone 7.5 uređaje. SDK 7.1 Windows Phone SDK 7.1 i 7.1.1 omogućuju razvoj aplikacija za Windows

More information

How to Program a Primitive Twin-Stick Shooter in Monogame 3.4

How to Program a Primitive Twin-Stick Shooter in Monogame 3.4 How to Program a Primitive Twin-Stick Shooter in Monogame 3.4 This is a tutorial for making a basic twin-stick style shooter in C# using Monogame 3.4 and Microsoft Visual Studio. This guide will demonstrate

More information

Computer Games 2012 Game Development

Computer Games 2012 Game Development Computer Games 2012 Game Development Dr. Mathias Lux Klagenfurt University This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 libgdx features High-performance, cross-platform

More information

Session 5.2. Creating Clocks

Session 5.2. Creating Clocks 1 Session 5.2 Creating Clocks Chapter 5.2: Creating Clocks 2 Session Overview Find out how to obtain and use the current date and time in a C# program using the DateTime type Discover how to extract a

More information

Programs, Data, and Pretty Colors

Programs, Data, and Pretty Colors C02625228.fm Page 19 Saturday, January 19, 2008 8:36 PM Chapter 2 Programs, Data, and Pretty Colors In this chapter: Introduction...........................................................19 Making a Game

More information

DO NGHIEM AN RAPID ROLLER: A GAME FOR WINDOWS PHONE

DO NGHIEM AN RAPID ROLLER: A GAME FOR WINDOWS PHONE DO NGHIEM AN RAPID ROLLER: A GAME FOR WINDOWS PHONE Telecommunications and Technology 2012 2 VAASAN AMMATTIKORKEAKOULU UNIVERSITY OF APPLIED SCIENCES TELECOMMUNICATIONS AND TECHNOLOGY ABSTRACT Author Do

More information

CMPS 20: Game Design Experience. January 14, 2010 Arnav Jhala

CMPS 20: Game Design Experience. January 14, 2010 Arnav Jhala CMPS 20: Game Design Experience January 14, 2010 Arnav Jhala foreach ( type identifier in array-or-collection ) { } Foreach Statement Iterates through all elements in an array, or collection type Creates

More information

Bloom effect - before. Bloom effect - after. Postprocessing. Motion blur in Valve s Portal - roll

Bloom effect - before. Bloom effect - after. Postprocessing. Motion blur in Valve s Portal - roll Bloom effect - before Postprocessing Prof. Aaron Lanterman School of Electrical and Computer Engineering Georgia Institute of Technology 2 Bloom effect - after Motion blur in Valve s Portal - roll 3 http://www.valvesoftware.com/publications/2008/

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 15. Saving Game State

A Summoner's Tale MonoGame Tutorial Series. Chapter 15. Saving Game State A Summoner's Tale MonoGame Tutorial Series Chapter 15 Saving Game State This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials will

More information

Blending Equation Blend Factors & Mode Transparency Creating an Alpha Channel Using DX Tex Tool Render Semi-Transparent Objects.

Blending Equation Blend Factors & Mode Transparency Creating an Alpha Channel Using DX Tex Tool Render Semi-Transparent Objects. Overview Blending Blend Factors & Mode Transparency Creating an Alpha Channel Using DX Tex Tool Render Semi-Transparent Objects 305890 Spring 2014 5/27/2014 Kyoung Shin Park Blending Allows us to blend

More information

For efficiency, the graphics card will render objects as triangles Any polyhedron can be represented by triangles Other 3D shapes can be approximated

For efficiency, the graphics card will render objects as triangles Any polyhedron can be represented by triangles Other 3D shapes can be approximated By Chris Ewin For efficiency, the graphics card will render objects as triangles Any polyhedron can be represented by triangles Other 3D shapes can be approximated by triangles Source: Wikipedia Don t

More information

Chapter 2: Into the 2 nd Dimension

Chapter 2: Into the 2 nd Dimension Chapter 2: Into the 2 nd Dimension By Mike Fleischauer xna@return42.com Hosted at http://www.learnxna.com/pages/xnabook.aspx So, in chapter one we covered how to get the basis of your game up and running.

More information

3D Graphics with XNA Game Studio 4.0

3D Graphics with XNA Game Studio 4.0 3D Graphics with XNA Game Studio 4.0 Create attractive 3D graphics and visuals in your XNA games Sean James BIRMINGHAM - MUMBAI 3D Graphics with XNA Game Studio 4.0 Copyright 2010 Packt Publishing All

More information

Microsoft XNA and the 3DUI Framework

Microsoft XNA and the 3DUI Framework Microsoft XNA and the 3DUI Framework Lecture #3: XNA Paul Varcholik Joseph J. LaViola Jr. Introductions Paul Varcholik: pvarchol@ist.ucf.edu Technology Blog: www.bespokesoftware.org Software Visual Studio

More information

Chapter 3: The keys to control

Chapter 3: The keys to control Chapter 3: The keys to control By Mike Fleischauer xna@return42.com Hosted at http://www.learnxna.com/pages/xnabook.aspx In this chapter we are going to learn the basics of controlling our games. We cover

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 10. Creating Avatars

A Summoner's Tale MonoGame Tutorial Series. Chapter 10. Creating Avatars A Summoner's Tale MonoGame Tutorial Series Chapter 10 Creating Avatars This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials will

More information

XNA 4.0 RPG Tutorials. Part 25. Level Editor Continued

XNA 4.0 RPG Tutorials. Part 25. Level Editor Continued XNA 4.0 RPG Tutorials Part 25 Level Editor Continued I'm writing these tutorials for the new XNA 4.0 framework. The tutorials will make more sense if they are read in order. You can find the list of tutorials

More information

Game Programming with. presented by Nathan Baur

Game Programming with. presented by Nathan Baur Game Programming with presented by Nathan Baur What is libgdx? Free, open source cross-platform game library Supports Desktop, Android, HTML5, and experimental ios support available with MonoTouch license

More information

Platform Games Drawing Sprites & Detecting Collisions

Platform Games Drawing Sprites & Detecting Collisions Platform Games Drawing Sprites & Detecting Collisions Computer Games Development David Cairns Contents Drawing Sprites Collision Detection Animation Loop Introduction 1 Background Image - Parallax Scrolling

More information

Eyes of the Dragon - XNA Part 37 Map Editor Revisited

Eyes of the Dragon - XNA Part 37 Map Editor Revisited Eyes of the Dragon - XNA Part 37 Map Editor Revisited I'm writing these tutorials for the XNA 4.0 framework. Even though Microsoft has ended support for XNA it still runs on all supported operating systems

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

A Summoner's Tale MonoGame Tutorial Series. Chapter 8. Conversations

A Summoner's Tale MonoGame Tutorial Series. Chapter 8. Conversations A Summoner's Tale MonoGame Tutorial Series Chapter 8 Conversations This tutorial series is about creating a Pokemon style game with the MonoGame Framework called A Summoner's Tale. The tutorials will make

More information

Michael C. Neel. XNA 3D Primer. Wiley Publishing, Inc. Updates, source code, and Wrox technical support at

Michael C. Neel. XNA 3D Primer. Wiley Publishing, Inc. Updates, source code, and Wrox technical support at Michael C. Neel XNA 3D Primer Wiley Publishing, Inc. Updates, source code, and Wrox technical support at www.wrox.com Contents Who Is This Book For? 1 3D Overview 2 Basic 3D Math 4 Right-Hand Rule 4 Working

More information

Smoother Graphics Taking Control of Painting the Screen

Smoother Graphics Taking Control of Painting the Screen It is very likely that by now you ve tried something that made your game run rather slow. Perhaps you tried to use an image with a transparent background, or had a gazillion objects moving on the window

More information

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course : Advanced Java Concepts + Additional Questions from Earlier Parts of the Course 1. Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... In what order

More information

Chapter 6 Reacting to Player Input

Chapter 6 Reacting to Player Input Chapter 6 Reacting to Player Input 6.1 Introduction In this chapter, we will show you how your game program can react to mouse clicks and button presses. In order to do this, we need a instruction called

More information

Lab 3 Shadow Mapping. Giuseppe Maggiore

Lab 3 Shadow Mapping. Giuseppe Maggiore Lab 3 Shadow Giuseppe Maggiore Adding Shadows to the Scene First we need to declare a very useful helper object that will allow us to draw textures to the screen without creating a quad vertex buffer //

More information

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C1: Moving Triangles

Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C1: Moving Triangles Course 3D_XNA: 3D-Computer Graphics with XNA Chapter C1: Moving Triangles 1 Project triangle1 Game1, Initialize, Update, Draw Three triangles Hundred triangles Chaos Help Copyright by V. Miszalok, last

More information

Lab 1 Sample Code. Giuseppe Maggiore

Lab 1 Sample Code. Giuseppe Maggiore Lab 1 Sample Code Giuseppe Maggiore Preliminaries using Vertex = VertexPositionColor; First we define a shortcut for the type VertexPositionColor. This way we could change the type of Vertices used without

More information

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created.

+ Inheritance. Sometimes we need to create new more specialized types that are similar to types we have already created. + Inheritance + Inheritance Classes that we design in Java can be used to model some concept in our program. For example: Pokemon a = new Pokemon(); Pokemon b = new Pokemon() Sometimes we need to create

More information

the gamedesigninitiative at cornell university Lecture 16 Color and Textures

the gamedesigninitiative at cornell university Lecture 16 Color and Textures Lecture 6 Color and Textures Take Away For Today Image color and composition What is RGB model for images? What does alpha represent? How does alpha composition work? Graphics primitives How do primitives

More information

And Even More and More C++ Fundamentals of Computer Science

And Even More and More C++ Fundamentals of Computer Science And Even More and More C++ Fundamentals of Computer Science Outline C++ Classes Special Members Friendship Classes are an expanded version of data structures (structs) Like structs, the hold data members

More information

Index. Audio project AudioSupport class, 207 controls, 206 description, 206 GameState class, 209 goals, 206

Index. Audio project AudioSupport class, 207 controls, 206 description, 206 GameState class, 209 goals, 206 Index A Audio project AudioSupport class, 207 controls, 206 description, 206, 209 goals, 206 B BlowFish class, 245 BounceObject() function, 143 BubbleShot class, 231 C Chasers ChaserGameObject class, 117

More information

the gamedesigninitiative at cornell university Lecture 17 Color and Textures

the gamedesigninitiative at cornell university Lecture 17 Color and Textures Lecture 7 Color and Textures Take Away For Today Image color and composition What is RGB model for images? What does alpha represent? How does alpha composition work? Graphics primitives How do primitives

More information

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK.

Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Start Visual Studio, start a new Windows Form project under the C# language, name the project BalloonPop MooICT and click OK. Before you start - download the game assets from above or on MOOICT.COM to

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

Please go to the Riemer s 2D XNA Tutorial for C# by clicking on You are allowed to progress ahead of me by

Please go to the Riemer s 2D XNA Tutorial for C# by clicking on   You are allowed to progress ahead of me by 2D Shooter game- Part 2 Please go to the Riemer s 2D XNA Tutorial for C# by clicking on http://bit.ly/riemers2d You are allowed to progress ahead of me by reading and doing to tutorial yourself. I ll

More information

LECTURE 4. Announcements

LECTURE 4. Announcements LECTURE 4 Announcements Retries Email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your grader email your

More information

Erasmus+ Project: Yestermorrow Year 1 Maths: Pythagorean Theorem

Erasmus+ Project: Yestermorrow Year 1 Maths: Pythagorean Theorem Erasmus+ Project: Yestermorrow Year 1 Maths: Pythagorean Theorem Workshop (Coding Android Mobile Apps): Collision Detection and the Pythagorean Theorem (Based on the code.org worksheet) WORKSHOP OVERVIEW

More information

Introduction to the Graphics Module Framework

Introduction to the Graphics Module Framework Introduction to the Graphics Module Framework Introduction Unlike the C++ module, which required nothing beyond what you typed in, the graphics module examples rely on lots of extra files - shaders, textures,

More information

Program a Game Engine from Scratch. Development Checkpoint #8. Sprite & Resource Manager

Program a Game Engine from Scratch. Development Checkpoint #8. Sprite & Resource Manager Program a Game Engine from Scratch Mark Claypool Development Checkpoint #8 Sprite & Resource Manager This document is part of the book Dragonfly Program a Game Engine from Scratch, (Version 5.0). Information

More information

Time-step Simulation

Time-step Simulation Time-step Simulation Model: a simplified representation of something else. (Java book) The model will SIMULATE something else. Time-step Simulation: We simulate continuous time by a loop. Each iteration

More information

WW.IT-IQ Training & Solutions (PTY) LTD

WW.IT-IQ Training & Solutions (PTY) LTD GAMES DEVELOPMENT COURSE OUTLINES DURATION: 4 YEARS Course Modules Prerequisite Prerequisite Completing the Fundamentals of Programming Course Completing the Object Oriented Programming Course Initialization

More information

09/08/2017 CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations.

09/08/2017 CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations. CS2530 INTERMEDIATE COMPUTING 9/8/2017 FALL 2017 MICHAEL J. HOLMES UNIVERSITY OF NORTHERN IOWA TODAY S TOPIC: Exceptions and enumerations. 1 RUNTIME ERRORS All of us have experienced syntax errors. This

More information

CannonAttack v1.0. A Test Driven Development Tutorial in C# 4.0 Author: Dominic Millar Tech Review:Matt Rumble Editor:Cathy Tippett

CannonAttack v1.0. A Test Driven Development Tutorial in C# 4.0 Author: Dominic Millar Tech Review:Matt Rumble Editor:Cathy Tippett CannonAttack v1.0 A Test Driven Development Tutorial in C# 4.0 Author: Dominic Millar Tech Review:Matt Rumble Editor:Cathy Tippett http://domscode.com Introduction Defining the Battlefield This tutorial

More information

the gamedesigninitiative at cornell university Lecture 14 2D Sprite Graphics

the gamedesigninitiative at cornell university Lecture 14 2D Sprite Graphics Lecture 14 Drawing Images Graphics Lectures SpriteBatch interface Coordinates and Transforms Drawing Perspective Camera Projections Drawing Primitives Color and Textures Polygons 2 Drawing Images Graphics

More information

Windows Phone Recipes. A Problem-Solution Approach

Windows Phone Recipes. A Problem-Solution Approach Avoid the common pitfalls of Windows Phone programming with this concise recipe collection written specifically for the busy developer Windows Phone Recipes A Problem-Solution Approach Second Edition Fabio

More information

5.1. Examples: Going beyond Sequence

5.1. Examples: Going beyond Sequence Chapter 5. Selection In Chapter 1 we saw that algorithms deploy sequence, selection and repetition statements in combination to specify computations. Since that time, however, the computations that we

More information

Form Properties Window

Form Properties Window C# Tutorial Create a Save The Eggs Item Drop Game in Visual Studio Start Visual Studio, Start a new project. Under the C# language, choose Windows Form Application. Name the project savetheeggs and click

More information

Demo Scene Quick Start

Demo Scene Quick Start Demo Scene Quick Start 1. Import the Easy Input package into a new project. 2. Open the Sample scene. Assets\ootii\EasyInput\Demos\Scenes\Sample 3. Select the Input Source GameObject and press Reset Input

More information

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string.

RegEx - Numbers matching. Below is a sample code to find the existence of integers within a string. RegEx - Numbers matching Below is a sample code to find the existence of integers within a string. Sample code pattern to check for number in a string: using System; using System.Collections.Generic; using

More information

Creating a Role Playing Game with XNA Game Studio 3.0 Part 21 Adding a Custom Content Pipeline Processor and Importer

Creating a Role Playing Game with XNA Game Studio 3.0 Part 21 Adding a Custom Content Pipeline Processor and Importer Creating a Role Playing Game with XNA Game Studio 3.0 Part 21 Adding a Custom Content Pipeline Processor and Importer To follow along with this tutorial you will have to have read the previous tutorials

More information

nostarch.com/pfk For bulk orders, please contact us at

nostarch.com/pfk For bulk orders, please contact us at nostarch.com/pfk For bulk orders, please contact us at sales@nostarch.com. Teacher: Date/Period: Subject: Python Programming Class: Topic: #1 - Getting Started Duration: Up to 50 min. Objectives: Install

More information

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation

RegEx-validate IP address. Defined below is the pattern for checking an IP address with value: String Pattern Explanation RegEx-validate IP address Defined below is the pattern for checking an IP address with value: 240.30.20.60 String Pattern Explanation 240 ^[0-9]1,3 To define the starting part as number ranging from 1

More information

ICS 4U. Introduction to Programming in Java. Chapter 10 Notes

ICS 4U. Introduction to Programming in Java. Chapter 10 Notes ICS 4U Introduction to Programming in Java Chapter 10 Notes Classes and Inheritance In Java all programs are classes, but not all classes are programs. A standalone application is a class that contains

More information

CIS Intro to Programming in C#

CIS Intro to Programming in C# OOP: Creating Classes and Using a Business Tier McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Understand how a three-tier application separates the user interface from the business

More information

Click on the empty form and apply the following options to the properties Windows.

Click on the empty form and apply the following options to the properties Windows. Start New Project In Visual Studio Choose C# Windows Form Application Name it SpaceInvaders and Click OK. Click on the empty form and apply the following options to the properties Windows. This is the

More information