ICT Gaming Lesson 3.

Slides:



Advertisements
Similar presentations
Microsoft® Small Basic
Advertisements

Programming Concepts MIT - AITI. Variables l A variable is a name associated with a piece of data l Variables allow you to store and manipulate data in.
index.php Palmyra Area High School 1.
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running o Stored in.
Visual Basic Chapter 1 Mr. Wangler.
Introduction to Python
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Flow of Control. 2 Control Structures Control structure: An instruction that determines the order in which other instructions in a program are executed.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
COMPUTER PROGRAMMING. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may repeat code.
Input, Output, and Processing
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
Introduction to Programming with RAPTOR
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Algorithms Writing instructions in the order they should execute.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
ICT Study Guide Video Game Design Stacked Squares (Basic)
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Alice: A Visual Introduction to Programming Third Edition.
Controlling Computers with Programs When you create a computer program you are creating a set of instructions that tell the computer exactly and completely.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Scratch Programming Cards
Introduction to Scratch
C++ LANGUAGE MULTIPLE CHOICE QUESTION
Unit 2 Technology Systems
Information and Computer Sciences University of Hawaii, Manoa
Visual Basic.NET Windows Programming
Topic 02: Introduction to ActionScript 3.0
Collision Theory and Logic
VB Script V B S.
Topics Designing a Program Input, Processing, and Output
Programming & Scratch.
Games Programming in Scratch
Scratch for Interactivity
University of Central Florida COP 3330 Object Oriented Programming
Collision Theory and Logic
Chapter 3: Variables, Functions, Math, and Strings
Chapter 3: Variables, Functions, Math, and Strings
University of Central Florida COP 3330 Object Oriented Programming
The Selection Structure
Variables, Expressions, and IO
Scripts & Functions Scripts and functions are contained in .m-files
Control Structures
Starter Write a program that asks the user if it is raining today.
Chapter 2 Visual Basic Interface
Selection CIS 40 – Introduction to Programming in Python
Introduction to C++ Programming
WEB PROGRAMMING JavaScript.
Chapter 3: Introduction to Problem Solving and Control Statements
T. Jumana Abu Shmais – AOU - Riyadh
ICT Programming Lesson 4:
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Computer Science Core Concepts
Topics Designing a Program Input, Processing, and Output
Flow of Control.
ICT Programming Lesson 5:
Topics Designing a Program Input, Processing, and Output
Introducing JavaScript
Basic Programming Concepts
Web Programming and Design
Presentation transcript:

ICT Gaming Lesson 3

Basic Programming Concepts Objectives 10.3.8: Explain the types and uses of variables in game programming. 10.3.9: Describe basic Boolean concepts, including logical operators, order of precedence, and expressions. 10.3.10: Describe the use of events, event handlers and functions in game programming. 10.2.11: Describe the use of parameters and arguments in game programming. 10.3.12: Describe the use of objects, classes and instances in game programming. 10.3.13: Describe the use of properties and methods with objects in game programming.

Variable Variables are used to store information (in the computer's memory) that can be used in a program when executing detailed instructions. Descriptive name: the type of data it stores, such as "playerName.” Programs refer to the variable name

Variable In Math: x=2 (x= the variable) then: x+4=6 For example: If the playerName variable stores the value ”Michael," then when the program instructs the computer to print playerName, the name Michael will be displayed on the screen. If playerName changes to John, then the program simply changes the variable data to John (playerName = John). Every reference to the playerName variable will update to the new data.

Variables Declaring: telling the program that the variable exists and the data type the variable will store Initializing: assigning an original (initial) value Expressions contain a combination of variables, values, functions and operators, which are evaluated and produce another value. Similar to mathematical expressions: (2+8)*(2+1) evaluates to 30

Data Types Variables can hold different types of data and are classified based on the type of data they hold.

Operators A program can do “operations” on a variable An example would be a Score variable that adds up the points earned during a game The equal sign (=) is considered an assignment operator in most programming languages. Expressions are evaluated using the mathematical order of precedence: 1. Parentheses ( ) 2. Exponentiation xy 3. Multiplication and division * / 4. Addition and subtraction + -

Operators

Boolean Operators A Boolean (true or false) contains a condition and is often used in repetition and selection structures. Example: If “light=red” is true, then “stop”, or else if false, then “go ahead”. Conditional Booleans — check for a specific condition. Comparative Booleans — compare values.

Boolean Operators Conditional Boolean The code looks for “peanuts” If word exists, Condition is (=) True If word does not exist (Else), Condition is (=) False Comparative Boolean If the code finds a “Yes”, then the code will make the statement.

Characters in a game are a class of "Objects" Class & Objects A class is a definition or blueprint used to create a particular type of object. A class provides a detailed description of the object's characteristics (such as that the object should include a size and a color), and it specifies what can be done with the object (its functions). Characters in a game are a class of "Objects"

Properties & Instances Properties are the various characteristics of an object, such as size, color and type. Each object created using the class contains the same properties, but the values of the properties may be different. When a class is used to build an object, the object is called an instance of the class. Multiple objects (or instances) can be created using the same class. Sprites are objects that can be cloned to create separate and varied instances of the sprite. The clone will inherit the scripts, costumes, sounds and properties of the parent sprite, but can be modified separately.

Class & Objects

Objects, Methods & Functions Functions are actions that a class can do; but, are NOT part of the class description. Functions are named units of code that perform a task or cause an action to take place. A function is called upon or executed by a descriptive name, such as "move forward" or "jump up.”

Objects, Methods & Functions Actions that an object can perform and are a part of the object’s description (such as move, rotate or jump) are called methods in programming. A method is a function of a class – in other words, it is actions the class can perform and is part of how the class is defined. The methods that can be applied to the football object in a game program might be to bounce off walls, speed when thrown, or move up or down when the keyboard arrows are pressed.

Objects, Methods & Functions Each object created using the class shares the same methods (functions) as all the other objects created from the same class. That is, all objects in a class can do the same things, such as bounce off walls or speed when thrown. Methods and functions are ONLY applied to a class.

Arguments & Parameters Methods need information that tells them how far, high, long ,etc… A parameter is the variable that holds the argument data (value) needed by the method. For example, degrees=90 or steps=10.

Arguments & Parameters An argument is the value that is passed to a method when it is called so that it knows what to do. For example, an argument given to the rotate method could be 90o or 180o. So in this example: Degrees and steps are the parameters. The values assigned to the parameters — 90 and 10 — are the arguments.

Events & Handlers Event An event is an action that takes place while a program is running, such as a mouse click or the pressing of a key. It’s what you do that causes the method to execute.

Events & Handlers Event Handler An event handler contains the instructions to execute when the event occurs. Event handlers are functions/methods.

Concatenation Concatenation means to merge 2 or more variables into a single expression

Practice Label the following items in the picture using the letters below. a. A variable b. A variable value c. An expression d. An event e. A loop structure f. A selection structure g. A sequence structure h. A concatenation i. An operator

Practice Label the following items in the picture using the letters below. a. A variable b. A variable value c. An expression d. An event e. A loop structure f. A selection structure g. A sequence structure h. A concatenation i. An operator

Example Example of a Method Method: Turn left (function) Parameter: degrees Argument: 10

Example Event: When clicked Method: Switch (no function) Parameter: costume Argument: costume1 / costume2

Example Event: When this sprite clicked Class: Character Method: Play Function: None Parameter (Variable): Sound Argument: zoop Change score by 1 is a function. Your character is playing the sound, so the "play sound" is a Method.

Practice Event: Key space pressed Method: Play Parameter: Sound Argument: Meow Function: until done

Review: Class - Object Class: Chair Properties: Base: Roller Back: High Color: Tan Covering: Leather Object: The specific object described by the properties and their values.