Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your.

Slides:



Advertisements
Similar presentations
Data Representation. Units & Prefixes Review kilo, mega, and giga are different in binary! bit (b) – binary digit Byte (B) – 8 binary digits KiloByte.
Advertisements

© 2004, Robert K. Moniot Binary and Hex How to count like a computer.
Java Script Session1 INTRODUCTION.
Web Pages and Style Sheets Bert Wachsmuth. HTML versus XHTML XHTML is a stricter version of HTML: HTML + stricter rules = XHTML. XHTML Rule violations:
HTML 5 – GeoLocation and Maps. Geolocation API What is a ”geolocation”…? A geographical location, defined in terms of – Latitude (north/south) – Longitude.
Binary Representation
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)
Information Technology Center Hany Abdelwahab Computer Specialist.
Data Representation Kieran Mathieson. Outline Digital constraints Data types Integer Real Character Boolean Memory address.
Chapter 2 Data Types, Declarations, and Displays
CHAPTER 26 CREATING LOCATION-AWARE WEBPAGES USING GEOLOCATION.
Connecting with Computer Science 2 Objectives Learn why numbering systems are important to understand Refresh your knowledge of powers of numbers Learn.
1 Introduction to HTML5. 2 Introductions –Lecture is based on the book: –The Essential Guide to HTML5: Using Games to learn HTML5 & JavaScript.
CHAP 4. GEOLOCATION API.  You can request users to share their location and, if they agree, you can provide them with instructions on how to get to a.
Binary Numbers. Why Binary? Maximal distinction among values  minimal corruption from noise Imagine taking the same physical attribute of a circuit,
Computers Organization & Assembly Language
Programming Games Recap on Google Maps. Creating elements. Dynamic creation of elements (multiple video elements). Geolocation. Classwork/Homework: Catch-up.
Programming games Examples: Audio example. Google Maps api. Classwork: show more complex video. Classwork/Homework: Find place (lat and long) for basic.
Google Maps API. Static Maps send an HTTP GET request receive an image (PNG, GIF, JPEG) no javascript needed encode params in URL example:
INTRODUCTION TO HTML5 Geolocation. Display a Specific Location with Google Maps  You can use the Google Maps API to display a custom map on your own.
Programming Games Formulas. Date. Representation in [computer] Storage. Credit Card. Homework: Finish slide show. Upload application.
Representing Data. Representing data u The basic unit of memory is the bit  A transistor that can hold either high or low voltage  Conceptually, a tiny.
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.
Homework: New coin toss. [Start dice game.]
Number Systems CIT Network Math
1 i206: Lecture 2: Computer Architecture, Binary Encodings, and Data Representation Marti Hearst Spring 2012.
The Beauty and Joy of Computing Lecture #3 : Creativity & Abstraction UC Berkeley EECS Lecturer Gerald Friedland.
Introduction to PHP A user navigates in her browser to a page that ends with a.php extension The request is sent to a web server, which directs the request.
Term 2, 2011 Week 1. CONTENTS Problem-solving methodology Programming and scripting languages – Programming languages Programming languages – Scripting.
Creating User Interfaces Recap HTML/HTML5 JavaScript features Homework: keep working on user observation studies. Review JavaScript.
Session: 19. © Aptech Ltd. 2HTML5 Geolocation and APIs / Session 19  Explain geolocation and its use in HTML5  Explain the Google Maps API  Explain.
Creating Web Documents catch-up JavaScript slide show tools redirection.
Variables and Functions Chapter Variables Named storage location in computer’s memory Programs may need to store data when running Types of data.
Programming Games Credit cards. Forms. Homework: Catch up: dice game. Produce your own credit card application or something else making use of a form with.
Creating Interfaces Show form validation examples, Hangman. HTML5 with Google Maps API. Add in localStorage. Design pitfalls. Homework: Make proposal for.
Programming games Context of what we are doing. Drawing on canvas. Homework: [Complete coin toss examples.] Do your own drawings. Upload files to website.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Programming Games Logic. Slide show. Range input. Storage. Datatypes. Binary numbers. Homework: Catch up. This includes uploading projects to your server.
2016 N5 Prelim Revision. HTML Absolute/Relative addressing in HTML.
Computer Science I Storing data. Binary numbers. Classwork/homework: Catch up. Do analysis of image types.
Some Computer Science Conceptual Background Material Doug Hogan This version for UIC Spring 2016 CS 107.
RIA Geo Location. Finding Location modern devices can get location coordinates phones and tablets can use GPS desktops and laptops –often cannot use GPS.
Javascript Basic Concepts Presentation By: Er. Sunny Chanday Lecturer CSE/IT RBIENT.
Information in Computers. Remember Computers Execute algorithms Need to be told what to do And to whom to do it.
Phonegap Bridge –Geolocation and Google maps CIS 136 Building Mobile Apps 1.
Creating Databases Example using Google Maps API + file creation. Dollar sign problem. Classwork/Homework: [catch up]. Work on final project.
1 Bus Tracker A Google Maps Application. 22 Objectives You will be able to Add an icon to a map created with the Google Maps API. Use Ajax techniques.
1 Section 1.3 Binary Number Systems Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Creating Databases Example using Google Maps API + file creation. Dollar sign problem. Classwork/Homework: [catch up]. Work on final project.
Number Systems.
Chapter 8 & 11: Representing Information Digitally
The Beauty and Joy of Computing Lecture #4 : Creativity & Abstraction
“Under the hood”: Angry Birds Maze
Web Services application that operates over a network
JavaScript is a programming language designed for Web pages.
Building a Custom Video Player
Geolocation using Google maps
Introduction to JavaScript
CSS Colors, JavaScript Variables, Conditionals and Basic Methods
WEB PROGRAMMING JavaScript.
Geolocation using Google maps
Javascript Game Assessment
Tutorial 10: Programming with javascript
JavaScript Basics What is JavaScript?
Creating User Interfaces
Geolocation using Google maps
Programming Fundamental-1
ASCII and Unicode.
Presentation transcript:

Programming Games Reprise: storage, datatypes. Geolocation/Google API example. Work session Homework: [Catch up. Upload work. Post proposal.] Work on your game.

Storage Everything (data, instructions) is kept in memory and storage in 1s and 0s. Different data types are stored in different ways –whole numbers: binary. Typically 4 bytes = 32 bits. –numbers with fractions (mixed numbers): floating point –character strings: ASCII (1 byte) or UNICODE (2 bytes) –logical values: Booleans (may be stored in whole byte=8 bit units) Media, e.g., video, audio, images, stored in various ways.

Hexadecimal Base 16 shorter way to express a binary number Use 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F One way to define a color is as (combined) levels of red, green and blue, each one going from 0 to 255. This can be expressed with 3 x 2 hexadecimal symbols. –00 is 0 * * 1 0A is 0 * *1 F0 is 15* *1 FF is 15* *1 = 255

RGB colors You can reason about colors without making any conversions –FF0000 is red –CC00DD is purple –?

Geolocation navigator.geolocation provides current location for the IP address (latitude and longitude) User (on client computer) must confirm that it is okay. Done by interpreting signals from several satellites. GPS systems use that information together with locally stored maps.

Map app Use Google Maps API to bring up map at current location. Respond to clicking by placing a marker and calculating distance. Provide way to change to fixed set of locations or the last marker. need to give permission to Share Location geolocationkm.htmlhttp://faculty.purchase.edu/jeanine.meyer/html5/ geolocationkm.html workshop/geolocationdistance2.htmlhttp://faculty.purchase.edu/jeanine.meyer/html5 workshop/geolocationdistance2.html

Opening screen

Brings up ….

After click on map

After choose CUNY

Mapping Google Maps API (and other applications) defines positions using special latitude/longitude data object Access to Google Map is created for a place in the HTML document, using specified map options HTML has a specification for doing geolocation. –navigator.geolocation produces latitude and longitude values

How to get positions? Google Maps –get to a map Browser location javascript:void(prompt('',gApplication.getMap().get Center())); OR Click on green beaker and enable the drop latlng marker –right click then normal click

Basics if (navigator.geolocation) checks if this object exists. Does NOT cause any errors. map = new google.maps.Map(document.getEle mentById("place"), myOptions); brings up Google Maps in the div with id "place" using the parameters in myOptions.

style, external script header {font-family:Georgia,"Times New Roman",serif; font-size:20px; display:block; }

standalone code if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) {doStuff(position.coords.latitude, position.coords.longitude); }); } else { if (document.getElementById("place")) { document.getElementById("place").innerHTML = "I'm sorry but geolocation services are not supported by your browser"; document.getElementById("place").style.color = "#FF0000"; }

variables var listener; var map; var markersArray =[]; var blatlng; var myOptions; var locations = [ [ , , "CUNY"], [ , ,"Purchase College/SUNY"], [ , ,"IIT"] ];

create/access map function doStuff(mylat, mylong) { blatlng = new google.maps.LatLng(mylat,mylong); myOptions = { zoom: 14, center: blatlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("place"), myOptions); listener = google.maps.event.addListener(map, 'click', function(event) { checkit(event.latLng);}); }

response to click on map function checkit(clatlng) { var distance = dist(clatlng,blatlng); distance = Math.floor((distance+.005)*100)/100; var distanceString = String(distance)+" miles"; marker = new google.maps.Marker({ position: clatlng, title: distanceString, map: map }); markersArray.push(marker); document.getElementById("answer").innerHTML = "The distance from base to most recent marker is "+String(distance) +" miles."; }

distance function function dist(point1, point2) { //spherical law of cosines //var R = 6371; // km var R = 3959; // miles var lat1 = point1.lat()*Math.PI/180; var lat2 = point2.lat()*Math.PI/180 ; var lon1 = point1.lng()*Math.PI/180; var lon2 = point2.lng()*Math.PI/180; var d = Math.acos(Math.sin(lat1)*Math.sin(lat2) + Math.cos(lat1)*Math.cos(lat2) * Math.cos(lon2-lon1)) * R; return d; }

change base using radio buttons function changebase() { for(var i=0;i<locations.length;i++) { if (document.f.loc[i].checked) { doStuff(locations[i][0],locations[i][1]); document.getElementById("header").innerHTML = "Base location is "+locations[i][2]; } return false; }

Base location is your current geolocation Change base location: CUNY Purchase College Illinois Institute of Technology

Work session Make sure you have made a proposal and I have approved it!

Homework [Catch up. Upload projects.] [Post JavaScript project proposal.] Work on project.