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

Size: px
Start display at page:

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

Transcription

1 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 how to program a video game to demonstrate this. In this example, a ball will bounce around the screen. 1 We will use an if statement to check if the ball hits the edge. If it does, the ball will change direction. Y position = 0 X position = 0 X position = Window.ClientBounds.Width Y position = Window.ClientBounds.Height Here s the UML activity diagram for when the program updates: Notice the diamond shape whenever you use an if statement the diamond allows you two directions (AND ONLY TWO!) to go in. In this case, either the ball hits the side, or it doesn t. 1 Example from Learning XNA 3.0, by Aaron Reed. Copyright 2009 Aaron Reed M c T a v i s h Page 9

2 Create a new project, use XNA Game Studio 3.1, Windows Game. Name it: U2MMDDNAMEIFGAME In Solution Explorer, right-click the Content Folder. Select Add Folder, name it Images. In Solution Explorer, right-click the Images Folder. Select Add Existing Item Add the ball.bmp file (S:\pickup\mctavish) In the Game1.cs code, find the declaration for the class Game1: public class Game1 : Microsoft.Xna.Framework.Game GraphicsDeviceManager graphics; SpriteBatch spritebatch; C# is an object-oriented programming language. A class is an object the entire game is considered an object. Graphics and spritebatch are global variables that are available to the entire program. You will be adding some more global variables. Add the following code after the SpriteBatch line: Texture2D texture; Vector2 ballposition = Vector2.Zero; float xspeed = 2f; float yspeed = 2f; The texture variable will be the graphic we will use for the ball that bounces around. ballposition is a Vector2 variable Vector2 variables have an x value and a y value. It is initialized to the value (0,0) M c T a v i s h Page 10

3 xspeed and yspeed are float variables (similar to Double variables, the f after the number indicates it is a float). In the LoadContent function you will need to add the following line of code (right after the ToDo line) texture = Content.Load<Texture2D>(@"images/ball"); In the Draw function add the following code spritebatch.begin(); spritebatch.draw(texture, ballposition, Color.White); spritebatch.end(); If you run the program now, the ball should appear in the top left corner of the screen. In the Update function, add the following code after the TODO section and before base.update(gametime); 1. ballposition.x += xspeed; 2. if (ballposition.x > Window.ClientBounds.Width - texture.width ballposition.x < 0) 3. xspeed *= -1; 4. ballposition.y += yspeed; 5. if (ballposition.y > Window.ClientBounds.Height - texture.height ballposition.y < 0) 6. yspeed *= -1; If you run the program now, the ball should bounce around the screen. Here s what is happening: 1. ballposition.x += xspeed; The x location of the ball is set to the current x location plus the xspeed value (note += is an operator that adds to the item) 2. if (ballposition.x > Window.ClientBounds.Width - texture.width ballposition.x < 0) M c T a v i s h Page 11

4 Here s the if statement, the first part checks if the location of the ball is off the right of the screen. Note texture.width takes into account the width of the ball itself. is the OR operator in the if statement if the statement to the left OR the statement to the right are true, the next line will run. ballposition.x < 0 checks if the ball is off the left. 3. xspeed *= -1; In this line *= takes the value of xspeed and then multiplies it by -1. This essentially changes the direction by changing the value from positive to negative (or negative to positive) The next three lines do the same things, just with the y values instead. 4. ballposition.y += yspeed; 5. if (ballposition.y > Window.ClientBounds.Height - texture.height ballposition.y < 0) 6. yspeed *= -1; M c T a v i s h Page 12

5 if (Boolean expression) //line of code to run; The example you just programmed used the above format. Everything in the brackets has to result in a true or false answer. If the result is true, the next line of code will run. To run multiple lines of code, use the following: if (Boolean expression) //multiple lines of code between the braces; Comparison Operators The following comparison operators can be used with any primitive data types (Int32, float, Double, BUT NOT strings). In the following examples x and y are Int32 variables x = 4, y = 3 Operator Meaning Expression Result == Equal to x == y False!= Not equal to x!=y True > Greater than x>y True < Less than x<y False >= Greater than or x>=y True equal to <= Less than or equal to x<=y False But what about strings? If you have two strings and you want to compare them, you need to use the Compare or Equals function: if (String.Compare(username,"bob",true) == 0) The above line compares the variable username with the value of bob. It ignores whether there are capital letters or not. The result is -1 if username is alphabetically before bob, 0 if username is bob and 1 if username is alphabetically after bob. ==0 checks if the words are the same. M c T a v i s h Page 13

6 Boolean Operators Boolean operators check multiple situations. In the example you just did you used the OR operator. If the ball hit the top of the screen OR it hit the bottom, it changed direction. Operator Meaning Expression Result && AND TRUE && TRUE TRUE TRUE && FALSE FALSE FALSE && TRUE FALSE FALSE && FALSE FALSE OR TRUE TRUE TRUE TRUE FALSE TRUE FALSE TRUE TRUE FALSE FALSE FALSE! NOT!(TRUE) FALSE!(FALSE) TRUE M c T a v i s h Page 14

7 Advanced if statements The following code uses a variety of if statements. private void btnrun_click(object sender, EventArgs e) //Declare Variables Int32 mark; String output; //Initialize variable //if not an integer, display error if (!(Int32.TryParse(txtInput.Text, out mark))) output = "You must enter a number"; else //Now check what mark they got if (mark >= 90) output = "You got an A"; else if (mark >= 70) output = "You got a B"; else if (mark >= 50) M c T a v i s h Page 15

8 output = "You passed."; else output = "You did not pass."; rtboutput.text = output; M c T a v i s h Page 16

9 Switch Switch statements are similar to if statements. They can be used whenever you have a small range of integers to test. In the following example a mark (1-10) is entered. If the mark is 10, 9 or 8, output is set to Level 4. The break statement is used to break out of the switch statement. switch (mark) case 10: case 9: case 8: case 7: case 6: case 5: output = "Level 4"; output = "Level 3"; output = "Level 2"; output = "Level 1"; default: output = "Below level 1"; M c T a v i s h Page 17

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

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

GAME:IT Advanced. C# XNA Bouncing Ball First Game Part 1 GAME:IT Advanced C# XNA Bouncing Ball First Game Part 1 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

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

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

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

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

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

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

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

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

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

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

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

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

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed.

If the ball goes off either the right or left edge, turn the ball around. If x is greater than width or if x is less than zero, reverse speed. Conditionals 75 Reversing the Polarity of a Number When we want to reverse the polarity of a number, we mean that we want a positive number to become negative and a negative number to become positive.

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

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

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

Interaction Design A.A. 2017/2018

Interaction Design A.A. 2017/2018 Corso di Laurea Magistrale in Design, Comunicazione Visiva e Multimediale - Sapienza Università di Roma Interaction Design A.A. 2017/2018 7 Conditionals in Processing Francesco Leotta, Andrea Marrella

More information

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan

Lecture Programming in C++ PART 1. By Assistant Professor Dr. Ali Kattan Lecture 08-1 Programming in C++ PART 1 By Assistant Professor Dr. Ali Kattan 1 The Conditional Operator The conditional operator is similar to the if..else statement but has a shorter format. This is useful

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

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca

COMP Summer 2015 (A01) Jim (James) Young jimyoung.ca COMP 1010- Summer 2015 (A01) Jim (James) Young young@cs.umanitoba.ca jimyoung.ca order of operations with the explicit cast! int integervariable = (int)0.5*3.0; Casts happen first! the cast converts the

More information

What is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username

What is a variable? a named location in the computer s memory. mousex mousey. width height. fontcolor. username What is a variable? a named location in the computer s memory mousex mousey width height fontcolor username Variables store/remember values can be changed must be declared to store a particular kind of

More information

[ the academy_of_code] Senior Beginners

[ the academy_of_code] Senior Beginners [ the academy_of_code] Senior Beginners 1 Drawing Circles First step open Processing Open Processing by clicking on the Processing icon (that s the white P on the blue background your teacher will tell

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

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

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

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

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

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

Expressions and Casting

Expressions and Casting Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements

Lecture 05 I/O statements Printf, Scanf Simple statements, Compound statements Programming, Data Structures and Algorithms Prof. Shankar Balachandran Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 05 I/O statements Printf, Scanf Simple

More information

CSE 142 Su 04 Computer Programming 1 - Java. Objects

CSE 142 Su 04 Computer Programming 1 - Java. Objects Objects Objects have state and behavior. State is maintained in instance variables which live as long as the object does. Behavior is implemented in methods, which can be called by other objects to request

More information

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

Processing/Java Syntax. Classes, objects, arrays, and ArrayLists

Processing/Java Syntax. Classes, objects, arrays, and ArrayLists Processing/Java Syntax Classes, objects, arrays, and ArrayLists 1 Processing and Java Java is relentlessly object-oriented Among other things, this means that all methods must occur within classes Processing

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

In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics.

In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics. Additional Controls, Scope, Random Numbers, and Graphics CS109 In this lecture we will briefly examine a few new controls, introduce the concept of scope, random numbers, and drawing simple graphics. Combo

More information

Basic Computer Programming (Processing)

Basic Computer Programming (Processing) Contents 1. Basic Concepts (Page 2) 2. Processing (Page 2) 3. Statements and Comments (Page 6) 4. Variables (Page 7) 5. Setup and Draw (Page 8) 6. Data Types (Page 9) 7. Mouse Function (Page 10) 8. Keyboard

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

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

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

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

Java Identifiers, Data Types & Variables

Java Identifiers, Data Types & Variables Java Identifiers, Data Types & Variables 1. Java Identifiers: Identifiers are name given to a class, variable or a method. public class TestingShastra { //TestingShastra is an identifier for class char

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

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

Visual C# Program: Simple Game 3

Visual C# Program: Simple Game 3 C h a p t e r 6C Visual C# Program: Simple Game 3 In this chapter, you will learn how to use the following Visual C# Application functions to World Class standards: Opening Visual C# Editor Beginning a

More information

General Syntax. Operators. Variables. Arithmetic. Comparison. Assignment. Boolean. Types. Syntax int i; float j = 1.35; int k = (int) j;

General Syntax. Operators. Variables. Arithmetic. Comparison. Assignment. Boolean. Types. Syntax int i; float j = 1.35; int k = (int) j; General Syntax Statements are the basic building block of any C program. They can assign a value to a variable, or make a comparison, or make a function call. They must be terminated by a semicolon. Every

More information

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013 Expressions and Casting C# Programming Rob Miles Data Manipulation We know that programs use data storage (variables) to hold values and statements to process the data The statements are obeyed in sequence

More information

Bits and Bytes. How do computers compute?

Bits and Bytes. How do computers compute? Bits and Bytes How do computers compute? Representing Data All data can be represented with: 1s and 0s on/of true/false Numbers? Five volunteers... Binary Numbers Positional Notation Binary numbers use

More information

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it. Introduction to JAVA JAVA is a programming language which is used in Android App Development. It is class based and object oriented programming whose syntax is influenced by C++. The primary goals of JAVA

More information

Variable initialization and assignment

Variable initialization and assignment Variable initialization and assignment int variable_name; float variable_name; double variable_name; String variable_name; boolean variable_name; Initialize integer variable Initialize floating point variable

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

Class #1. introduction, functions, variables, conditionals

Class #1. introduction, functions, variables, conditionals Class #1 introduction, functions, variables, conditionals what is processing hello world tour of the grounds functions,expressions, statements console/debugging drawing data types and variables decisions

More information

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont.

5/3/2006. Today! HelloWorld in BlueJ. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. HelloWorld in BlueJ, Cont. Today! Build HelloWorld yourself in BlueJ and Eclipse. Look at all the Java keywords. Primitive Types. HelloWorld in BlueJ 1. Find BlueJ in the start menu, but start the Select VM program instead (you

More information

McGill University School of Computer Science COMP-202A Introduction to Computing 1

McGill University School of Computer Science COMP-202A Introduction to Computing 1 McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif

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

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types and

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

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++

Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ Laboratory 0 Week 0 Advanced Structured Programming An Introduction to Visual Studio and C++ 0.1 Introduction This is a session to familiarize working with the Visual Studio development environment. It

More information

Language Reference Manual

Language Reference Manual ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents

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

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing. CISC-124 20180115 20180116 20180118 We continued our introductory exploration of Java and object-oriented programming by looking at a program that uses two classes. We created a Java file Dog.java and

More information

Logic & program control part 2: Simple selection structures

Logic & program control part 2: Simple selection structures Logic & program control part 2: Simple selection structures Summary of logical expressions in Java boolean expression means an expression whose value is true or false An expression is any valid combination

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

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

Design Programming DECO2011

Design Programming DECO2011 Design Programming DECO2011 Rob Saunders web: http://www.arch.usyd.edu.au/~rob e-mail: rob@arch.usyd.edu.au office: Room 274, Wilkinson Building Data, Variables and Flow Control What is a Variable? Computers

More information

Defining Classes and Methods

Defining Classes and Methods Defining Classes and Methods Chapter 5 Modified by James O Reilly Class and Method Definitions OOP- Object Oriented Programming Big Ideas: Group data and related functions (methods) into Objects (Encapsulation)

More information

SFPL Reference Manual

SFPL Reference Manual 1 SFPL Reference Manual By: Huang-Hsu Chen (hc2237) Xiao Song Lu(xl2144) Natasha Nezhdanova(nin2001) Ling Zhu(lz2153) 2 1. Lexical Conventions 1.1 Tokens There are six classes of tokes: identifiers, keywords,

More information

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application

Java Applets. Last Time. Java Applets. Java Applets. First Java Applet. Java Applets. v We created our first Java application Last Time v We created our first Java application v What are the components of a basic Java application? v What GUI component did we use in the examples? v How do we write to the standard output? v An

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 06 / 04 / 2015 Instructor: Michael Eckmann Today s Topics Questions / comments? Calling methods (noting parameter(s) and their types, as well as the return type)

More information

Chapter 4 Lab. Loops and Files. Objectives. Introduction

Chapter 4 Lab. Loops and Files. Objectives. Introduction Chapter 4 Lab Loops and Files Objectives Be able to convert an algorithm using control structures into Java Be able to write a while loop Be able to write a do-while loop Be able to write a for loop Be

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

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof.

GridLang: Grid Based Game Development Language Language Reference Manual. Programming Language and Translators - Spring 2017 Prof. GridLang: Grid Based Game Development Language Language Reference Manual Programming Language and Translators - Spring 2017 Prof. Stephen Edwards Akshay Nagpal Dhruv Shekhawat Parth Panchmatia Sagar Damani

More information

Start Visual Studio, create a new project called Helicopter Game and press OK

Start Visual Studio, create a new project called Helicopter Game and press OK C# Tutorial Create a helicopter flying and shooting game in visual studio In this tutorial we will create a fun little helicopter game in visual studio. You will be flying the helicopter which can shoot

More information

(a) Assume that in a certain country, tax is payable at the following rates:

(a) Assume that in a certain country, tax is payable at the following rates: 3 1. (Total = 12 marks) (a) Assume that in a certain country, tax is payable at the following rates: 15% on your first $50000 income 25% on any amount over $50000 Write a method that takes in an annual

More information

Decisions in Java IF Statements

Decisions in Java IF Statements Boolean Values & Variables In order to make decisions, Java uses the concept of true and false, which are boolean values. Just as is the case with other primitive data types, we can create boolean variables

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010

CS 102 / CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 CS 102 / CS 107 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2010 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each)

More information

You can call the project anything you like I will be calling this one project slide show.

You can call the project anything you like I will be calling this one project slide show. C# Tutorial Load all images from a folder Slide Show In this tutorial we will see how to create a C# slide show where you load everything from a single folder and view them through a timer. This exercise

More information

Key Differences Between Python and Java

Key Differences Between Python and Java Python Python supports many (but not all) aspects of object-oriented programming; but it is possible to write a Python program without making any use of OO concepts. Python is designed to be used interpretively.

More information

Basic SFML Moving a Sprite

Basic SFML Moving a Sprite Basic SFML Moving a Sprite This sample program is a basic SFML program allowing the user to move a sprite around a screen by using the keyboard. 1. Download the zip file associated with this lecture. This

More information

CSE 142/143 Unofficial Style Guide

CSE 142/143 Unofficial Style Guide CSE 142/143 Unofficial Style Guide Below, things in GREEN are GOOD; things in RED are to be AVOIDED. Commenting Comment well. Follow the commenting rules for header, method, field, and inside-method comments

More information

Activity 3: Data Types

Activity 3: Data Types Activity 3: Data Types Java supports two main types of data: primitive types like int and double that represent a single value, and reference types like String and Scanner that represent more complex information.

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi Lecture 3 Constants, Variables, Data Types, And Operations Department of Computer Engineering

More information

Computers, Variables and Types. Engineering 1D04, Teaching Session 2

Computers, Variables and Types. Engineering 1D04, Teaching Session 2 Computers, Variables and Types Engineering 1D04, Teaching Session 2 Typical Computer Copyright 2006 David Das, Ryan Lortie, Alan Wassyng 1 An Abstract View of Computers Copyright 2006 David Das, Ryan Lortie,

More information

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.

Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment

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

Express Yourself. Writing Your Own Classes

Express Yourself. Writing Your Own Classes Java Programming 1 Lecture 5 Defining Classes Creating your Own Classes Express Yourself Use OpenOffice Writer to create a new document Save the file as LastFirst_ic05 Replace LastFirst with your actual

More information

egrapher Language Reference Manual

egrapher Language Reference Manual egrapher Language Reference Manual Long Long: ll3078@columbia.edu Xinli Jia: xj2191@columbia.edu Jiefu Ying: jy2799@columbia.edu Linnan Wang: lw2645@columbia.edu Darren Chen: dsc2155@columbia.edu 1. Introduction

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

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

Fundamentals of Programming CS-110. Lecture 2

Fundamentals of Programming CS-110. Lecture 2 Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

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

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1

Pick a number. Conditionals. Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary. CS Conditionals 1 Conditionals Boolean Logic Relational Expressions Logical Operators Numerical Representation Binary CS105 04 Conditionals 1 Pick a number CS105 04 Conditionals 2 Boolean Expressions An expression that

More information

Skinning Manual v1.0. Skinning Example

Skinning Manual v1.0. Skinning Example Skinning Manual v1.0 Introduction Centroid Skinning, available in CNC11 v3.15 r24+ for Mill and Lathe, allows developers to create their own front-end or skin for their application. Skinning allows developers

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,

More information

Introduction to Programming EC-105. Lecture 2

Introduction to Programming EC-105. Lecture 2 Introduction to Programming EC-105 Lecture 2 Input and Output A data stream is a sequence of data - Typically in the form of characters or numbers An input stream is data for the program to use - Typically

More information