Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.

Slides:



Advertisements
Similar presentations
JavaScript I. JavaScript is an object oriented programming language used to add interactivity to web pages. Different from Java, even though bears some.
Advertisements

The Web Warrior Guide to Web Design Technologies
Programming games Reprise on dice game and alternative dice game Homework: [Catch up.]. Finish dice game.
CIS101 Introduction to Computing Week 12. Agenda Your questions Solutions to practice text Final HTML/JavaScript Project Copy and paste assignment JavaScript:
Chapter 20 Thinking Big: Functions. Copyright © 2006 Pearson Addison-Wesley. All rights reserved Anatomy of a Function Functions are packages for.
CSCE 121, Sec 200, 507, 508 Fall 2010 Prof. Jennifer L. Welch.
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)
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
Computer Science 103 Chapter 4 Advanced JavaScript.
JavaScript Events and Event Handlers 1 An event is an action that occurs within a Web browser or Web document. An event handler is a statement that tells.
Programming games Flash drawing trick(s). Rock paper scissors. Classwork: Complete rock paper scissors.
Programming Games Review for midterm. Work session. Homework: Prepare for midterm.
Homework: Finish dice game.
Created by, Author Name, School Name—State FLUENCY WITH INFORMATION TECNOLOGY Skills, Concepts, and Capabilities.
SYST Web Technologies SYST Web Technologies Lesson 6 – Intro to JavaScript.
Execution Environment for JavaScript " Java Script Window object represents the window in which the browser displays documents. " The Window object provides.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Chapter 3 : Processing on the Front End JavaScript Technically its name is ECMA-262, which refers to the international standard which defines it. The standard.
Creating Web documents JavaScript: modeling dog behavior general modeling concepts JavaScript review.
Programming Games Formulas. Date. Representation in [computer] Storage. Credit Card. Homework: Finish slide show. Upload application.
CPSC1301 Computer Science 1 Chapter 11 Creating Classes part 1.
Client Scripting1 Internet Systems Design. Client Scripting2 n “A scripting language is a programming language that is used to manipulate, customize,
Programming Games Google Map API examples. CSS. Classwork/homework: Catch up. Upload work. Show your [more] complex Google Maps API example. Plan your.
Programming Games Show your simple video. More video examples. Audio. Classwork/Homework: Produce more complex video program.
Programming games Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
Homework: New coin toss. [Start dice game.]
 2008 Pearson Education, Inc. All rights reserved JavaScript: Functions.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
Programming Fundamentals. Today’s Lecture Why do we need Object Oriented Language C++ and C Basics of a typical C++ Environment Basic Program Construction.
WDMD 170 – UW Stevens Point 1 WDMD 170 Internet Languages eLesson: Variables, Functions and Events (there is an audio component to this eLesson) © Dr.
CSC1401 Classes - 1. Learning Goals Computing concepts Identifying objects and classes Declaring a class Declaring fields Default field values.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
Visual Basic Games: Week 4 Recap Parallel structures Initialization Prepare for Memory Scoring Shuffling Homework: when ready, move on to next game/chapter.
Programming games HTML/JavaScript basics Functions, events, forms Classwork: [Show favorite sites.] Coin toss. Homework: GET WEB SPACE. Complete coin toss.
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Creating Web Documents catch-up JavaScript slide show tools redirection.
JavaScript, Fourth Edition
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.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
JavaScript. JavaScript Introduction JavaScript is the world's most popular programming language. It is the language for HTML and the web, for servers,
Understanding JavaScript and Coding Essentials Lesson 8.
Programming games Drawing logo. Expressions. Formulas. Credit cards. Form validation. Homework: your credit card program. Continue uploading work.
Tutorial 11 1 JavaScript Operators and Expressions.
Programming games Reprise on credit cards. Operators. Homework: Catch-up. Work on your JavaScript project.
Time to upload Virtual something.
JavaScript Tutorial. What is JavaScript JavaScript is the programming language of HTML and the Web Programming makes computers do what you want them to.
Programming Games Reprise Credit Cards! Reprise Binary. Overall time limit, setTimeout Homework: [Show virtual something.] Make proposal as reply to my.
JavaScript: Functions
JavaScript Functions.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Event Driven Programming & User Defined Functions
CSCE Fall 2013 Prof. Jennifer L. Welch.
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Barb Ericson Georgia Institute of Technology Oct 2005
CSCE Fall 2012 Prof. Jennifer L. Welch.
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
Programming games Share your plans for your virtual something.
Web Programming and Design
Presentation transcript:

Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan your virtual something. Do codeacademy.

Describe 3 mistakes in the following code for calculating days in the month for this year switch(mon { case “Sep”: case “Apr”: case “Jun”: case “Nov”: daysInMonth = “This month has 30 days.”; case “Feb”: daysInMonth = “This month has 29 days.”; break; default: daysInMonth = “This month has 31 days.”; } For each mistake, is the error syntactic or semantic?

HTML html elements have opening and closing tags –…except for singletons such as img Elements have attributes, depends on the type. Elements can have names –Need the name to reference or set any of the element attributes

Programming Requirements for names: exact for built-in features and consistent for those you (the programmer) make up. This holds for ALL programming languages Requirements on bracketing (things within things) holds for ALL programming languages The specific syntax (use of {},(),<>,[ ]) holds for JavaScript AND ActionScript –And Java and C –Some other languages use line breaks and other symbols

Declare variables The var statement is used to set up a variable: associate a name with a value. The var statement can initialize the value or be used just to let JavaScript 'know' that this will be used as a variable. Variables can change (vary….) Variables are named values Values can be numbers, strings, Booleans (true or false), other things…

Arrays …. Are sets (actually a sequence) of things. The code gets to one of the things using an index. –Index can be 0 to 1 less than the number in the array –This relates to how the address is calculated. For example var list = [120, 45, 97]; list of 3 numbers list[0] is 120, list[1] is 45, list[2] is 97. Code can change one of the elements: list[1] = 80; OR if n is a variable holding the number 2: list[n] = 23; means after these 2 assignment statements: [120,80,23]

Big ideas Function Variable Object Event Arrays Application state

Function Function is definition of a sequence of statements CODE –And (generally) a name –And (sometimes) one or more parameters A function once defined can be invoked –Called –Called to be executed

In HTML/Javascript Definition of function is in the element function dthrow() { } Invocation of function in Invocation of function in function travel( ) { move(dx,dy); } tid = setInterval(“change();”, 300);

HTML with Javascript (repeat) One function can call another function Invoke function after reading in (loading in) body, using onload= in tag Invoke function directly in the section Invoke function by a submit button defined in a element – Invoke function using an element – Start Invoke function using a element.

Variables Variable: associates a name with a value Value can change (vary) Can use the variable name to get the value Variables can be global (outside of any function) or local to a function Javascript: –Declare the variable using a var statement –Doing this outside any function makes the variable global and available to any code inside functions or outside functions

Other information Programming generally requires encoding of information. The encoding CAN BE arbitrary, but does need to be defined –My rock paper scissors game assigns 0 to rock, 1 to paper and 2 to scissors. The player NEVER sees this. Many systems of encodings start with 0 –Arrays (sets of values) are indexed starting with 0.

Instructions Computer storage holds –Instructions (the code) Instructions may be translation (compilation) of higher level instructions Machine code: Load Register, Store Register, Add, Multiply, Check value and jump, etc. –Information Can't look at the bits and say what it is – the letter J or the number 74 or...

Note: Scope Large (larger) applications worked on by many people require rules on scope of variable and function names What if two or more people working on different sections of a project used the same name? Answer: scoping rules. Avoid global variables. Share information different ways… –Use objects

Objects Objects bring together code and data Code called methods Data called properties or attributes Math object has random method document object has write method –write method takes what is to be written as the parameter If an img element has the name 'coin', then the document object has an attribute by the name of coin that has an attribute by the name of src.

programmer defined objects See program with approach for building rectangles and ovals. – 5/build1.htmlhttp://faculty.purchase.edu/jeanine.meyer/html 5/build1.html Added video and heart – 5/collagebase.htmlhttp://faculty.purchase.edu/jeanine.meyer/html 5/collagebase.html

Events An event is something that can be detected by the system Event definition involves setting up the event and specifying what is to be done when it occurs. Javascript (and other languages/systems) may treat events differently. Underlying common concepts are –Event definition (setup) –Specification of event handler

HTML with JavaScript events Clicking on button set up using element or element. Clicking on link (set up using element) addEventListener for event on an object, such as a element. For slide show: Passage of interval of time (set up using setInterval and turned off by clearInterval)

Application state State of the game May or may not be visible on screen Example: –dice game: first throw or follow-up throw –slide show: which slide –Will show: bouncing ball: current position of ball and current deltas (xa and ya) –Minesweeper: where the mines are and which cells have been examined –?

Implementation of application state Use [internal] variables Use values in visible html elements, such as form input values.

Advice Review YOUR programs and use the computer programming jargon to describe YOUR code. Review previous lectures.

Virtual dog Done with older HTML. Many places for improvement. – 3.htmlhttp://faculty.purchase.edu/jeanine.meyer/pet 3.html See tutorial / notes: – virtualpetjs.dochttp://faculty.purchase.edu/jeanine.meyer/ virtualpetjs.doc

Virtual dog Has states that correspond to –different image files put in the img element. –Form input fields used to indicate information. There is a weight variable that goes up and down. There is a stochastic (random) factor in the dog wagging its tail (displaying an animated gif) or snarling (displaying the mean image) –calculation also uses times since last fed There is a timed event that decrements the weight and uses an if statement to determine a new state.

Homework Plan your virtual something. (Step away from the computer.) Decide what you want to do. –Decide on states, state variables, conditions. –Write out to show next class. –THEN (and only then) study code and tutorial. You also can make use of canvas for drawing. Note: I did my Virtual Dog before HTML5. You can make use of canvas –But wait to use video, audio, for final project.