Lesson 1: Decomposition

Slides:



Advertisements
Similar presentations
17 HTML, Scripting, and Interactivity Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and.
Advertisements

Information Technology Center Hany Abdelwahab Computer Specialist.
CIS101 Introduction to Computing Week 11. Agenda Your questions Copy and Paste Assignment Practice Test JavaScript: Functions and Selection Lesson 06,
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
 JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user actions and.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
Every week: Sign in at the door If you are new: Fill in Registration Form Ask a Mentor how to get started Make sure you are on the Athenry Parents/Kids.
Javascript and the Web Whys and Hows of Javascript.
Using Dreamweaver. Slide 1 Dreamweaver has 2 screens that do different things The Document window where you create your WebPages The Site window where.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
Intro to JavaScript. Use the tag to tell the browser you are writing JavaScript.
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
 This presentation introduces the following: › 3 types of CSS › CSS syntax › CSS comments › CSS and color › The box model.
Client Side Programming with JavaScript Why use client side programming? Web sides built on CGI programs can rapidly become overly complicated to maintain,
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
 HTML is hypertext markup language. It is a way for people to display their information with more complex pictures and text displays. Before HTML, messages.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
1 JavaScript
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
ECA 225 Applied Interactive Programming1 ECA 225 Applied Online Programming basics.
Fluency with Information Technology INFO100 and CSE100 Katherine Deibel Katherine Deibel, Fluency in Information Technology1.
HTML GUIDE Press F5 and then Click on the links on the left to get to the section you want Section 1: Getting Started Section 2: Moving Banner Section.
Quick Questions 1. What does HTML stand for? 2. What are the three main languages of the Web? 3. What is the purpose of the tags? 4. Why do we indent different.
Photoshop Image Slicing. Reasons to Image Slide To create links out of sliced images To optimise different areas. (flat areas of colour, such as logos,
CSD 340 (Blum)1 Starting JavaScript Homage to the Homage to the Square.
JavaScript Challenges Answers for challenges
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
Spiderman ©Marvel Comics Creating Web Pages (part 1)
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
Introduction to TouchDevelop Lesson 3 – Comments & Lists Created by S. Johnson
CGS 3066: Web Programming and Design Spring 2016 Introduction to JavaScript.
JavaScript JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user.
1 JavaScript and Dynamic Web Pages Lecture 7. 2 Static vs. Dynamic Pages  A Web page uses HTML tags to identify page content and formatting information.
Introducing Scratch Learning resources for the implementation of the scenario
Introduction to.
CGS 3066: Web Programming and Design Spring 2017
Online PD Basic HTML The Magic Of Web Pages
Section 4.1 Section 4.2 Format HTML tags Identify HTML guidelines
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Parts of Chapter 14 Key Concepts
Human Computer Interaction
Microsoft® Office FrontPage® 2003 Training
Intro to JavaScript CS 1150 Spring 2017.
Section 17.1 Section 17.2 Add an audio file using HTML
Computer Programming I
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
HTML.
Section 10.1 YOU WILL LEARN TO… Define scripting
Lesson 1: Buttons and Events – 12/18
A second look at JavaScript
Your 1st Programming Assignment
Introduction to TouchDevelop
WEB PROGRAMMING JavaScript.
Javascript Game Assessment
We are starting to program with JavaScript
INFO/CSE 100, Spring 2005 Fluency in Information Technology
Introduction to TouchDevelop
Teaching slides Chapter 6.
BUILDING A WEBSITE 7.4.2: Basics of HTML and CSS.
Computer communications
Chapter 7 Event-Driven Pages
JavaScript: Introduction to Scripting
Web Programming and Design
Web Programming and Design
Web Programming and Design
Running & Testing :: IDEs
Presentation transcript:

Lesson 1: Decomposition GET YOUR PEN OUT ! Year 9 Build a Javascript game Starter: You have been asked to build a Call of Duty style combat computer game. How would you go about splitting up the task? What parts would you need to consider? Which parts could you give to other people to do? Draw a Spider Diagram to represent the parts

Combat Game – possible decomposition ideas Each one of the tasks could be further and further decomposed into smaller sub-tasks

Decomposition is one of the principles of Computational Thinking Computational Thinking = Thinking like a computer (ie logically) Very useful skill in all parts of life E.g. organising a party Revising for exams Planning a picnic with friends

Decomposition in computer programming… Allows you to tackle large problems in a methodical way The sub tasks are more manageable and easier to understand Let's other developers work on sub tasks of the problem (saving you time) Allows each sub task/sub program to be tested independently to check it works

Lesson 1 - Plan We will be learning a new programming language – Javascript We will use Javascript (as well as HTML & CSS) to build a simple online game Choose the level of difficulty of the game to work with depending on your confidence with programming if you are taking Comp Science next year you have used Javascript before Select a Gold, Silver or Bronze task from the folder W:\Public\ICT & Computing\Year 9\9.6 Javascript\Tasks Read it and make sure you understand what the game is supposed to do Create a new Powerpoint and save it as "My Javascript Game Diary" For your chosen task, create a slide with another spider diagram to divide your task into sub-tasks Imagine you were giving jobs to other workers to complete

Example Decomposition of Magic 8 Ball game User Interface User enters a question User clicks a button Page design should be appealing Game Logic When button pressed, generate random phrase Display random phrase to screen Ask if they want to play again Using Powerpoint "Smart Art Feature"

Building a game in a web page You will need to use HTML to build the framework of the webpage <html> <body> <h1>My fabulous game</h1> <p>This is going to be an awesome game</p> <img src="cat.jpg" width="100"/> </body> </html> What will this page look like?

New online HTML/CSS/Javascript editor Jsbin.com New online HTML/CSS/Javascript editor Result appears here Type HTML here http://jsbin.com/genabujiki/edit?html,output http://jsbin.com/gozawopohi/edit?html,output http://jsbin.com/givawekusa/edit?html,output http://jsbin.com/dewuzoconi/edit?html,output 9A1 Mon 19th Feb 2018 Use File > Save to get a unique URL that you can use Copy and paste this into your Powerpoint NOW!

Two new HTML tags At the moment the button doesn't do anything

What is Javascript? The most popular programming language in the world Lightweight scripting language Runs in your browser Allows interactivity on web pages Animations, popups, validation, calculations, games, Google doodles! Almost all web sites use Javascript No relation to Java!

Event driven Javascript is event driven Runs when Button clicked Image clicked Page is loaded Mouse moved Events can be added to HTML e.g. <img src=“cat.jpg” onclick=“sayMeow()” />

Lines end in a semi-colon ; Javascript Rules Case sensitive Alert() is not the same as alert() Lines end in a semi-colon ; Quotes matter – make sure that you have pairs of matching “ ”

Lesson 2 – Working with Javascript Variables & the Document True or False Javascript can create animations Javascript is not case sensitive Javascript can run in your browser Javascript lines end in colons : Javascript is used on almost every web site TRUE FALSE TRUE FALSE https://codepen.io/tholman/pen/jvIEz?page=1& TRUE COOL JavaScript Examples https://codepen.io/jackrugile/pen/acAgx?page=3 https://codepen.io/tholman/pen/jvIEz?page=1& https://codepen.io/jackrugile/pen/Drykf?page=2

Using the alert()function This will create a pop up Change <button>Click Me!</button> to <button onclick="alert('hello')">Click Me!</button> screenshot your work! Now click the button and a pop up appears Change the message to something else

Debugging errors Javascript errors can be tricky to track down Use F12 on a web page to show the Console Or in JSBIN there is a console button This tells me I’ve spelled “alert” wrong!

Using the prompt()function This will create a pop up which asks the user a question Change the button to <button onclick="prompt('What is your name?')">Click Me!</button> Now click the button and a prompt box appears Change the message to something else

Creating a Javascript function At the moment the Javascript is being written inline with the HTML This will get confusing when we start to write longer programs Creating a block of code called a function allows us to separate the Javascript out to make it easier to manage In JSBin we need to show the Javascript tab:

Creating and running a function STEP 1: Define the function Love Tester Demo: http://jsbin.com/nihivaxuko/1/edit?html,css,output STEP 2: Run the function

Using variables in JavaScript Use the var keyword when you first set up a variable You can stick variables and text together (concatenate) using a + sign Variable names… -Must be one word -Can't start with a number -no punctuation

Task: Practice creating and running a function Add a function with a couple of alerts and a prompt to ask the user a question (This is practice – and doesn't have to be part of your final game) STEP 1: Define the function screenshot your work! STEP 2: Run the function

Changing the document with Javascript document.bgColor="red" What do you think this line will do? You can also use color hex codes such as #ff6600 #00ff00 You can change lots of things on a web page – images, text, divs – more later… amount of Red amount of Green amount of Blue

Task: Change the background colour Add a line to change the background colour to your button. Extension: Research "hex color codes" to find other colours you could use Add the line to change the colours at several points in your script and see what happens screenshot your work! or use "#ff6600"

Getting data out of fields that the user has typed in http://jsbin.com/raxogojesi/1/edit?html,js,output document.getElementById("name1").value "name1" is the id of the input tag Be careful of the spelling of getElementById store it in a variable and use it in your program screenshot your work! Love tester : http://jsbin.com/raxogojesi/1/edit?html,js,output

TO DO Adding comments Changing a picture Creating a Random Number Creating an array (and picking random value) Adding a delay using setTimeout