Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. 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.
Programming games More drawing. Text. Radian measure. Faces. Homework: Do your own drawings. Create index.html file. Upload work.
 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.
Computer Science 103 Chapter 4 Advanced JavaScript.
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.
1 Events Lect 8. 2 Event-driven Pages one popular feature of the Web is its interactive nature e.g., you click on buttons to make windows appear e.g.,
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.
Creative Commons Attribution 3.0 creativecommons.org/licenses/by/3.0 Key Abstractions in Game Maker Foundations of Interactive Game Design Prof. Jim Whitehead.
Introduction to TouchDevelop
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 Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Programming Games Basic HTML5 audio example. Catch-up. Work on basic video. Homework: Complete basic video.
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 Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
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!
AD 305 Electronic Visualization I : School of Art and Design : University of Illinois at Chicago : Spring 2007 Intro to Action Script 9 "The games of a.
Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle.
Programming games HTML/JavaScript basics Functions, events, forms Classwork: [Show favorite sites.] Coin toss. Homework: GET WEB SPACE. Complete coin toss.
© 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.
AD 206 Intermediate CG : School of Art and Design : University of Illinois at Chicago : Spring 2009 Intro to Action Script 9 "The games of a people reveal.
© 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.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
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 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.
Programming games in Visual Basic Review programming & VB topics Insertion sort. Best times. Generate questions & answer patterns for quiz Lab/Homework:
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.
JavaScript II ECT 270 Robin Burke. Outline Functions Events and event handling Form validation.
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.
HTML 5 (Part 1) – Start from SCRATCH. HTML 5 – Start from SCRATCH.
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?
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.
Functions, Regular expressions and Events
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.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on animation project. Homework: Finish.
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
JavaScript – Let’s Draw!
Presentation transcript:

Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish your cannonball. 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()

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.getConte xt(‘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! html5/slingshot1.htmlhttp://faculty.purchase.edu/jeanine.meyer/ html5/slingshot1.html

Mouse events on canvas mousedown –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"] Give code AND give online source (URL and type of source)

Classwork / homework Catch up –Uploading work, updating index.html. Finish your cannonball. (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. Teasers: – lhttp://faculty.purchase.edu/jeanine.meyer/html5/playblrrotated.htm l – mlhttp://faculty.purchase.edu/jeanine.meyer/html5/movingpictures.ht ml – e.htmlhttp://faculty.purchase.edu/jeanine.meyer/html5/jigsaw/jigsawdanc e.html – –More: ml ml