Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.

Slides:



Advertisements
Similar presentations
Data Representation COE 202 Digital Logic Design Dr. Aiman El-Maleh
Advertisements

The Binary Numbering Systems
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, Java Version, Third Edition.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Data Representation COE 205
Connecting with Computer Science, 2e
Chapter 3 Data Representation.
Chapter 3 Data Representation. Chapter goals Describe numbering systems and their use in data representation Compare and contrast various data representation.
8 November Forms and JavaScript. Types of Inputs Radio Buttons (select one of a list) Checkbox (select as many as wanted) Text inputs (user types text)
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Third Edition.
Chapter 4: The Building Blocks: Binary Numbers, Boolean Logic, and Gates Invitation to Computer Science, C++ Version, Fourth Edition.
Data Types. Every program must deal with data The data is usually described as a certain type This type determines what you can do with the data and how.
ENEL 111 Digital Electronics Richard Nelson G.1.29
Binary Number Systems.
Topic 4 Computer Mathematics and Logic
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
(2.1) Fundamentals  Terms for magnitudes – logarithms and logarithmic graphs  Digital representations – Binary numbers – Text – Analog information 
Computing Higher - Unit 1… Computer Systems 1 Higher Computing Unit 1 – Topic 1 Data Representation.
Computers Organization & Assembly Language
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
Input & Output: Console
Programming Games Formulas. Date. Representation in [computer] Storage. Credit Card. Homework: Finish slide show. Upload application.
Foundations of Computer Science Computing …it is all about Data Representation, Storage, Processing, and Communication of Data 10/4/20151CS 112 – Foundations.
Representing Data. Representing data u The basic unit of memory is the bit  A transistor that can hold either high or low voltage  Conceptually, a tiny.
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
Cis303a_chapt03-2a.ppt Range Overflow Fixed length of bits to hold numeric data Can hold a maximum positive number (unsigned) X X X X X X X X X X X X X.
Homework: New coin toss. [Start dice game.]
Lecture 5. Topics Sec 1.4 Representing Information as Bit Patterns Representing Text Representing Text Representing Numeric Values Representing Numeric.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
Creating Web Documents catch-up JavaScript slide show tools redirection.
Programming Games Credit cards. Forms. Homework: Catch up: dice game. Produce your own credit card application or something else making use of a form with.
1 Information Representation in Computer Lecture Nine.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
2016 N5 Prelim Revision. HTML Absolute/Relative addressing in HTML.
Computer Science I Storing data. Binary numbers. Classwork/homework: Catch up. Do analysis of image types.
1. Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 2.
Data Representation. How is data stored on a computer? Registers, main memory, etc. consists of grids of transistors Transistors are in one of two states,
Types Chapter 2. C++ An Introduction to Computing, 3rd ed. 2 Objectives Observe types provided by C++ Literals of these types Explain syntax rules for.
Tutorial 11 1 JavaScript Operators and Expressions.
Computing Systems Lecture 3 Binary Representation & Boolean Logic Binary and Logic 1.
09/06/ Data Representation ASCII, Binary Denary Conversion, Integer & Boolean data types.
 Computers are 2-state devices › Pulse – No pulse › On – Off  Represented by › 1 – 0  BINARY.
Programming Games Reprise Credit Cards! Reprise Binary. Overall time limit, setTimeout Homework: [Show virtual something.] Make proposal as reply to my.
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Backgrounder: Binary Math
Invitation to Computer Science, C++ Version, Fourth Edition
Lec 3: Data Representation
Everything is a number Everything in a computer memory and on storages is a number. Number  Number Characters  Number by ASCII code Sounds  Number.
Programming Games Work / finish and show dice game. Extras. Timed events. ftp. index file. Homework: Catch up and do slide show.
Data Representation Binary Numbers Binary Addition
ENEL 111 Digital Electronics
Chapter 3 Data Storage.
Digital Electronics Jess 2008.
Why use Binary? There are only four rules for addition in binary compared to 100 in decimal [0+0=0 ; 0+1=1 ; 1+0=1; 1+1=10]
Invitation to Computer Science, Java Version, Third Edition
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Binary Numbers Material on Data Representation can be found in Chapter 2 of Computer Architecture (Nicholas Carter) CSC 370 (Blum)
Why use Binary? It is a two state system (on/off) which makes it simple to operate Even if degradation of current occurs (ie a slight drop in voltage)
Plan Attendance Files Posted on Campus Cruiser Homework Reminder
How Computers Store Data
Chapter 3 DataStorage Foundations of Computer Science ã Cengage Learning.
Programming games Share your plans for your virtual something.
ENEL 111 Digital Electronics
Presentation transcript:

Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server account and creating (and updating) an index.html file.

Reprise: logic of dice game Use so-called state variables to hold – Boolean value (true vs false) indicating if this a first throw or not – value (number) of the point value Use if statement with the condition is this a first throw Use switch statements to hold the rules –different based on first throw or not first throw

Any application any game what are the states of the application? what are the rules? what are the player moves? what are the events (including responding to player moves)?

Timed events JavaScript provides functions for setting up timed events setInterval ('moveit(dx,dy)',500); tid = setInterval('change()',800); setInterval(change,800); setTimeout(finish,2000); //just happens once tid = setInterval(finish,2000); clearInterval(tid);

Timed events The coding is different, but the underlying concept is the same as other events –set up handling for event: do something, generally invoke a function, when something happens –write the event handler function –event can be stopped, for the timing event, that means a call to clearInterval using the value set by the call to setInterval or setTimeout.

Exercises Set up a timed event to be a call to "stopgame();" to happen one time, after 10 seconds? one and one half seconds? –What do you think stopgame is? Set up timed events to be a call to "moveit(dx,dy);" to happen 10 times/second until your code stops it?

Slide show Use form buttons to start and stop the slide show. Starting the slide show is done by a function that contains a call to setInterval. Stopping the slide show is done by a function that contains a call to clearInterval. The change function advances the slide show using a variable sn and then incrementing sn. The sn variable is reset back to zero when it reaches the end—pointing past the end of the array holding the names of the slide image files.

Preview: Animation … fooling the eye/brain by showing a sequence of still pictures. JavaScript: use setInterval. –shorter intervals than for the slide show –In slide show: the event handler changes the src value of an img element. –Future projects: the event handler will change src values OR draw (re-draw) the canvas OR move (re-position) elements around the screen.

Slide show Use an array to hold the names of the image files. –Alternative: construct the names. This works if the names follow a pattern. Need to write code to go back to the first element of the array. Note: the variable sn pointing to next slide is a state variable

Slide show You need to upload the.html file and all the image files. Some people like putting image files in their own folder. Your code must reflect this… Either change the values in the slides array or document.pic1.src = "images/" + slides[sn];

Lead in to datatypes… What does the + operator do when the operands are strings (aka character strings aka text)? Answer: concatenation

Overview Representation of information. How is everything/anything represented 'in' the computer (in storage)? –ANSWER: everything is represented using 1s and 0s. What the 1s and 0s mean depends on what the information is, for example, the datatype whole number, number with fraction, true/false value, character string, other… Expressions and operators

Storage Everything (data and programs) is stored in the circuitry of 'the computer'. The circuitry includes transistors that are switches: on or off states, 0 or 1. Each switch is called a bit. So….numbers are stored using the binary (base 2) system Symbols (characters, letters, etc.) are stored using agreed upon systems of encoding –ASCII: 8 bits per character –UNICODE: 16 bits per character

Why? Why not use circuits that can directly represent numbers using the decimal (base 10) system? Answer: Easier to make on/off switches than something with 10 states. Easier to build circuitry for calculations for the base 2 addition and base 2 times tables than the ones you remember…

Recall base 10 Recall 1s column, 10s column, 100s column Recall borrowing (re-grouping) and carrying Do problem(s)

Base 2 Same principle 1s column, 2s column, 4s column, ???? Do problem(s)

Joke Explain joke on shirt

Another Joke

Base 16 Hexadecimal: used for quick way to describe bits, mostly commonly for color coding Symbols used are 0, 1, 2, …, 9, A, B, C, D, E, F You have seen color coding: RGB (red, green blue) in hexadecimal FF0000 is red 00FF00 is green ??

Numbers with fraction part Aka numbers with a decimal point How to represent? ANSWER: floating point numbers aka scientific notation – * 10 2 is the same as * 10 0 –Terminology: (or ) is the mantissa or significand and the 2 (or 0) is the exponent. Computer format: use 2 or 16 in place of 10 Example using 32 bits: – 1 bit for the sign (0 for +, 1 for -) – 8 bits for the exponent –23 bits for the mantissa (width, i.e., 23, is the precision)

Characters ASCII coding The character A is represented by The character a is represented by The character 1 is represented by The character 2 is represented by …. Unicode is a 16 bit format big enough (hopefully) for all the world's languages

String of characters …such as a name or a label or a piece of text Fixed length: allocate 1 byte (8 bits) for each character –UNICODE 2 bytes Variable length: store string in two parts –One part holds length as a number and pointer (address) of the whole string –String itself

Boolean Named after George Boole True / False Theoretically: 1 bit, 0 for false, 1 for true but The addressability requirement means it could be 1 byte or even bigger String of Booleans can be combined. –A byte can represent the answer to 8 true/false questions.

HTML5 form input HTML5 provides additional ways to specify input in forms. Claim is that browser will check (validate) input. One specific new type is range ml5logoscale.html

HTML5 form input See html5/addmessage.html html5/addmessage.html For type="url", type="color" There are others.

Classwork/Homework Make your own slide show –Think about timing. May change after your program is debugged. –Can add more images. Next class: credit cards Catch-up!