Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle. 1.

Slides:



Advertisements
Similar presentations
HTML Basics Customizing your site using the basics of HTML.
Advertisements

Bring Life to Your Web Pages with JavaScript and HTML5 Part 2 Ole Ildsgaard Hougaard -
HTML5 Examples drawing on canvas (paths, text, video), mouse events, timed events, objects, semantic elements, etc. Jeanine Meyer Purchase College/SUNY.
Building Memory… Day 7 – April 18, Mouse Listener Attached listeners to each card (but the back image only) When click event is generated, simply.
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.
HTML, HTML5 Canvas, JavaScript PART 3 LOOKING MORE CLOSELY AT FULL BLOWN GAME DESIGN A PATTERNED BACKGROUND (CREATED WTIH LOOPS) WITH A MOVING OBJECT CHALLENGES.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
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)
Unit 1 – Improving Productivity Instructions ~ 100 words per box.
HTML, Third Edition--Illustrated Brief 1 HTML, Third Edition Illustrated Brief Unit D Adding Graphics and Multimedia.
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.]
Homework: New coin toss. [Start dice game.]
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…)
Creating Buttons – Lesson 51 Creating Buttons Lesson 5.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
Things you should have with you: Your own address Student addresses Ideas that you want to include.
Creating User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
Programming Games Reprise on drawing on canvas. Jargon (concepts): objects. Demonstrate slingshot. Mouse events. Work on your cannonball. Homework: Finish.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle.
Highly Confidential – for UCRE Affiliate Use Only 2015 Regional Training Embedding Maps into your listings on your United Country office website.
Programming games Problems. Schedule Various examples. Homework: rps, bo (don't go back to do this), cannonball, Video or Audio should be complete. Now.
USING WORDPRESS TO CREATE A WEBSITE (RATHER THAN A BLOG) STEP-BY-STEP INSTRUCTIONS.
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.
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.
School of Computing and Information Systems RIA Animation, part I.
Programming games Reprise on credit cards. Operators. Homework: Catch-up. Work on your JavaScript project.
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 More class examples. Paths. Jigsaw. Tolerance. Classwork/homework: Your class project. Post proposal for midterm project.
Time to upload Virtual something.
Start your Free Weebly Site with a User Name, Password, and address.
Programming Games Reprise Credit Cards! Reprise Binary. Overall time limit, setTimeout Homework: [Show virtual something.] Make proposal as reply to my.
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.
Creating Databases Example using Google Maps API + file creation. Dollar sign problem. Classwork/Homework: [catch up]. Work on final project.
HTML5 ProgLan HTML5 Making a Game on the Canvas Part 1.
That Gauge is COOL! 
CUS POWERPOINT PRESENTATION
Chapter 4: HTML5 Media - <video> & <audio>
Adding a File to a Course
Pronoun Prezi Presentation
Prezi.
Adding Assignments and Learning Units to Your TSS Course
BYU China Teacher Training 2015
Programming Games Mouse position. Examples. Review for final quiz.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Inserting Pictures and Symbols in Word documents
Arrays
Programming games Classes and objects (used for Jigsaw, Bouncing stuff, other projects) Homework: Complete cannonball. Video or Audio. Your own project.
Tutorial 10: Programming with javascript
Catchup. Work on project.
Creating User Interfaces
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:
Develop Your Web Presence Using WEEBLY
The Iterative Design Recipe
Show your animation project. HTML5 video. Miro.
Programming games Reprise on dice game and alternative dice game
Presentation transcript:

Programming Games [Show Google Maps project.] Demonstrate more examples. Classwork/Homework: Decide on final project. Post proposal to moodle. 1

Demonstrate Examples http://faculty.purchase.edu/jeanine.meyer/html5pro jects.html Family Collage (may need re-load to get all photos. Extra credit to fix!): http://faculty.purchase.edu/jeanine.meyer/html5/bu ildfamily.html 2

Add videos First attempt Add new object type: Videoblock. Control overlays using globalCompositeOperator and globalAlpha Control volume Use setInterval for calls to drawstuff http://faculty.purchase.edu/jeanine.meyer/mediamash/mov evideos.html Second attempt at Collage with addition of videos http://faculty.purchase.edu/jeanine.meyer/html5/collagebas e.html Uses external file to hold information on media items.

ALERT Chrome browser changed what video formats it used since last offering of course. The fix was to change ORDER of the source elements within the video element, making webm option first!

Lesson Sometimes doing something general is easier than doing something specific… I did this for the family collage.

Objects Programming concept Informal definition: an object is something with properties (aka attributes) and methods (functions) One of the methods is the constructor method that builds an instance of the object Recall: Date(), also map = new google.maps.Map(...);

Programmer created objects Write constructor functions for Rect, Oval, Picture, Heart This is my coding Write code to determine when mouse is over an object Write code to draw the object Write code to create specific rectangles, ovals, heart 7

In init function var r1 = new Rect(2,10,50,50,"red"); var s1 = new Rect(60,10, 50,50,"blue"); var oval1 = new Oval(200,30,20,2.0,1.0, "teal"); var cir1 = new Oval(300,30,20,1.0,1.0,"purple"); var dad = new Image(); dad.src = "daniel1.jpg"; … var pic1 = new Picture(10,100,100,100,dad); var heart1 = new Heart(510,30,60,20,"pink"); stuff.push(pic1); stuff.push(pic2); stuff.push(pic3); stuff.push(pic4); stuff.push(pic5); stuff.push(r1); stuff.push(s1); stuff.push(oval1); stuff.push(cir1); stuff.push(heart1); drawstuff(); 8

Features Drag objects (images, drawings) Create new objects Critical events: mouse down, mouse move, mouse up Create new objects Critical event: double click 9

In init function function init() { canvas1 = document.getElementById('canvas'); canvas1.onmousedown = function () { return false; } canvas1.addEventListener('dblclick',makenewitem,false); canvas1.addEventListener('mousedown',startdragging,false); ctx = canvas1.getContext("2d"); … 10

function startdragging(ev) { var mx; var my; if ( ev.layerX || ev.layerX == 0) { // Firefox, ??? mx= ev.layerX; my = ev.layerY; } else if (ev.offsetX || ev.offsetX == 0) { mx = ev.offsetX; my = ev.offsetY; } var endpt = stuff.length-1; for (var i=endpt;i>=0;i--) { if (stuff[i].overcheck(mx,my)) { offsetx = mx-stuff[i].x; offsety = my-stuff[i].y; var item = stuff[i]; thingInMotion = stuff.length-1; stuff.splice(i,1); stuff.push(item); canvas1.style.cursor = "pointer"; canvas1.addEventListener('mousemove',moveit,false); canvas1.addEventListener('mouseup',dropit,false); break; } } } 11

function makenewitem(ev) { var mx; var my; if ( ev.layerX || ev.layerX == 0) { mx= ev.layerX; my = ev.layerY; } else if (ev.offsetX || ev.offsetX == 0) { mx = ev.offsetX; my = ev.offsetY; } var endpt = stuff.length-1; var item; for (var i=endpt;i>=0;i--) { if (stuff[i].overcheck(mx,my)) { item = clone(stuff[i]); item.x +=20; item.y += 20; stuff.push(item); break; } } drawstuff(); } 12

Examples http://faculty.purchase.edu/jeanine.meyer/html5/html5expla in.html Scroll down to memory examples. Compare! Polygons and pictures Note: needed to fix problem in one of the photos examples: the last pair didn't go away! Important feature was insert of pause, so player could see the result before "flip back" or remove pair. Why do I put "flip back" in quotes? 13

Drawing polygons Create programmer-defined (me!) object called Polycard Defining characteristics are x,y,radius,number of sides 14

function Polycard(sx,sy,rad,n) { this.sx = sx; this.sy = sy; this.rad = rad; this.draw = drawpoly; this.n = n; this.angle = (2*Math.PI)/n; this.moveit = generalmove; } 15

Draw using method named drawpoly Objects have data (attributes, properties) and code (methods) The this refers to the object, so this.sx, this.sy, this.rad and this.angle is the stored data. 16

Recall side sin(angle)*side angle cos(angle)*side 17

Use of this in code In my program for drawing a specific polygon p.drawpoly(); Then this.angle, this.rad, this.sx, etc., will refer to the angle, rad, sx, etc. properties of THIS polygon. These are benefits of object oriented programming: bringing together code and data. 18

ctx.fillStyle=polycolor; var i; var rad = this.rad; function drawpoly() { ctx.fillStyle= frontbgcolor; ctx.strokeStyle=backcolor; ctx.fillRect(this.sx-2*this.rad,this.sy- 2*this.rad,4*this.rad,4*this.rad); ctx.beginPath(); ctx.fillStyle=polycolor; var i; var rad = this.rad; ctx.strokeRect(this.sx,this.sy,4,4); ctx.moveTo(this.sx+rad*Math.cos(- .5*this.angle),this.sy+rad*Math.sin(-.5*this.angle)); for (i=1;i<this.n;i++) { ctx.lineTo(this.sx+rad*Math.cos((i- .5)*this.angle),this.sy+rad*Math.sin((i-.5)*this.angle)); } ctx.fill(); } 19

Examples Many more available online: http://faculty.purchase.edu/jeanine.meyer/morehtml5examples.html Many more available online: Remember: you don't read this like poetry.... Scan. Look at functions defined. Look at body. Scan… BUT: the html document—the program—must have the proper structure. Be VERY careful when copy- and-pasting code. 20

Classwork/homework Catch up Decide on final project Post proposal bouncing ball, cannonball, 2 video, 2 Google Maps (Move on even if you haven't finished cannonball!) Decide on final project Post proposal Start final project. Have something to show. Ask for help. Show complete final project. 21