Rob Miles. Creating a Broken MoodLight An XNA game contains game data which is used by the Draw and Update methods – Update updates the game data – Draw.

Slides:



Advertisements
Similar presentations
2000 Prentice Hall, Inc. All rights reserved. 1 Outline 3.1Introduction 3.2Game Loop Components 3.3How to Implement in C# 3.4Adding Image to XNA Project.
Advertisements

Noadswood Science,  To know how to use Python to produce windows and colours along with specified co-ordinates Sunday, April 12, 2015.
Adrianna Gumula UAL Diploma in Art & Design Level 2 COMPLETING “PLANTS ARE NOT BORING”
COMPUTER PROGRAMMING 2 Chapter 7 Sound. Objectives Find out how to prepare sounds for inclusion in Microsoft XNA projects. Incorporate sounds into XNA.
How to Debug VB .NET Code.
Objects Interaction and Source Code Week 2. OBJECT ORIENTATION BASICS REVIEW.
SUNY Morrisville-Norwich Campus-Week 12 CITA 130 Advanced Computer Applications II Spring 2005 Prof. Tom Smith.
A Simple Applet. Applets and applications An applet is a Java program that runs on a web page –Applets can be run from: Internet Explorer Netscape Navigator.
A Simple Applet.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
CH1 – A 1 st Program Using C#. Program Set of instructions which tell a computer what to do. Machine Language Basic language computers use to control.
Hello World In C++ and Microsoft Visual C++. Directions to begin a project 1. Go to All Programs 2. Open Visual Studio C++ 3. Click on New Project 4.
CHAPTER 4 Images XNA Game Studio 4.0. Objectives Find out how the Content Manager lets you add pictures to Microsoft XNA games. Discover how pictures.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 11 1 Microsoft Office Access 2003 Tutorial 11 – Using and Writing Visual Basic for Applications.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
COMPUTER PROGRAMMING 2 Timers. Game Idea: Mob Reaction Timer Use a timer variable to keep track of time and a variable for each player to measure the.
11 A First Game Program Session Session Overview  Begin the creation of an arcade game  Learn software design techniques that apply to any form.
Getting Started. XNA Game Studio 4.0 To download XNA Game Studio 4.0 itself, go to XNA Game.
CSC 107 – Programming For Science. Announcements  Textbook available from library’s closed reserve.
A way to pull together related data A Shape Class would contain the following data: x, y, height, width Then associate methods with that data A Shape.
11 Using the Keyboard Session Session Overview  Introduce the keyboard device  Show how keys on a keyboard can be represented by enumerated types.
Programming in Processing Taught by Ms. Madsen Assistants: Ms. Fischer and Ms. Yen Winsor School, 2/6/08.
Art 321 Lecture 7 Dr. J. Parker. Programming In order to ‘make things happen’ on a computer, you really have to program it. Programming is not hard and.
Collecting Things Together - Lists 1. We’ve seen that Python can store things in memory and retrieve, using names. Sometime we want to store a bunch of.
Rob Miles. Creating a Working MoodLight We know that colours in XNA are stored as values which represent the amount of red, blue, green and transparency.
CHAPTER 10 Using C# Methods to Solve Problem XNA Game Studio 4.0.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
CS PC/CONSOLE GAME PROGRAMMING/DEVELOPMENT CHAPTER 2: DRAWING, DATA AND CONTROLS.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
11 Working with Images Session Session Overview  Find out more about image manipulation and scaling when drawing using XNA  Start to implement.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
XNA Game Studio 4.0 Keyboard and Mouse Controls + more on Animated Sprites.
11 Making a Sprite Session 4.2. Session Overview  Describe the principle of a game sprite, and see how to create a sprite in an XNA game  Learn more.
Introduction to Processing. 2 What is processing? A simple programming environment that was created to make it easier to develop visually oriented applications.
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.
Standard Grade Programming using VB 1 Programming Visual Basic.
11 Getting Player Input Using a Gamepad Session 3.1.
Sanjay Johal. Introduction(1.1) In this PowerPoint I will be explaining :  The purpose of the code for each of the two given programs, e.g. to carry.
2.3. A RCHITECTURAL D ESIGN I Example approach for game screen management.
Aaron Yuen 1 Outline 9.1Storyboarding & Charting Method for Game Design 9.2Game State in Game Development 9.3Game State Management 9.4GUI Assets for Gameplay.
CHAPTER 3 Getting Player Input XNA Game Studio 4.0.
CHAPTER 6 Multiplayer XNA Game Studio 4.0. Objectives Discover how to detect and use individual button-press events in a game. Learn how to create and.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004 Drawing pictures … It’s not art, it’s fun.
CHAPTER 14 Classes, Objects, and Games XNA Game Studio 4.0.
PROGRAMMING IN PYTHON LETS LEARN SOME CODE TOGETHER!
CHAPTER 2 The Game Loop - Variables, Types, Classes and Objects in XNA XNA Game Studio 4.0.
Scientific lab report Title of experiment How light works Team members: Sasha and Felicity.
11 Writing Text Session 5.1. Session Overview  Show how fonts are managed in computers  Discover the difference between bitmap fonts and vector fonts.
11 Debugging Programs Session Session Overview  Create and test a method to calculate percentages  Discover how to use Microsoft Visual Studio.
Playing with Sprites. XNA Game Lifecycle In the faceBall demo program we bounced a smiley face around the graphical display against a background image.
C OMPUTER P ROGRAMMING 1 Input and Variables. I/O S TATEMENTS : I NPUT & V ARIABLES Input is the term used to describe the transfer of information from.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
11 Adding a Bread Bat Session Session Overview  We have created a cheese sprite that bounces around the display  We now need to create a bread.
11 Using the Keyboard in XNA Session 9.1. Session Overview  Discover more detail on how the XNA keyboard is implemented  Find out how to use arrays.
XNA Tutorial 1 For CS134 Lecture. Overview Some of the hard work has already been done for you. If you build and run your game now, the GraphicsDeviceManager.
Rob Miles. Using data in an XNA game program An XNA game program Draw and Update methods that are called to run the game Colours are held in XNA as four.
11 ITI 1120 Lab # 2 Contributors: G. Arbez, M. Eid, D. Inkpen, A. Williams, D. Amyot.
11 Adding Vibration Effects Session Session Overview  Describe how the vibration feature of the gamepad works  Show how an XNA program can control.
HTML HTML stands for Hyper Text Markup Language. HTML is used in making the base of a Website You can just use an online website maker like weebly.com.
Part 1 Learning Objectives To understand that variables are a temporary named location to store data and that programmers work with different data types.
Eastside Robotics Alliance / Newport Robotics Group 1 T/Th, 6:30 – 8:30 PM Big Picture School Day 3 · 10/9/2014.
11 Making Decisions in a Program Session 2.3. Session Overview  Introduce the idea of an algorithm  Show how a program can make logical decisions based.
CHAPTER 5 Text XNA Game Studio 4.0. Objectives Discover how text is drawn using Microsoft XNA. Add some font resources to your XNA program. Draw some.
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
Computer Programming Methodology Luminance
Storing Values as Variables
MTA-4201 Game Programming Chapter 8 : Scrolling Background & Font
For loops Taken from notes by Dr. Neil Moore
Lawrence Snyder University of Washington, Seattle
Presentation transcript:

Rob Miles

Creating a Broken MoodLight

An XNA game contains game data which is used by the Draw and Update methods – Update updates the game data – Draw uses the data to draw the game display We can create a fixed colour light by setting a game data value with the colour we want to be drawn

A Changing Mood Light We can now create any colour moodlight by changing the values that are used to create the colour Next we want to make the colour of the light change automatically over time

Changing Colours A colour can be constructed out of three values (red, green, blue) If we change these values we will draw different colours This is how our changing moodlight will work

Game Data for the Mood Light We need some more game data variables These will hold the intensity of red, green and blue in our mood light Update backColor The Update method will change these values and create a backColor value using them Draw backColor The Draw method will clear the screen with the backColor

Colour Intensity Game Data The intensity of each part of a colour is held as a value in a data byte byte A byte is an area of computer memory that can hold values in the range 0 to 255 byte backColor We need to declare 3 byte variables for the game in addition to the backColor value Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity;

More Game Data We now have four different variables as game data They are shared by all the methods inside the game Color byte One variable is of type Color, the others are of type byte Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; Update method Draw method

Game Data and Methods Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { }

The Game Class public class Game1 : Microsoft.Xna.Framework.Game { } public class Game1 : Microsoft.Xna.Framework.Game { } Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { }

The Game Class public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } } public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } }

What is a Class? A class is what C# calls a lump of data and actions Things which are placed in a class are called “members” of the class Our game class contains the Game world data and the methods that use

Blocks and Brackets – Game1 public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } } public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } }

Blocks and Brackets - Update public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } } public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } }

Blocks and Brackets - Update public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } } public class Game1 : Microsoft.Xna.Framework.Game { Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; protected override void Update(GameTime gameTime) { } protected override void Draw(GameTime gameTime) { } }

Comments Comments do not tell the computer to do anything They make programs easier to understand // At the start of a comment there is a // sequence to mark the rest of that line as a comment // Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; // Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity;

Big Comments /**/ If you want to write a really large comment you put the text in-between /* and */ The compiler (the thing that makes your program into something you can run) ignores all comments Lots of comments make code easy to understand /* This program displays a mood light which changes colour and looks really nice */ /* This program displays a mood light which changes colour and looks really nice */

Coloured Code Visual Studio shows comments in green It also shows keywords in dark blue – A keyword is something which is part of C# Things that have been added to C# (e.g. parts of XNA) are shown in light blue This makes programs easier to read // Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity; // Game Data Color backColor; byte redIntensity; byte greenIntensity; byte blueIntensity;

Initial Values for Variables A program can set the initial value of a variable when the variable is declared backColorUpdate We don’t need to set an initial value of backColor as this will be set by Update // Game Data – start with a black screen Color backColor; byte redIntensity = 0; byte greenIntensity = 0; byte blueIntensity = 0; // Game Data – start with a black screen Color backColor; byte redIntensity = 0; byte greenIntensity = 0; byte blueIntensity = 0;

A Boring Update Method UpdatebackColor This version of Update create a backColor values based on the intensity values The screen will always be black protected override void Update(GameTime gameTime) { // game exit test backColor = new Color(redIntensity, greenIntensity, blueIntensity); base.Update(gameTime); } protected override void Update(GameTime gameTime) { // game exit test backColor = new Color(redIntensity, greenIntensity, blueIntensity); base.Update(gameTime); }

An Interesting Update Method protected override void Update(GameTime gameTime) { // game exit test backColor = new Color(redIntensity, greenIntensity, blueIntensity); redIntensity++ ; // add more red greenIntensity++; // add more green blueIntensity++; // add more blue base.Update(gameTime); } protected override void Update(GameTime gameTime) { // game exit test backColor = new Color(redIntensity, greenIntensity, blueIntensity); redIntensity++ ; // add more red greenIntensity++; // add more green blueIntensity++; // add more blue base.Update(gameTime); }

The Game Draw Method Draw This is exactly the same Draw method we used before Update The game behaves differently because Update does different things to the game data protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(backColor); base.Draw(gameTime); } protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(backColor); base.Draw(gameTime); }

Update This program uses the “interesting” version of Update The brightness values are increased 60 times a second Fading Up

Something is Broken The screen gets brighter, and then it goes black This seems to happen every four seconds or so Apart from that the program runs fine – There are no errors reported What is happening? – More next time......

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs

The Update method contains the program’s class The start and end of a block is marked with curly brackets Comments in programs tell the compiler what to do Comments in programs are blue The Update method is only called once when a game runs