Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on animation project. Homework: Finish.

Slides:



Advertisements
Similar presentations
IS660Z Programming Games Using Visual Basic Overview of Cannonball.
Advertisements

Visual Basic: ballistics
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Microsoft® Small Basic Advanced Games Estimated time to complete this lesson: 1 hour.
Programming games Classwork: Show Favorite Sites. Show coin toss. Review concepts. Crooked coin toss. Homework: Complete coin toss examples. Upload files.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 18 – Macromedia Flash MX 2004: Building an Interactive Game Outline 18.1 Introduction 18.2 Object-Oriented.
CIS101 Introduction to Computing Week 10 Spring 2004.
CIS101 Introduction to Computing Week 10. Agenda Your questions Final exam and final project CIS101 Student Survey Class presentations: Your Mad Libs.
Chapter 9 Introduction to the Document Object Model (DOM) JavaScript, Third Edition.
GAME:IT Junior Bouncing Ball Objectives: Create Sprites Create Sounds Create Objects Create Room Program simple game.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Programming games Flash drawing trick(s). Rock paper scissors. Classwork: Complete rock paper scissors.
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
AIM: How can we describe the path of an object fired horizontally from a height above the ground? DO NOW: A ball rolls off a table top with an initial.
Programming Games Basic HTML5 audio example. Catch-up. Work on basic video. Homework: Complete basic video.
Programming Games Show your cannonball. HTML5 video. Miro. Classwork/Homework: Acquire video, convert to multiple formats, and produce simple (just html)
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 Simulated ballistic motion: cannon ball. Classwork: Final day for midterm project and all projects for first part of class. Homework:
Programming Games Show your simple video. More video examples. Audio. Classwork/Homework: Produce more complex video program.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Programming games Flash drawing trick(s). Past due: Your completion of rock-paper-scissors) Classwork: Bouncing ball: read tutorial. Start coding.
Programming games Reflection Bouncing things, Memory Server-side: Survey. ActionScript 2 examples. Homework: Finish Video or Audio. Post proposal for your.
Programming games Examples. Classwork: work and show something of your final project. Homework: (finish…)
Programming games Show your version of Bo the dog. Start cannonball Preview: video, audio work session (cannonball) Homework: Cannonball with ball in a.
Programming Games Preview Video & Audio. Work on cannonball. Homework: finish cannonball!
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 21 - “Cat and Mouse” Painter Application.
Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now.
© 2011 Delmar, Cengage Learning Chapter 10 Using ActionScript to Enhance User Experience.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
Programming games Cannonball due. Drawing & printing example. Acquiring video or sound Homework: Catch up: complete projects (rps, Bo, cb). Start video.
Computer Game Design ActionScript is… Object-oriented programming Everything you do in ActionScript does something to some object* Some objects.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Programming Games Show your rock-paper-scissors. Demonstrate bouncing ball. Demonstrate and examine Bo the dog. Homework: Modify Bo to make your own.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
Creating User Interfaces HTML5 video & audio. Role of video and audio. Homework: Complete your own [small/simple] HTML5 video and audio projects.
Computer Science I Share plans for virtual something. Text. Show my virtual dog. Classwork: Plans for your virtual something. Homework: start implementation.
School of Computing and Information Systems RIA Animation, part I.
Programming Games Reprise: credit cards. Show video projects. Demonstrate Find Daniel and Virtual Dog. Homework: [Catch up.] Post proposal for your JavaScript.
Programming Games Show slide show (on your site). Bouncing something. Video element. Bouncing video element. Bouncing video drawn on canvas. Bouncing video.
Computer Science I Animations. Bouncing ball. The if statement. Classwork/homework: bouncing something. Compress and upload work to Moodle.
Computer Science I Slingshot example. ProcessingJS example. Review for midterm quiz. Classwork/Homework: study for midterm. Work on midterm project.
Time to upload Virtual something.
Chapter 6 © 2003 by Addison-Wesley, Inc Introduction - Dynamic HTML is not a new markup language - A dynamic HTML document is one whose tag attributes,
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Programming games Show work on site. Work on slide show. Timed event for bouncing ball. Homework: [Finish slide show and upload to site.] Acquire a short.
What is a Function Expression?
MOM! Phineas and Ferb are … Aims:
JavaScript Forms Adding User Input.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle. 1.
ISC440: Web Programming II Ch14: HTML5 Canvas
Agenda (10/15) Pick-up guided notes (on front table)
Functions, Regular expressions and Events
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Web Design and Development
Context of what we are doing.
Recognizing JavaScript Features
Programming games Demonstrate cannonball
Programming games Share your plans for your virtual something.
Catchup. Work on project.
Creating User Interfaces
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
Web Programming and Design
Web Programming and Design
JavaScript – Let’s Draw!
Presentation transcript:

Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on animation project. Homework: Finish your animation project. Acquire video clip.

Programming jargon: objects Objects are members of classes. Objects come with Properties (aka attributes). These are values Methods. These are functions. Examples: slides.length (read-only property), ctx.fillStyle document.write(…); canvas1.addEventListener(…) There also are class properties & methods: Math.PI Math.random()

JavaScript Constructor function MyThing (x, y, w, h, pic) { this.xp = x; this.yp = y; this.wp = w; this.wh = h; this.imagefile = pic; this.display = showpicture; this.move = moveThing; }

function showpicture() { ctx.drawImage(this.imagefile, this.xp, this.yp, this.wp, this.hp); } function moveThing (dx, dy) { this.xp = this.xp + dx; this.yp = this.yp + dy;

Usage firstThing = new myThing(10,20,100,100,”Annika.jpg”); firstThing.display(); firstThing.move(5,10);

Example http://faculty.purchase.edu/jeanine.meyer/html5/buildfamily.html http://faculty.purchase.edu/jeanine.meyer/html5/collagebase.html More coming….

Class properties & functions Are NOT associated with any specific object.

What is ‘this’? In JavaScript, and in some other programming languages, the programmer can create an object. You see this in my cannonball, collage, other examples. The properties and methods are accessed using the dot notation and the use of the term this. The properties and methods are set using a declaration with the term new and then a function with use of the term this.

Drawing on [a] canvas Screen (canvas) coordinates Absolute numbers Variables Expressions Remember: canvas methods are done to a canvas context: ctx = document.getElementById(‘mycanvas’).document.getContext(‘2d’);

Drawing, cont. To draw at a position known ahead of time ctx.fillRect(100,150,50,60); To draw at a position defined by variables, with dimensions defined by variables, with a color defined by variables: ctx.fillStyle = mycolor; ctx.fillRect(x,y,w,h); fillStyle is a property of context objects and fillRect is a method of context objects.

Events Events and event handling are featured in many programming languages but the exact methods differ. HTML and JavaScript provide event handling in multiple ways: setInterval and setTimeout for timing events Setting attributes in HTML tags for various events including: onload, onsubmit, onclick, onMouseover, onmouseout, etc. Using addEventListener for various things canvas1.addEventListener(‘click’,toss,false);

Reflecting on bouncing ball Bouncing something Use setInterval to set up event/event handling for timing event. This sets up calls to a function that will calculate a new position using two variables (aka displacement values, horizontal and vertical velocities) and draw the item. Also calculates (by another function) if item hits a wall and changes the variables so the NEXT iteration moves away from the wall.

Reflecting on cannonball [First, go through sequence of examples.] Cannonball uses form input to set displacement variables AND orient cannon. The fire function uses setInterval to set up event/event handling: call to function that will do the re-positioning of the ball AND checking for collisions of ball with target and with ground.

Your cannonball Do progression of examples. You can change cannon or ball or target or ground You can add a second target. ???? Remember: you also can wait to do something more elaborate for your final project. Including adding video and/or audio

Look at cannonball source The possible things to be drawn include balls, pictures and rectangles. Each object class has its own draw method set. Each object class has its own set of properties. Look at the drawall function. Look at the Ball, Picture, Myrectangle functions. These are called constructor functions.

Slingshot Built on cannonball, but using different events! Mouse down on the ball Actually, mouse down on the canvas is detected and code determines whether or not it is on the ball (rock). Mouse move: movement of mouse is detected and this causes the sling shot coordinates to change Mouse up: release of mouse button is detected and code calculated trajectory and fires off the ball (rock)

slingshot Based on cannonball but… different graphics Player (user) affordance (fancy way of saying move or action) is based on [simulation of] pulling back on slingshot. Needs improvement! http://faculty.purchase.edu/jeanine.meyer/html5/slingshot1.html

Mouse events on canvas mousedown mousemove mouseup need to determine if mouse on the ball (rock) mousemove move rock and re-draw sling mouseup calculate angle and velocity based on (my formulas) simulation of slingshot physics needs improvement. These are all set up using the addEventListener method.

Note I have never seen Angry Chickens. This is based on cannonball, which, in turn, is based on bouncing ball, which …

Preview… There are more array operations, also called methods. If a is an array a.indexOf(b) a.join(“+”); a.push(item); a.slice(….); a.splice(…); More To learn: search on JavaScript array operations or JavaScript array methods. WRITE THESE DOWN IN YOUR NOTES.

Pop quiz Using JavaScript, how do you replace the first instance of a specific item in an array with 2 other items? For example, if “potatoes” in an element in the array items, remove it and replace it with “rice”, “beans”. So ["milk","OJ", "potatoes", "onion", "napkins"] becomes ["milk","OJ", "rice", "beans", "onion","napkins"] Hint: look at previous chart. Give code AND give online source (URL and type of source) Hint: indexOf and splice

Classwork / homework Teaser: Catch up Uploading work, updating index.html. Finish your animation project. (Skip if you are finishing bb today). We start video & audio next week. Acquire a short video, MOV or avi format, to use in class. Teaser: http://faculty.purchase.edu/jeanine.meyer/html5/monkeybars.html More: http://faculty.purchase.edu/jeanine.meyer/morehtml5examples.html