Programming games Recap. Upload work (Filezilla, index.html). Drawing lines. Drawing stars. Homework: Drawing exercises.

Slides:



Advertisements
Similar presentations
Javascript It’s not JAVA. What do these all have in common?
Advertisements

COM311H Zheng, School of C&M, UUJ1 Dynamic Web Authoring JavaScript Basics (Array and Function)
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.
Programming games Reprise on dice game and alternative dice game Homework: [Catch up.]. Finish dice game.
Web Page Development Identify elements of a Web Page Start Notepad
Assignment 1 Pointers ● Be sure to use all tags properly – Don't use a tag for something it wasn't designed for – Ex. Do not use heading tags... for regular.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
Chapter 1 Getting Started With Dreamweaver. Explore the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
MATLAB FUNDAMENTALS: INPUT/OUTPUT LOGIC CONTROL STRUCTURES HP 101 – MATLAB Wednesday, 9/24/2014
Explanation of Web 6, Web 7 and Web 9 at my site Please be sure to bring up the speaker notes for the explanation Intro - Web 6, Web 7 and Web 9.
Programming Games Computer science big ideas. Computer Science jargon. Show virtual dog Homework: [Catch up: dice game, credit card or other form.] Plan.
Create Interfaces College exercise. Continue HTML5: HTML5 logo, drawing images. Coin toss. Homework: acquire video & audio.
Homework: Finish dice game.
Javascript: More features B. Ramamurthy 7/4/2014B. Ramamurthy, CSE651C1.
Getting Started with Canvas IDIA Spring 2013 Bridget M. Blodgett.
Programming games Reprise: coin toss on canvas. Dice game rules. Global and local variables. Homework: [Catch up. Upload projects, including index.html.]
Creating Tables in a Web Site
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Homework: New coin toss. [Start dice game.]
Creating Interfaces Defining users. College exercise. HTML5 drawing. Homework: Post or make comment on other postings on reflection on college exercise.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Element. The element Used to dynamically draw graphics using javascript. Capable of drawing paths, circles, rectangles, text, and images.
Unit 3 Day 6 FOCS – Web Design. Journal Unit #3 Entry #4 Write the source code that would make the following display on a rendered page: Shopping List.
Programming Games Show project. Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Homework: Do your own.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 7 The Game Loop and Animation Starting Out with Games & Graphics.
DHTML AND JAVASCRIPT Genetic Computer School LESSON 5 INTRODUCTION JAVASCRIPT G H E F.
Definition CSS “Short for Cascading Style Sheets, a new feature being added to HTML that gives both Web site developers and users more control over how.
Creating User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
Programming games Show shaking screen, quiz show. Calculations Homework: (Finish basic Javascript Projects) Make proposal. Work on project.
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.
Lesson Two: Everything You Need to Know
Chapter 1 Getting Started With Dreamweaver. Exploring the Dreamweaver Workspace The Dreamweaver workspace is where you can find all the tools to create.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
Computer Science I Recap: variables & functions. Images. Pseudo-random processing.
Programming games Review concepts. Crooked coin toss. Drawing on canvas. Homework: Complete [static] drawings. Upload files to website.
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
Creating User Interfaces HTML5 video & audio. Role of video and audio. Homework: Complete your own [small/simple] HTML5 video and audio projects.
Creating Web Documents: JavaScript Ftp / file management: review Introduction to JavaScript Sources Homework: start review for midterm, work on Project.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
Understanding JavaScript and Coding Essentials Lesson 8.
IN THIS LESSON, WE WILL BECOME FAMILIAR WITH HTML AND BEGIN CREATING A WEB PAGE IN YOUR COMPUTER HTML – the foundation.
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.
HTML Review * is used as a reference for most of the notes in this powerpoint.
Programming Games Show slide show (on your site). Bouncing something. Video element. Bouncing video element. Bouncing video drawn on canvas. Bouncing video.
CSS IS A LANGUAGE DESIGNED TO TARGET HTML ELEMENTS AND NODES BY TYPE, CLASS, ID AND VALUE, AND CHANGE THEIR VALUES CSS – change how your HTML looks and.
JavaScript Errors and Debugging Web Design Sec 6-3 Part or all of this lesson was adapted from the University of Washington’s “Web Design & Development.
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.
Programming games HTML/JavaScript basics Functions, events, forms
What is a Function Expression?
Programming Games Work / finish and show dice game. Extras. Timed events. ftp. index file. Homework: Catch up and do slide show.
Programming Games Computer science big ideas and Computer Science jargon: review of things we have used in examples. Show virtual dog Homework: [Catch.
Console.
Drawing Graphics in JavaScript
Context of what we are doing.
Programming games Share your plans for your virtual something.
Catchup. Work on project.
Programming Games Refresher on coordinates. Scaling, translation. HTML5 logo. Refresher on animation. Bouncing ball. Show project. Classwork/Homework:
CIS 136 Building Mobile Apps
Web Programming and Design
JavaScript – Let’s Draw!
Programming games Reprise on dice game and alternative dice game
Presentation transcript:

Programming games Recap. Upload work (Filezilla, index.html). Drawing lines. Drawing stars. Homework: Drawing exercises.

Recap Drawing done using what is termed the 2d context of the canvas element. My code sets a variable called ctx. This is my name. Can draw filled-in rectangles or outlines of rectangles Can draw paths, including arcs. The fill and stroke calls close the path. Also, can close a path with closePath() NOTE: can draw non-circular ovals using transformations: scale. Check out the hangman game in book! Using variables makes code more flexible and easier to see relationships.

Uploading work Please upload all your work to your students.purchase.edu website. Use filezilla (or equivalent) ftp (file transfer protocol) program to upload and download work. Create a pg (or games or programminggames) folder. In that folder, create an index.html file with links to your work.

index.html Games My favorite sites Fair coin toss and Weighted coin …

More on index.html Can make as fancy as you wish. Can use and style Caution: you do need to upload all the image files. You do need to use the correct names. Make file names simple: no spaces, no special symbols.

Reminder You may use your web space as storage space for incomplete work. Someone can look at it, but only if they know the name.

Coordinate system Keep in mind that drawing requires attention to the coordinate system of the canvas. The coordinate system is upside down! That is, vertical values start with zero at the top and get bigger moving DOWN the screen. Each point on the screen requires 2 numbers: a horizontal (x) number and a vertical (y) number.

Exercises This draws one triangle. See if you can draw a different triangle somewhere else on the screen, say the lower right corner. This draws 2 triangles. See if you can draw two different triangles. Again, change this example. Draw 3 triangles. Draw other combinations of lines. This draws two filled triangles. Change the triangle dimensions, location on the screen, AND color. There are 16 named colors. You can look at the rectangles example to see other ways to set the color. Remember there is a color for the stroke and for the fill. This draws triangles using fill and stroke. Experiment with the order of the fill and stroke, the color (change the strokeStyle and the fillStyle and the lineWidth). This draws a figure. Experiment with this. Maybe you don’t want the body to be a triangle but something else. You also can use the methods you learned in the drawing rectangle and drawing smile-y and frown-y faces. Review those examples now!

Next drawing: star For drawing lines (and arcs), think of moving a pencil versus drawing (preparing to draw) a line segment –nothing is drawn until the stroke or fill Use an array with coordinates for 5 points Use an array to hold names of 3 colors button element html5workshop/wkshopdrawingstars.htmlhttp://faculty.purchase.edu/jeanine.meyer/ html5workshop/wkshopdrawingstars.html

opening screen

after 1 st press of button

after next press

show body first Your browser doesn't support the HTML5 element canvas. Make Star

variables (in script element) var ctx; var pts=[//5 points for star: rough drawing [100,35], [60,10], [20,35], [35,100], [85,100] ]; var colors=["red","white","blue"]; //used in succession var c=0;// points to next color

variables (in script element) var ctx; var pts=[//5 points for star: rough drawing [100,35], [60,10], [20,35], [35,100], [85,100] ]; var colors=["red","white","blue"]; //used in succession var c=0;// points to next color

variables (in script element) var ctx; var pts=[//5 points for star: rough drawing [100,35], [60,10], [20,35], [35,100], [85,100] ]; var colors=["red","white","blue"]; //used in succession var c=0;// points to next color

variables (in script element) var ctx; var pts=[//5 points for star: rough drawing [100,35], [60,10], [20,35], [35,100], [85,100] ]; var colors=["red","white","blue"]; //used in succession var c=0;// points to next color

variables (in script element) var ctx; var pts=[//5 points for star: rough drawing [100,35], [60,10], [20,35], [35,100], [85,100] ]; var colors=["red","white","blue"]; //used in succession var c=0;// points to next color

function init() { ctx = document.getElementById('canvas').getContext('2d'); } function makestar() { ctx.clearRect(0,0,600,400); ctx.fillStyle=colors[c]; c = c +1; // can reduce to one line using colors[c++] c = (c<3)?c:0; ctx.beginPath(); ctx.moveTo(pts[0][0],pts[0][1]); ctx.lineTo(pts[3][0],pts[3][1]); ctx.lineTo(pts[1][0],pts[1][1]); ctx.lineTo(pts[4][0],pts[4][1]); ctx.lineTo(pts[2][0],pts[2][1]); ctx.lineTo(pts[0][0],pts[0][1]); ctx.stroke(); //outline (necessary for white star! ctx.fill(); }

Assignment Use what you have learned: drawing rectangles and paths –a path can include arcs and lines. Try stroke and fill Can include multiple moveTo –think of picking up your pen and moving to a new spot on the paper/canvas.

HTML with JavaScript The statement: return false; is necessary [sometimes] to prevent the browser from refreshing the screen, which would restore the original images.

Watch out Spelling of HTML & javascript tags and commands must be correct. You must save the file as filename.html –For the name: all one word, lowercase. –Make sure you are saving as.html –remember where you are saving it same folder/directory as any images. Your names must be consistent. –You can spell how you like. Punctuation (called syntax) must be correct –Missing quotation marks and missing or misplaced brackets matter. Image files must really be of indicated type. Be careful of large images pushing button off-screen. Anything else??????

Names File names, variable names, function names Simple, short, but clear enough for you to remember Consistency helps –NOT: head.gif, tails.gif Einstein said: explanations / theories "should be as simple as possible, but no simpler."

Debugging Make sure you are testing latest version –you can make a small visible change Insert alert statements alert("at start of toss function"); alert("xxx is "+xxx); NOTE: if a function is not well-formed (for example, bracket problem), the browser does not display a message—it just doesn't work! Firefox: Tools/Error console Chrome: wench symbol/Tools/JavaScript Console

Debugging In TextWrangler (PC: TextPad) use Find command –Check if dthrow defined AND called –Check on consistent spelling of names –Can use for brackets, closing, etc. though you may need to print out and use pencil. Also use opening and closing….

For curiousity Try: xxx = Math.random(); alert("xxx is " + xxx); Remember two meanings of + (operator overloading)

JavaScript if & if/else if ( logicalexpression ) { statements } if ( logicalexpression ) { statements } else { statements }

Switch statement switch (expression) { case value1: statements case value2: statements default: statements } If you do NOT want execution to continue (flow into) the next case, you need to insert a break statement. optional

Notation { and } are used to group statements together –function definition, if and else clauses, and other statements we haven't done yet: switch, for, do while. ( and ) are used –condition part of an if statement if (Math.random()>.5) –set order of operations in a calculation total = total + (total*taxrate); –specify arguments in a function definition and parameters in a function call Math.random()

Homework Continue with drawings The next game will be the dice game (craps).