Using keyboard for input control
|
|
- Irma McCormick
- 6 years ago
- Views:
Transcription
1 Lecture #7 Introduction Using keyboard for input control The keyboard has been the computer input device for the longest time, even since the old days when there was no such thing called mouse and graphical user interface. As a matter of fact, even today, the keyboard is still a useful input device for a wide range of games. For example, any game involving the player moving an object around will benefit from using the arrow keys. In this lecture, you will learn many games that uses the arrow keys to move objects. In JavaScript, as well as most programming languages, each keyboard character has a unique character code, typically known as key code. They not only help the browser to know which character is pressed but also how to develop application to handle interactions for responsive design. Basic keyboardrelated event handlers JavaScript support some keyboard event handlers, which are very useful in responding to the user input when keys on a keyboard are pressed. These events are what make it possible for JavaScript to react when a key is pressed: Event handler Onkeypress Onkeydown onkeyup Table: Keyboard related event handlers Functions invokes JavaScript code when a key is pressed invokes JavaScript code when a key is held down (but not yet released) invokes JavaScript code when a key is has been released after being pressed. These events can be bind to most elements on a game page. But, you will probably stick to either the document element in most cases. For example, the code below uses the onkeypress property of the document element to call the show function, which in turns changes the display attribute s value from none to inline. In other words, when the user presses any key, the cat.gif appears. <!-- IE10, Firefox, Chrome --> <head> function show() var m1 = document.getelementbyid("m1"); m1.style.display="inline"; document.onkeypress = function() show(); <img id="m1" src="cat.gif" style="display:none"> 186
2 This code may be simplified to: <!-- IE10, Firefox, Chrome --> <head> function show() var m1 = document.getelementbyid("m1"); m1.style.display="inline"; document.onkeypress=show; <img id="m1" src="cat.gif" style="display:none"> Another way to register the onkeypress event is: <!-- IE10, Firefox, Chrome --> <head> function show() var m1 = document.getelementbyid("m1"); m1.style.display="inline"; document.addeventlistener("keypress", show, false); <img id="m1" src="cat.gif" style="display: none"> The old way is: <body onkeypress = "show()"> In the following example, the onkeydown is used to display the time the page was loaded, while onkeyup displays the current time. <!-- IE10, Firefox, Chrome --> 187
3 <head> function init_time() init_time = Date(); document.onkeydown = function() var t1 = document.getelementbyid("t1"); t1.innertext=init_time; document.onkeyup = function() var t2 = document.getelementbyid("t2"); t2.innertext=date(); window.onload = init_time; Starting time: <b id="t1"></b><br> Ending time: <b id="t2"></b> Press any key. A sample output looks: In order to write a cross-browser code, it might be necessary to use an if statement to provide codes for different browsers, although this course intends to ignore this incompatibility issue to keep the lecture note concise and compact. if (document.addeventlistener) document.addeventlistener("keydown", funct1, false); document.addeventlistener("keypress", funct2, false); document.addeventlistener("keyup", funct3, false); else if (document.attachevent) document.attachevent("onkeydown", funct1); document.attachevent("onkeypress", funct2); document.attachevent("onkeyup", funct3); else document.onkeydown= keydown; document.onkeypress= keypress; 188
4 document.onkeyup= keyup; The above code use the following statement to comply with the DOM specification that all browsers should follow. if (document.addeventlistener) Since Microsoft Internet Explorer, for a while, try to promote its own specification, use the following to support Internet Explorer. else if (document.attachevent) Ultimately, use the following because there may be other older browsers that follow neither. else To further demonstrate how the keyboard-related even handlers work in game programming, create a new project called kb.htm with the following contents: <!-- IE10, Firefox, Chrome --> <div id=area1 style="border:1px solid black; background-color:#abcdef; width:300px; height:300px;"> </div> <img id=ball src="ball.gif" style="top:315px; left:10px; position:absolute"> Use a web browser to run the code. It creates a pale-blue area with a rolling ball below it. The tag contains an onkeydown event, which will detect if the user ever presses any key. A user-defined function cc() is assigned to the onkeydown event handler, although it is not yet created. You will soon create and define what this cc() function can do. The <div> and </div> defines the pale-blue area. All its properties, such as border, background color, width, and height, are defined using CSS. The id attribute simply defines the ID of this area. The <img> tag loads the animated gif file. It also uses CSS to define properties. Noticeably, the position is set to be absolute, which means the position value set (top, left) is based on the Web browser s origin. The ID of the gif file is ball. The KeyCode The keycode property of the Event object returns UniCode value of key pressed. The returned value is the key's numerical value, not the American National Standards Institute 189
5 (ANSI) value. You can use keycode to detect when the user has pressed an arrow or function key, which cannot be specified by the key property. The syntax is: event.keycode The following example demonstrates how you can display each key s key code in an alert box. There is an if statement which specifies what e is in case it is not detected by the browser. <!-- IE10, Firefox, Chrome --> function getit(e) if (!e) var e = window.event; // in case event not detected window.alert(e.keycode); document.onkeydown = function() getit(); Press the Alt key, for example, you should see a value 18 on the alert box: Many games dedicate a special key, such as the s key for a specified function, such as firing a bullet. It is often necessary to check if the player ever presses the s key, and raise an event as response if so. Before being able to detect if a particular is pressed, you will need to learn how to check keys by their key codes. The following is a list of JavaScript key codes. Table: Common Key Codes Key Code Key Code Key Code Key Code A [Alt] 18 B [Enter] 13 C * 106 [Shift] 16 D / 111 [Ctrl] 17 E ` 192 [CapsLock] 20 F , 188 [Esc] 27 G [Backspace] 8 H / 191 [Insert] 45 I ; 186 [Home]
6 J [PageUp] 33 K 75 F1 112 [ 219 [Delete] 46 L 76 F2 113 ] 221 [End] 35 M 77 F3 114 \ 220 [PageDown] 34 N 78 F4 115 = 187 [PrintScreen] O 79 F5 116 [ScrollLock] 145 P 80 F6 117 [Pause] 19 Q 81 F7 118 R 82 F8 119 S 83 F9 120 T 84 F U 85 F V 86 F W X Y 89 3 Z There is a function named moveit() in the following code which uses the keycode property of the event object to determine weather or not the user presses the Left arrow key ( ). This Left arrow key has a numerical value 37. A simple if..then decisive logic can make this decision. <!-- IE10, Firefox, Chrome --> <head> function moveit(e) var ball = document.getelementbyid("ball"); if (!e) var e = window.event; // in case event not detected if(e.keycode == 37) ball.style.left = (parseint(ball.style.left) - 10) + "px"; document.onkeydown = function() moveit(window.event); // call moveit with default event <div id=area1 style="border:1px solid black; background-color:#abcdef; width:300px; height:300px;"> </div> <img id=ball src="ball.gif" style="top:315px; left:10px; position:absolute"> 191
7 In the following line, ball is the ID of the gif file, so ball.style.left represents the horizontal value of the position value set (top, left). style is a keyword that indicates Cascading Style Sheet. ball.style.left = (parseint(ball.style.left) - 10) + "px"; The original value of ball.style.left is set to the 10, as specified by left:10. The above line is techinically the same as the following in Internet Explorer: ball.style.pixelleft = ball.style.pixelleft - 10; By the way, in the old days, the above line would look (Good thing is you don t have to do so any more!): ball.style.left = eval(ball.style.left.replace('px','')) - 10; The difference between left and pixelleft is that the value of left is a string, such as 120px. The value of pixelleft is an integer, such as 120. Since a string value cannot be calculated arithematically, you need to use the replace() method to remove the px substring. ball.style.left.replace('px','') Consequently, a value of 120px becomes 120. But, 120 is still a string made of 1, 2, and 0, not an integer. The eval() method then convert the number-like string to the integer data type. In other words, 120 now means one-hundred-and-twenty, no longer a string that reads one-twozero. With the new XHTML, CSS and JavaScript standard, you can ignore this old technique. Remarkably, the instructor purposely brings up this topic just for your reference. The following lines, which only works in Internet Explorer, tells the computer to subtract 10 from the current ball.style.pixlleft each time when the user press the Left arrow key ( ). var e = window.event; if(e.keycode==37) var ball = document.getelementbyid("ball"); ball.style.pixelleft -= 10; According to the following table, the Up, Right, and Down arrow keys have values of 38, 39, and 40. Similarly, you can use the following line to add 10 to the current ball.style.left each time when the user press the Right arrow key ( ). if(e.keycode==39) ball.style.left = (parseint(ball.style.left) + 10) + "px"; The change the vertical position, you need to modify the current value of ball.style.top, which represents the vertical value of the position value set (top, left). var ball = document.getelementbyid("ball"); if(e.keycode==38) ball.style.top = (parseint(ball.style.top) - 10) + "px"; 192
8 if(e.keycode==40) ball.style.top = (parseint(ball.style.top) + 10) + "px"; The code now looks: <!-- IE10, Firefox, Chrome --> <head> function moveit(e) if (!e) var e = window.event; // in case event not detected var ball = document.getelementbyid("ball"); if(e.keycode==37) ball.style.left = (parseint(ball.style.left) - 10) + "px"; if(e.keycode==39) ball.style.left = (parseint(ball.style.left) + 10) + "px"; if(e.keycode==38) ball.style.top = (parseint(ball.style.top) - 10) + "px"; if(e.keycode==40) ball.style.top = (parseint(ball.style.top) + 10) + "px"; document.onkeydown = function() moveit(); <div id=area1 style="border:1px solid black; background-color:#abcdef; width:300px; height:300px;"> </div> <img id=ball src="ball.gif" style="top:315px; left:10px; position:absolute"> The use of a switch..case statement in such programming case is probably more efficient and effective to the game. You can re-write the above code to the following for a better efficiency. <!-- IE10, Firefox, Chrome --> 193
9 <head> function moveit(e) if (!e) var e = window.event; // in case event not detected var ball = document.getelementbyid("ball"); switch (event.keycode) case 37: ball.style.left = (parseint(ball.style.left) - 10) + "px"; case 39: ball.style.left = (parseint(ball.style.left) + 10) + "px"; case 38: ball.style.top = (parseint(ball.style.top) - 10) + "px"; case 40: ball.style.top = (parseint(ball.style.top) + 10) + "px"; document.onkeydown = function() moveit(); <div id=area1 style="border:1px solid black; background-color:#abcdef; width:300px; height:300px;"> </div> <img id=ball src="ball.gif" style="top:315px; left:10px; position:absolute"> Use Internet to run the code, and use the,,, and keys to move the ball. 194
10 By the way, some keys, like [Shift], [Control] and [Alt], aren t normally thought of as sending characters, but modify the characters sent by other keys. For many keys, no key codes are returned on keydown and keyup events. Instead the keycode value is just zero, Characters that give a zero keycode when typed include those listed below, as well as any key when the Alt/Option key is held down. - _ # $ % ^ & * ( ) + : < >? Internet Explorer provides the following properties. Properties altkey, ctrlkey, shiftkey keycode type Table: Keyboard related properties of the event object Description Boolean properties that indicate whether the Alt, Ctrl, Meta, and Shift keys were pressed at time of the event. Property indicating the Unicode for the key pressed. A string indicating the type of event, such as onkeydown, onkeyup, etc. The following example illustrates how to require the player to hold the Shift key and then press the C key to do something. The event.shiftkey property is a boolean type. It returns true if the Shift key is being pressed, false if not; altkey and ctrlkey work the same way. <!-- IE10, Firefox, Chrome --> <head> function getit(e) if (!e) var e = window.event; // in case event not detected if (e.shiftkey && e.keycode==67) window.alert("you pressed Shift + C"); document.onkeydown = function() getit(); The following will return the type of event. A sample output looks: if (e.shiftkey && e.keycode==67) window.alert(e.type); 195
11 Both if..then and switch..case statements are frequently used collaboratively to check if the player presses a combination of keystroke in order to make decision as what to respond to the player s input from keyboard. The following example will first check if the shift key is held, and then determine if C, D, or E is pressed accordingly. <!-- IE10, Firefox, Chrome --> <head> function getit(e) if (!e) var e = window.event; // in case event not detected if (e.shiftkey) // if shift is press switch (e.keycode) case 67: window.alert("shift + C"); case 68: window.alert("shift + D"); case 69: window.alert("shift + E"); document.onkeydown = function() getit(); <audio id="p1" src="c0.mp3" preload="auto"></audio> <button onclick="playme()">c0</button> Basically, the switch..case statement is a multi-way decision statement. Unlike the multiple-decision statement that can be created using if..then. The switch statement evaluates the conditional expression and tests it against numerous constant values. The branch corresponding to the value that the expression matches is taken during execution. The [Enter] key is a known issue that needs your attention because the [Enter] is typically used to submit something, such as a HTML form. In a game, it might be necessary to use the [Enter] to call a JavaScript user-defined function, the following code is an example that will void the default function of [Enter]; therefore, you can use it call some user-defined function. <!-- IE10, Firefox, Chrome --> 196
12 <head> function getit(e) if (e.which == 13 e.keycode == 13) window.alert("hi!"); return false; // void the key else return true; document.onkeydown = function() getit(event); Sample Games Consider the following code, it uses CSS (cascade style sheet) to specify how an area defined by <span> </span> in a code division (defined by <div> </div>) should look in a Web browser s body area. <style>.wkey background-color: white; border-top: 1px solid #cdcdcd; border-left: 1px solid #cdcdcd; border-bottom: 4px solid #cdcdcd; border-right: 1px solid black; height: 150px; width: 40px; </style> Define white keys <div> <!-- white keys --> <span class="wkey" id="midc"></span> </div> CSS uses <style> </style> to embed a style sheet onto an HTML code. In this example, wkey is the name of style, which contains the following attributes and their associated values in the format of atttributename : value. background-color : white. This set of attribute and value simply defines the background of the object using this style as white. border-top : 1px solid #cdcdcd. This sets the top border to be a solid line with size of 1px and color value of #cdcdcd (in the RGB format). This color combination produces the color of light gray. height : 150px. This sets the height of the object to be 150px. width : 40px. This sets the width of the object to be 40px. 197
13 The following line associates an object with ID midc with the wkey style, such that all the styles wkey has will apply to this midc object. <span class="wkey" id="midc"></span> The output of this code looks: In order to add two more objects that are clones of the midc object, simply add the following two lines. Just be sure to assign new IDs for each of the two new objects! <span class="wkey" id="midc" style="left:50px"></span> <span class="wkey" id="midd" style="left:91px"></span> <span class="wkey" id="midf" style="left:132px"></span> The output now looks: Take a close look at these three objects, they are placed closely together, there s no space between any consecutive ones. In order to dynamically place each object on the web browser s body area, you need to use absolute positioning system. You do so by adding the following bold line:.wkey position: absolute; background-color: white; border-top: 1px solid #cdcdcd; border-left: 1px solid #cdcdcd; border-bottom: 4px solid #cdcdcd; border-right: 1px solid black; height: 150px; width: 40px; DHTML, with CSS, use two pre-defined variables -- left and top -- to represent x- and y- coordinate of the browser s body area. In fact, most graphics in a Windows program are drawn to the client area of a window, which uses the Windows graphics coordinate system. 198
14 The following figures explains how the coordinates of the client area begin in the upper-left corner of the window and increase down and to the right, as you learned earlier in the hour. This coordinate system is very important because most GDI graphics operations are based on them. Consequently, by adding the following bold line, all the three objects y-coordinate are set to be 20px, which means they all are 20px below the x-axis..wkey position: absolute; top: 20px; background-color: white; border-top: 1px solid #cdcdcd; border-left: 1px solid #cdcdcd; border-bottom: 4px solid #cdcdcd; border-right: 1px solid black; height: 150px; width: 40px; The output now looks weird. There are 3 objects, supposedly, but only one is displayed. What s wrong? The answer is, the absolute positioning system uses both left and top to specify a given object of absolute position. All the three objects top values are defined as 20px in the above code segment. It s time to assign each object s left value individually. <span class="wkey" id="midc" style="left:50px"></span> <span class="wkey" id="midd" style="left:91px"></span> <span class="wkey" id="mide" style="left:132px"></span> The above uses a technique known as inline style, which means to add a style to the HTML tag as an attribute of the tag. As a reminder, the syntax is: 199
15 style = "attributename1:value1;attributename2:value2;...; attributenamen:valuen" The midc object is now assigned an initial point (50, 20), midd (91, 20), and mide (132, 20). The distance between 50 and 91 is 41. In this code example, 41 is determined because each object is 40px wide (as specified by width:40px), plus 1px as the space between two objects = = 132 Take a good look at the output. There is a visible space between every two objects. (50, 20) (91,50) (132, 20) To make the above graphics looks like a section of piano keyboard, add the following bold lines: <style>.wkey position: absolute; top: 20px; background-color: white; border-top: 1px solid #cdcdcd; border-left: 1px solid #cdcdcd; border-bottom: 4px solid #cdcdcd; border-right: 1px solid black; height: 150px; width: 40px;.bKey position: absolute; top: 20px; background-color: black; border: 1px solid white; height: 70px; width: 36px; Define black keys </style> <div> <!-- white keys --> <span class="wkey" id="midc" style="left:50px"></span> 200
16 <span class="wkey" id="midd" style="left:91px"></span> <span class="wkey" id="mide" style="left:132px"></span> <!-- black keys --> <span class="bkey" id="csharp" style="left:72px"></span> <span class="bkey" id="dsharp" style="left:114px"></span> </div> The first added code segment defines a new CSS style named bkey, which specifies how a black key should look. The second simply adds two black keys in the division ( as defined by <div> </div>). Each black key has a unique ID. The output now looks (Surprisingly, you create a graphic using DHTML codes!): To add animated effects to the above graphics, you need to write user-defined functions. Such functions can perform visual effects. For example, you can add visual effects to the keys, so they will have an effect of key-down-key-up. Consider the following added bold codes: <!-- for middle C --> function CDown() var midc = document.getelementbyid("midc"); midc.style.bordertop="1px solid black"; midc.style.borderleft="1px solid black"; midc.style.borderbottom="1px solid black"; midc.style.borderright="1px solid #cdcdcd"; function CUp() var midc = document.getelementbyid("midc"); midc.style.bordertop="1px solid #cdcdcd"; midc.style.borderleft="1px solid #cdcdcd"; midc.style.borderbottom="4px solid #cdcdcd"; midc.style.borderright="1px solid black"; document.onkeydown = function() CDown(); document.onkeyup = function() CUp(); 201
17 It uses two event handlers: onkeydown and onkeyup to call two different user-defined functions: CDown() and CUp(). Such programming techniques will be discussed in a later lecture. For now, you just have to know what they are. These two user-defined functions, CDown() and Cup(), are combinations of DHTML statements. As a reminder, the syntax is (notice that style is a keyword): objectid.style.attributenme = "Value"; In CDown(), the first line changes the top border of the midc object to solid 1 black, the second changes the left border, the third changes the bottom border, and the fourth changes the right border to solid 1 #cdcdcd. Compare CDown() and CUp() carefully and you will find out their color values in the reversed order to each other. Also, be sure to know that the color values of CUp() are exactly the same as those defined in wkey style. var midc = document.getelementbyid("midc"); function CDown() var midc = document.getelementbyid("midc"); midc.style.bordertop="1px solid black"; midc.style.borderleft="1px solid black"; midc.style.borderbottom="1px solid black"; midc.style.borderright="1px solid #cdcdcd"; function CUp() var midc = document.getelementbyid("midc"); midc.style.bordertop="1px solid #cdcdcd"; midc.style.borderleft="1px solid #cdcdcd"; midc.style.borderbottom="4px solid #cdcdcd"; midc.style.borderright="1px solid black"; By executing these two functions, the color of midc s top border changes from #cdcdcd to black, and then back to #cdcdcd. This creates an effect of key-down-key-up. A complete code is available in the learning activity, please learning this technique for your own good. The above code also illustrates how you can create animated game objects programmatically. The advantage is that you can easily apply dynamic functions to the graphics. On the other hand, try use Microsoft Paint to create a gif file (named board.gif) that looks: Then, modify the kb.htm file to: <!-- IE10, Firefox, Chrome --> 202
18 <head> function moveit(e) var ball = document.getelementbyid("ball"); if (!e) var e = window.event; if(e.keycode==37) ball.style.left = (parseint(ball.style.left) - 10) + "px"; if(e.keycode==39) ball.style.left = (parseint(ball.style.left) + 10) + "px"; if(e.keycode==38) ball.style.top = (parseint(ball.style.top) - 10) + "px"; if(e.keycode==40) ball.style.top = (parseint(ball.style.top) + 10) + "px"; document.onkeydown = function() moveit(); <img id="board" src="board.gif"> <img id="ball" src="ball.gif" style="top:315px; left:10px; position:absolute"> Use Internet to run the code, you just created a maze game. This code can be written using the switch..case statement. For example, <!-- IE10, Firefox, Chrome --> <head> 203
19 function cc() var ball = document.getelementbyid("ball"); var e = event.keycode; switch (e) case 37: ball.style.left = (parseint(ball.style.left) - 10) + "px"; case 39: ball.style.left = (parseint(ball.style.left) + 10) + "px"; case 38: ball.style.top = (parseint(ball.style.top) - 10) + "px"; case 40: ball.style.top = (parseint(ball.style.top) + 10) + "px"; <body onkeydown=cc()> <img id=board src="board.gif"> <img id=ball src="ball.gif" style="top:315px; left:10px; position:absolute"> Use keyboard to control the width and height of an object Many objects have the properties of width and height. In one of the previou lecture, there is a game that creates a visul effect of a bat flying back and forth. With the topic of this lecture, you can try to control the visual effect by keyboard. In the following example, the <img> tag is given and ID m1. Consequently, m1.style.width represents the width property of this image object. <!-- IE10, Firefox, Chrome --> <head> function cc(e) if (!e) var e = window.event; var m1 = document.getelementbyid("m1"); if (e.keycode == 38) m1.width = m1.width + 10; if (e.keycode == 40) m1.width = m1.width - 10; 204
20 document.onkeydown = function() cc(); <img id="m1" src="bat.gif" width="10px"> When you run the code, the Up and Down arrow keys will increase and decrease the value of width. On the screen, the change of value creates effect of zoom in and zooms out. Another way to write the above code is: <!-- IE10, Firefox, Chrome --> <head> function cc() if (!e) var e = window.event; var m1 = document.getelementbyid("m1"); var i = event.keycode; switch(i) case 38: m1.width = m1.width + 10; case 40: m1.width = m1.width - 10; document.onkeydown = function() cc(); <img id="m1" src="bat.gif" width="10px"> to 205
21 Review Questions 1. Which can register an "onkeypress" event to the web page and use it to call the "show()" function as event handler? A. document.onkeypress = function() show(); B. document.onkeypress=show; C. document.addeventlistener("keypress", show, false); D. <body onkeypress = "show()"> E. All of the above. 2. Which can prevent the [Enter] key from submitting something; in other words, void the [Enter] key's default function? A. if (e.which == 13 e.keycode == 13) return null; B. if (e.which == 13 e.keycode == 13) return false; C. if (e.which == 13 e.keycode == 13) D. if (e.which == 13 e.keycode == 13) void; E. if (e.which == 13 e.keycode == 13) return void; 3. Given the following code block, which statement is correct? <body onkeydown="status = new Date();" onload="document.title=new Date()" onkeyup="p1.innertext=new Date()"> A. When the user loads the page, the current data and time is display on the status bar. B. When the user press and hold the [Enter] key, the current data and time is displayed on the status bar. C. When the user press and then release the [Enter] key, the current data and time is displayed on the status bar. D. All of the above 4. Which property of the Event object returns UniCode value of key pressed? A. event.keytype B. event.keycode C. event.key D. event.keypress 5. Given the following code block, which statement is incorrect? <body onkeydown="status=event.keycode"> A. When you press any key, the status bar displays the string "event.keycode". B. When you press the Alt key, the status bar displays the value 18. C. When you press the left arrow key, the status bar displays the value 37. D. When you press the P key, the status bar displays the value When Unicode value is what you get when you press the Scroll Lock key? A. 145 B. 125 C. 135 D Given the following code, which statement is correct? ball.style.left.replace('px','')) A. It uses the replace() method to remove "px" from "10px". B. It uses the replace() method to remove "10px" from "10px". C. It sets the value of ball.style.left to null. 206
22 D. All of the above 8. Which property of the event object returns a boolean outcome? A. altkey B. ctrlkey C. shiftkey D. All of the above 9. Given the following code, Which can detect if both the shift key and the C key is presses? var e = window.event; A. if (shiftkey && keycode==67) B. if (e.keycode = "shift" && e.keycode==67) C. if (e.shiftkey && e.keycode==67) D. if (e.keycode = "shiftkey" && e.keycode==67) 10. Which is the correct way to detect what key has been pressed? A. <body onkeydown="status=event.keycode"> B. <body onkeydown="status=event.keypresscode"> C. <body onkeydown="status=event.keytypecode"> D. <body onkeydown="status=event.keyoncode"> 207
23 Lab #7 Note: The following games are meant to be simple and easy for the sake of demonstrating programming concepts. Please do not hesitate to enhance the appearance or functions of these games. Preparation #1: 1. Create a new directory named C:\games. 2. Use Internt Explorer to go to to download lab7.zip (a zipped) file. Extract the files to C:\games directory. Learning Activity #1: Labyrinth 1. In the C:\games director, use Notepad to create a new file named C:\games\lab7_1.htm with the following contents: <!-- Microsoft Edge, IE10/11, FireFox, Chrome --> function moveit(e) var ball = document.getelementbyid("ball"); // find the object if (!e) var e = window.event; var i = e.keycode; switch (i) case 37: // old way ball.style.left = (eval(ball.style.left.replace('px','')) - 10) + "px"; case 39: // new way ball.style.left = (parseint(ball.style.left) + 10) + "px"; case 38: // without using increment-append ball.style.top = (parseint(ball.style.top) - 10) + "px"; case 40: ball.style.top = (parseint(ball.style.top) + 10) + "px"; document.onkeydown = function() moveit(); 208
24 <img id="board" src="board.gif"> <img id="ball" src="ball.gif" style="top:315px; left:10px; position: absolute"> Note: This version use switch..case, so be sure to compare this version with the one in the lecture which use if..then statement. 2. Test the program. Use,,, and arrow keys to move the ball. A sample output looks: 5. Download the assignment template, and rename it to lab7.doc if necessary. Capture a screen shot similar to the above one and then paste it to a Micrsoft Word document named lab7.doc (or.docx). Learning Activity #2: Moving the ball 1. In the C:\games director, use Notepad to create a new file named C:\games\lab7_2.htm with the following contents: <!-- Microsoft Edge, IE10/11, FireFox, Chrome --> <head> function move() var ball = document.getelementbyid("ball"); // find the object var area1 = document.getelementbyid("area1"); var e = event.keycode; // detect the key var x = parseint(ball.style.left); var y = parseint(ball.style.top); switch(e) case 37: // stop if the ball touches the left border if ( x <= 10) ball.style.left = (x + 10) + "px"; // x-coordinate of ball else ball.style.left = (x - 1) + "px"; case 39: // stop if ball touches the right border if ((x + ball.width) >= area1.width-10) 209
25 ball.style.left = (area1.width - ball.width -10); else ball.style.left = (x + 1) + "px"; case 38: // stop if the ball touches the top border if ( y <= 10) ball.style.top = (y + 10) + "px"; else ball.style.top = (y - 1) + "px"; case 40: // stop if the ball touches the bottom border if ((y + ball.height) >= area1.height-10) ball.style.top = (area1.height - ball.height -10); else ball.style.top = (y + 1) + "px"; // end of move() document.onkeydown = function() move(); <div id=area1 style="border: 1px solid black; background-color:#abcdef; width:300px; height:300px; top:10px; left:10px; position:absolute"> </div> <img id=ball src="ball.gif" style="top:10px; left:10px; position: absolute"> 2. Test the program. Use the,,, arrow keys to move the ball. A sample output looks: 210
26 3. Capture a screen shot similar to the above one and then paste it to a Micrsoft Word document named lab7.doc (or.docx). Learning Activity #3: snake game 1. In the C:\games director, use Notepad to create a new file named C:\games\lab7_3.htm with the following contents: <!-- Microsoft Edge, IE10/11, FireFox, Chrome --> <head> var x=190; // global variables var y=384; var k=1; var n=0; function draw() var e = event.keycode; switch (e) case 37: n=1; k=0; case 38: n=0; k=1; case 39: n=-1; k=0; case 40: n=0; k=-1; function init() var codes = ""; // clear codes var p1 = document.getelementbyid("p1"); var area1 = document.getelementbyid("area1"); if ((x<=10) (x>=394) (y<=-10) (y>=400)) // means "or" p1.innertext="game over!"; else y -= k; // decrement x -= n; codes = "<span style='position:absolute; left:"+x; codes += "px; top:"+ y +"px'>.</span>"; area1.innerhtml += codes; 211
27 settimeout("init()", 0.1); window.onload = function() init(); document.onkeydown = function() draw(); <div id="area1" style="position:absolute; width:400px; height:400px; border: 3px solid black; color:red; background-color: black; left:0px; top:10px;"></div> <p id="p1" style="position:absolute; left:160px; top:200px; color: white"></p> 2. Test the program. Use,,, and arrow keys to move. A sample output looks: and 3. Capture a screen shot similar to the above one and then paste it to a Micrsoft Word document named lab7.doc (or.docx). Learning Activity #4: 1. In the C:\games directory, use Notepad to create a new file named C:\games\lab7_4.htm with the following contents: <!-- Microsoft Edge, IE10/11, FireFox, Chrome --> <!Doctype html> <head> <script> 212
28 function moveit(e) if (!e) var e = window.event; var ap = document.getelementbyid("airplane"); switch (e.keycode) case 65: //A ap.style.left = (parseint(ap.style.left) - 1) + "px"; ap.src = "a3.png"; case 68: //D ap.style.left = (parseint(ap.style.left) + 1) + "px"; ap.src = "a4.png"; case 87: //W ap.style.top = (parseint(ap.style.top) - 1) + "px"; ap.src = "a1.png"; case 88: //X ap.style.top = (parseint(ap.style.top) + 1) + "px"; ap.src = "a2.png"; //slant directions case 81: //Q ap.style.left = (parseint(ap.style.left) - 1) + "px"; ap.style.top = (parseint(ap.style.top) - 1) + "px"; ap.src = "a6.png"; case 69: //E ap.style.left = (parseint(ap.style.left) + 1) + "px"; ap.style.top = (parseint(ap.style.top) - 1) + "px"; ap.src = "a5.png"; case 67: //C ap.style.left = (parseint(ap.style.left) + 1) + "px"; ap.style.top = (parseint(ap.style.top) + 1) + "px"; ap.src = "a7.png"; case 90: //Z ap.style.left = (parseint(ap.style.left) - 1) + "px"; ap.style.top = (parseint(ap.style.top) + 1) + "px"; ap.src = "a8.png"; document.onkeydown = function() 213
29 moveit(window.event); <img id="airplane" src="a3.png" style="position: absolute; left:200px; top:200px;"> 2. Test the program. Click the white spaceonce, and then use Q, W, E, A, D, Z, X, and C to move the airplane. 3. Capture a screen shot similar to the above one and then paste it to a Micrsoft Word document named lab7.doc (or.docx). Learning Activity #5: Jet Fighters 1. In the C:\games director, use Notepad to create a new file named C:\games\lab7_5.htm with the following contents: <!-- Microsoft Edge, IE10/11, FireFox, Chrome --> <head> <style> body background-color: black; </style> var bsrw = document.documentelement.clientwidth; // get browser width function init() var ap01 = document.getelementbyid("ap01"); // find the object ap01.style.left = Math.floor(Math.random()*300) + "px"; moveit(); var k = 2; function moveit() var ap01 = document.getelementbyid("ap01"); if (parseint(ap01.style.left) > bsrw - 20) k = -2; and 214
30 else if (parseint(ap01.style.left) < 10) k = 2; ap01.style.left = (parseint(ap01.style.left) + k) + "px"; settimeout("moveit()",5); function fly() var e = event.keycode; var st01 = document.getelementbyid("st01"); var b01 = document.getelementbyid("b01"); switch(e) case 37: st01.style.left = (parseint(st01.style.left) - 10) + "px"; case 39: st01.style.left = (parseint(st01.style.left) + 10) + "px"; case 38: st01.style.top = (parseint(st01.style.top) - 10) + "px"; case 40: st01.style.top = (parseint(st01.style.top) + 10) + "px"; case 83: // bullet b01.style.left = (parseint(st01.style.left) + 20) + "px"; b01.style.top = parseint(st01.style.top) + "px"; b01.style.display = 'inline'; fire(); // end of fly() function fire() var b01 = document.getelementbyid("b01"); b01.style.top = (parseint(b01.style.top) - 10) + "px"; settimeout("fire()",50); window.onload = function() init(); document.onkeydown = function() fly(); <body id="bd"> <img id="ap01" src="e_plan.gif" style="position:absolute"> <img id="st01" src="shooter.gif" style="position:absolute; top:300px; left:100px"> <span id="b01" style="position:absolute; display:none; color: white">!</span> 215
31 Note: Because collision detection and response is the topic of a later lecture, how you can modify this code so that the bullet can destroy the plane will be discussed in a later lecture. 2. Test the program. Use,,, and arrow keys to move airplane. Press the S key to shoot a bullet. A sample output looks: 3. Capture a screen shot similar to the above one and then paste it to a Micrsoft Word document named lab7.doc (or.docx). Submittal 1. Upon completing all the learning activities, compress the following files to a zipped file named lab7.zip : Lab7_1.htm Lab7_2.htm Lab7_3.htm Lab7_4.htm Lab7_5.htm Lab7.doc (or.docx) 2. Upload the lab7.zip file. Programming Exercise #07 1. Use Notepad to create a new text file named ex07.htm with the following lines. Be sure to replace YourFullName with your actual full name. <!-- Filename: ex07.htm Student: YourFullName --> 2. Next to the above code, write a code that will detect if both Control and k keys are pressed. If so, display the following message. 3. Download the programming exercise template, and rename it to ex07.doc. Capture a screen short similar to the above and paste it to a Word document named ex07.doc (or.docx). 4. Compress both ex07.htm and ex07.doc (or.docx) file to a zip file named ex07.zip. 216
32 5. Submit only the.zip file. Grading Critiera Your code must meet all the requirements to receive full credits. No partial credit is given. You will receive zero point if any of the required file is missing or not submitted. 217
<!DOCTYPE html> <html> <body> <audio src="u1.mp3" controls></audio> </body> </html> <audio src="u1.mp3" controls />
Lecture #10 HTML5 tag Applying sound effects With the HTML5 tag, you can insert a sound file, such as a MP3 file, on a web page. Then, write appropriate JavaScript code to control the default
More informationThe Art of Storyboarding
Lecture #12 Objective The Art of Storyboarding Storyline and Texture This lecture is aimed at walking students through some of the basic knowledge for developing complex games within a restricted coding
More informationINTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations
Hun Myoung Park (2/2/2018) Layout & Position: 1 INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations DCC5382 (2 Credits) Introduction
More informationGuidelines for doing the short exercises
1 Short exercises for Murach s HTML5 and CSS Guidelines for doing the short exercises Do the exercise steps in sequence. That way, you will work from the most important tasks to the least important. Feel
More informationPerfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5
Perfect Student Midterm Exam March 20, 2007 Student ID: 9999 Exam: 7434 CS-081/Vickery Page 1 of 5 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives
More informationWhat is a game? Game Programming Penn Wu 1
Lecture #1 Introduction Basic Skills The Game Industry is a multi-billion dollar industry and still growing. Years ago, the technology forced games to have simple designs. Programs could often be developed
More informationWeb Site Development with HTML/JavaScrip
Hands-On Web Site Development with HTML/JavaScrip Course Description This Hands-On Web programming course provides a thorough introduction to implementing a full-featured Web site on the Internet or corporate
More informationExercise 1: Understand the CSS box model
Concordia University SOEN 287: Web Programming 1 Winter 2016 Assignment 2 Due Date: By 11:55pm Sunday February 14, 2016 Evaluation: 4% of final mark Late Submission: none accepted Type: Individual Assignment
More informationEvents: another simple example
Internet t Software Technologies Dynamic HTML part two IMCNE A.A. 2008/09 Gabriele Cecchetti Events: another simple example Every element on a web page has certain events which can trigger JavaScript functions.
More informationLING 408/508: Computational Techniques for Linguists. Lecture 14
LING 408/508: Computational Techniques for Linguists Lecture 14 Administrivia Homework 5 has been graded Last Time: Browsers are powerful Who that John knows does he not like? html + javascript + SVG Client-side
More informationWeb Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh
Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags, creating our template file Introduction to CSS and style
More informationDeveloping Apps for the BlackBerry PlayBook
Developing Apps for the BlackBerry PlayBook Lab # 2: Getting Started with JavaScript The objective of this lab is to review some of the concepts in JavaScript for creating WebWorks application for the
More informationParashar Technologies HTML Lecture Notes-4
CSS Links Links can be styled in different ways. HTML Lecture Notes-4 Styling Links Links can be styled with any CSS property (e.g. color, font-family, background, etc.). a { color: #FF0000; In addition,
More informationCGS 3066: Spring 2015 JavaScript Reference
CGS 3066: Spring 2015 JavaScript Reference Can also be used as a study guide. Only covers topics discussed in class. 1 Introduction JavaScript is a scripting language produced by Netscape for use within
More informationMinistry of Higher Education and Scientific Research
Morning Study Department of information technology Institute of Technical - Duhok. University of Polytechnic Duhok. Subject: Web Technology Course book for 2nd year. Lecturer s name: MSc. Ayman Nashwan
More informationADDING FUNCTIONS TO WEBSITE
ADDING FUNCTIONS TO WEBSITE JavaScript Basics Dynamic HTML (DHTML) uses HTML, CSS and scripts (commonly Javascript) to provide interactive features on your web pages. The following sections will discuss
More informationWeb Programming and Design. MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh
Web Programming and Design MPT Junior Cycle Tutor: Tamara Demonstrators: Aaron, Marion, Hugh Plan for the next 5 weeks: Introduction to HTML tags Recap on HTML and creating our template file Introduction
More informationBefore you begin, make sure you have the images for these exercises saved in the location where you intend to create the Nuklear Family Website.
9 Now it s time to challenge the serious web developers among you. In this section we will create a website that will bring together skills learned in all of the previous exercises. In many sections, rather
More informationProgramming Lab 1 (JS Hwk 3) Due Thursday, April 28
Programming Lab 1 (JS Hwk 3) Due Thursday, April 28 Lab You may work with partners for these problems. Make sure you put BOTH names on the problems. Create a folder named JSLab3, and place all of the web
More informationIntroduction to using HTML to design webpages
Introduction to using HTML to design webpages #HTML is the script that web pages are written in. It describes the content and structure of a web page so that a browser is able to interpret and render the
More informationGetting Started with Eric Meyer's CSS Sculptor 1.0
Getting Started with Eric Meyer's CSS Sculptor 1.0 Eric Meyer s CSS Sculptor is a flexible, powerful tool for generating highly customized Web standards based CSS layouts. With CSS Sculptor, you can quickly
More informationCIS 228 (Spring, 2012) Final, 5/17/12
CIS 228 (Spring, 2012) Final, 5/17/12 Name (sign) Name (print) email I would prefer to fail than to receive a grade of or lower for this class. Question 1 2 3 4 5 6 7 8 9 A B C D E TOTAL Score CIS 228,
More informationPositioning in CSS: There are 5 different ways we can set our position:
Positioning in CSS: So you know now how to change the color and style of the elements on your webpage but how do we get them exactly where we want them to be placed? There are 5 different ways we can set
More informationProper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4
Proper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives aid on any exam or quiz. INSTRUCTIONS:
More informationNEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS
NEW WEBMASTER HTML & CSS FOR BEGINNERS COURSE SYNOPSIS LESSON 1 GETTING STARTED Before We Get Started; Pre requisites; The Notepad++ Text Editor; Download Chrome, Firefox, Opera, & Safari Browsers; The
More informationTizen Web UI Technologies (Tizen Ver. 2.3)
Tizen Web UI Technologies (Tizen Ver. 2.3) Spring 2015 Soo Dong Kim, Ph.D. Professor, Department of Computer Science Software Engineering Laboratory Soongsil University Office 02-820-0909 Mobile 010-7392-2220
More informationFSA Geometry EOC Practice Test Guide
FSA Geometry EOC Practice Test Guide This guide serves as a walkthrough of the Florida Standards Assessments (FSA) Geometry End-of- Course (EOC) practice test. By reviewing the steps listed below, you
More informationHTML/CSS Lesson Plans
HTML/CSS Lesson Plans Course Outline 8 lessons x 1 hour Class size: 15-25 students Age: 10-12 years Requirements Computer for each student (or pair) and a classroom projector Pencil and paper Internet
More informationStudent, Perfect Final Exam May 25, 2006 ID: Exam No CS-081/Vickery Page 1 of 6
Student, Perfect Final Exam May 25, 2006 ID: 9999. Exam No. 3193 CS-081/Vickery Page 1 of 6 NOTE: It is my policy to give a failing grade in the course to any student who either gives or receives aid on
More informationGIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image
GIMP WEB 2.0 MENUS Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR DYNAMIC BACKGROUND IMAGE Before you begin this tutorial, you will need
More informationTable Basics. The structure of an table
TABLE -FRAMESET Table Basics A table is a grid of rows and columns that intersect to form cells. Two different types of cells exist: Table cell that contains data, is created with the A cell that
More informationJavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK
Programming for Digital Media EE1707 JavaScript By: A. Mousavi & P. Broomhead SERG, School of Engineering Design, Brunel University, UK 1 References and Sources 1. Javascript & JQuery: interactive front-end
More informationFSA Algebra 1 EOC Practice Test Guide
FSA Algebra 1 EOC Practice Test Guide This guide serves as a walkthrough of the Florida Standards Assessments (FSA) Algebra 1 End-of- Course (EOC) practice test. By reviewing the steps listed below, you
More informationUsing Dreamweaver CS6
Using Dreamweaver CS6 4 Creating a Template Now that the main page of our website is complete, we need to create the rest of the pages. Each of them will have a layout that follows the plan shown below.
More informationGrade 8 FSA Mathematics Practice Test Guide
Grade 8 FSA Mathematics Practice Test Guide This guide serves as a walkthrough of the Grade 8 Florida Standards Assessments (FSA) Mathematics practice test. By reviewing the steps listed below, you will
More informationCOMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts
COMP519 Web Programming Lecture 16: JavaScript (Part 7) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool
More information12/9/2012. CSS Layout
Dynamic HTML CSS Layout CSS Layout This lecture aims to teach you the following subjects: CSS Grouping and nesting Selectors. CSS Dimension. CSS Display.. CSS Floating. CSS Align. 1 CSS Grouping and nesting
More informationEnterprise Portal Train the Trainer User Manual WEB PARTS
Enterprise Portal Train the Trainer User Manual WEB PARTS Version 1.2.1 Date: January 31, 2012 Table of Contents Table of Contents... 2 1 I Need To... 3 2 Media Web Part... 10 3 Content Editor... 15 4
More informationFORMS. The Exciting World of Creating RSVPs and Gathering Information with Forms in ClickDimensions. Presented by: John Reamer
FORMS The Exciting World of Creating RSVPs and Gathering Information with Forms in ClickDimensions Presented by: John Reamer Creating Forms Forms and Surveys: When and What to Use them For Both Allow you
More informationIntroduction to WEB PROGRAMMING
Introduction to WEB PROGRAMMING Web Languages: Overview HTML CSS JavaScript content structure look & feel transitions/animation s (CSS3) interaction animation server communication Full-Stack Web Frameworks
More informationMS Word Basics. Groups within Tabs
MS Word Basics Instructor: Bev Alderman L e t s G e t S t a r t e d! Open and close MS Word Open Word from the desktop of your computer by Clicking on the Start>All programs>microsoft Office >Word 2010
More informationPIC 40A. Midterm 1 Review
PIC 40A Midterm 1 Review XHTML and HTML5 Know the structure of an XHTML/HTML5 document (head, body) and what goes in each section. Understand meta tags and be able to give an example of a meta tags. Know
More informationHow to lay out a web page with CSS
Activity 2.6 guide How to lay out a web page with CSS You can use table design features in Adobe Dreamweaver CS4 to create a simple page layout. However, a more powerful technique is to use Cascading Style
More informationc122jan2714.notebook January 27, 2014
Internet Developer 1 Start here! 2 3 Right click on screen and select View page source if you are in Firefox tells the browser you are using html. Next we have the tag and at the
More informationDesigning the Home Page and Creating Additional Pages
Designing the Home Page and Creating Additional Pages Creating a Webpage Template In Notepad++, create a basic HTML webpage with html documentation, head, title, and body starting and ending tags. From
More informationHow to set up a local root folder and site structure
Activity 2.1 guide How to set up a local root folder and site structure The first thing to do when creating a new website with Adobe Dreamweaver CS3 is to define a site and identify a root folder where
More informationTAG STYLE SELECTORS. div Think of this as a box that contains things, such as text or images. It can also just be a
> > > > CSS Box Model Think of this as a box that contains things, such as text or images. It can also just be a box, that has a border or not. You don't have to use a, you can apply the box model to any
More informationChapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21
Table of Contents Chapter 1 Getting Started with HTML 5 1 Introduction to HTML 5... 2 New API... 2 New Structure... 3 New Markup Elements and Attributes... 3 New Form Elements and Attributes... 4 Geolocation...
More informationHTML. Mohammed Alhessi M.Sc. Geomatics Engineering. Internet GIS Technologies كلية اآلداب - قسم الجغرافيا نظم المعلومات الجغرافية
HTML Mohammed Alhessi M.Sc. Geomatics Engineering Wednesday, February 18, 2015 Eng. Mohammed Alhessi 1 W3Schools Main Reference: http://www.w3schools.com/ 2 What is HTML? HTML is a markup language for
More informationCSE 154: Web Programming Autumn 2018
CSE 154: Web Programming Autumn 2018 Name: UWNet ID : TA (or section): Rules: @uw.edu You have 60 minutes to complete this exam. You will receive a deduction if you keep working after the instructor calls
More informationCopyright 2018 MakeUseOf. All Rights Reserved.
15 Power User Tips for Tabs in Firefox 57 Quantum Written by Lori Kaufman Published March 2018. Read the original article here: https://www.makeuseof.com/tag/firefox-tabs-tips/ This ebook is the intellectual
More informationWeb Site Design and Development Lecture 9. CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM
Web Site Design and Development Lecture 9 CS 0134 Fall 2018 Tues and Thurs 1:00 2:15PM Floating elements on a web page By default block elements fll the page from top to bottom and inline elements fll
More informationWeb Engineering CSS. By Assistant Prof Malik M Ali
Web Engineering CSS By Assistant Prof Malik M Ali Overview of CSS CSS : Cascading Style Sheet a style is a formatting rule. That rule can be applied to an individual tag element, to all instances of a
More informationAcknowledgments. Who Should Read This Book?...xxiv How to Read This Book...xxiv What s in This Book?...xxv Have Fun!...xxvi
Contents IN DeTAIl Acknowledgments xxi Introduction xxiii Who Should Read This Book?....xxiv How to Read This Book....xxiv What s in This Book?...xxv Have Fun!...xxvi Part I: Fundamentals 1 What Is JavaScript?
More informationSEEM4570 System Design and Implementation. Lecture 3 Events
SEEM4570 System Design and Implementation Lecture 3 Events Preparation Install all necessary software and packages. Follow Tutorial Note 2. Initialize a new project. Follow Lecture Note 2 Page 2. Reset
More informationJavaScript: Events, the DOM Tree, jquery and Timing
JavaScript: Events, the DOM Tree, jquery and Timing CISC 282 October 11, 2017 window.onload Conflict Can only set window.onload = function once What if you have multiple files for handlers? What if you're
More informationTechnical Instructions
Technical Instructions This Web Site Tool Kit contains multiple Web assets that you can use to easily customize your Web pages. Web assets included are animated and static banners, a sample Web page, buttons,
More informationCatching Events. Bok, Jong Soon
Catching Events Bok, Jong Soon Jongsoon.bok@gmail.com www.javaexpert.co.kr What Is an Event? Events Describe what happened. Event sources The generator of an event Event handlers A function that receives
More informationSOEN287: Web Programming
Concordia University Department of Computer Science and Software Engineering SOEN287: Web Programming Summer 2016 Programming assignment #1 Deadline: Friday, July, 22, 2016 @ 23:55 Late submission: Type
More informationThis course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.
HTML5/CSS3/JavaScript Programming Course Summary Description This class is designed for students that have experience with basic HTML concepts that wish to learn about HTML Version 5, Cascading Style Sheets
More informationLava New Media s CMS. Documentation Page 1
Lava New Media s CMS Documentation 5.12.2010 Page 1 Table of Contents Logging On to the Content Management System 3 Introduction to the CMS 3 What is the page tree? 4 Editing Web Pages 5 How to use the
More informationPublishing On the Web. Course Content. Objectives of Lecture 7 Dynamic Pages
Web Technologies and Applications Winter 2001 CMPUT 499: Dynamic Pages Dr. Osmar R. Zaïane University of Alberta University of Alberta 1 Publishing On the Web Writing HTML with a text editor allows to
More informationCreating Buttons and Pop-up Menus
Using Fireworks CHAPTER 12 Creating Buttons and Pop-up Menus 12 In Macromedia Fireworks 8 you can create a variety of JavaScript buttons and CSS or JavaScript pop-up menus, even if you know nothing about
More informationUsing Dreamweaver CC. Logo. 4 Creating a Template. Page Heading. Page content in this area. About Us Gallery Ordering Contact Us Links
Using Dreamweaver CC 4 Creating a Template Now that the main page of our website is complete, we need to create the rest of the pages. Each of them will have a layout that follows the plan shown below.
More informationCS7026 CSS3. CSS3 Graphics Effects
CS7026 CSS3 CSS3 Graphics Effects What You ll Learn We ll create the appearance of speech bubbles without using any images, just these pieces of pure CSS: The word-wrap property to contain overflowing
More informationCS 134 Programming Exercise 9:
CS 134 Programming Exercise 9: Nibbles Objective: To gain experience working with 2 dimensional arrays. The Problem Nibbles is a snake. Nibbles moves around a field, looking for food. Unfortunately, Nibbles
More informationLecture : 3. Practical : 2. Course Credit. Tutorial : 0. Total : 5. Course Learning Outcomes
Course Title Course Code WEB DESIGNING TECHNOLOGIES DCE311 Lecture : 3 Course Credit Practical : Tutorial : 0 Total : 5 Course Learning Outcomes At end of the course, students will be able to: Understand
More informationGIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST
GIMP WEB 2.0 MENUS Web 2.0 Menus: Horizontal Navigation Bar WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR Hover effect: CREATING AN HTML LIST Most horizontal or vertical navigation bars begin with a simple
More information(Simple) JavaScript Framework Homework
(Simple) JavaScript Framework Homework Overview: In this homework you will implement a picture gallery using object oriented JavaScript code in an external JavaScript file. This is a lab about learning
More informationClient Side JavaScript and AJAX
Client Side JavaScript and AJAX Client side javascript is JavaScript that runs in the browsers of people using your site. So far all the JavaScript code we've written runs on our node.js server. This is
More informationOU EDUCATE TRAINING MANUAL
OU EDUCATE TRAINING MANUAL OmniUpdate Web Content Management System El Camino College Staff Development 310-660-3868 Course Topics: Section 1: OU Educate Overview and Login Section 2: The OmniUpdate Interface
More informationCSS worksheet. JMC 105 Drake University
CSS worksheet JMC 105 Drake University 1. Download the css-site.zip file from the class blog and expand the files. You ll notice that you have an images folder with three images inside and an index.html
More informationCreating HTML files using Notepad
Reference Materials 3.1 Creating HTML files using Notepad Inside notepad, select the file menu, and then Save As. This will allow you to set the file name, as well as the type of file. Next, select the
More informationSEEM4570 System Design and Implementation. Lecture 3 Cordova and jquery
SEEM4570 System Design and Implementation Lecture 3 Cordova and jquery Prepare a Cordova Project Assume you have installed all components successfully and initialized a project. E.g. follow Lecture Note
More informationTo place an element at a specific position on a page use:
1 2 To place an element at a specific position on a page use: position: type; top: value; right: value; bottom: value; left: value; Where type can be: absolute, relative, fixed (also static [default] and
More informationUNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013
UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013 SUBJECT CODE : SCSV1223 (Section 05) SUBJECT NAME : WEB PROGRAMMING YEAR/COURSE : 1SCSV TIME : 2.00 4.00 PM DATE : 18 APRIL 2013 VENUE : KPU 10
More informationDesigning and Developing a Website. December Sample Exam Marking Scheme
Designing and Developing a Website December 2015 Sample Exam Marking Scheme This marking scheme has been prepared as a guide only to markers. This is not a set of model answers, or the exclusive answers
More informationPurpose of this doc. Most minimal. Start building your own portfolio page!
Purpose of this doc There are abundant online web editing tools, such as wordpress, squarespace, etc. This document is not meant to be a web editing tutorial. This simply just shows some minimal knowledge
More informationExcel 2016 Basics for Windows
Excel 2016 Basics for Windows Excel 2016 Basics for Windows Training Objective To learn the tools and features to get started using Excel 2016 more efficiently and effectively. What you can expect to learn
More informationCSC 337. jquery Rick Mercer
CSC 337 jquery Rick Mercer What is jquery? jquery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.
More informationUsing Dreamweaver CC. 6 Styles in Websites. Exercise 1 Linked Styles vs Embedded Styles
Using Dreamweaver CC 6 So far we have used CSS to arrange the elements on our web page. We have also used CSS for some limited formatting. In this section we will take full advantage of using CSS to format
More informationDreamweaver: Portfolio Site
Dreamweaver: Portfolio Site Part 3 - Dreamweaver: Developing the Portfolio Site (L043) Create a new Site in Dreamweaver: Site > New Site (name the site something like: Portfolio, or Portfolio_c7) Go to
More informationICS 61 Game Systems and Design Introduction to Scratch
ICS 61, Winter, 2015 Introduction to Scratch p. 1 ICS 61 Game Systems and Design Introduction to Scratch 1. Make sure your computer has a browser open at the address http://scratch.mit.edu/projects/editor/.
More informationITP 101 Project 2 - Photoshop
ITP 101 Project 2 - Photoshop Project Objectives Learn how to use an image editing application to create digital images. We will use Adobe Photoshop for this project. Project Details To continue the development
More informationNational Training and Education Resource. Authoring Course. Participant Guide
National Training and Education Resource Authoring Course Participant Guide Table of Contents: OBJECTIVES... 4 OVERVIEW OF NTER... 5 System Requirements... 5 NTER Capabilities... 6 What is the SCORM PlayerWhat
More informationNAVIGATION INSTRUCTIONS
CLASS :: 13 12.01 2014 NAVIGATION INSTRUCTIONS SIMPLE CSS MENU W/ HOVER EFFECTS :: The Nav Element :: Styling the Nav :: UL, LI, and Anchor Elements :: Styling the UL and LI Elements CSS DROP-DOWN MENU
More informationLab 2: Movie Review. overview.png background.png rottenbig.png rbg.png fresh.gif rotten.gif critic.gif
EDUCATIONAL GOALS Lab 2: Movie Review By the end of this lab, the student should be able to: Use Notepad++. Organize website contents. Use the basic of CSS and HTML for layout, positioning, and the CSS
More informationCOMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018)
COMS W3101: SCRIPTING LANGUAGES: JAVASCRIPT (FALL 2018) RAMANA ISUKAPALLI RAMANA@CS.COLUMBIA.EDU 1 LECTURE-1 Course overview See http://www.cs.columbia.edu/~ramana Overview of HTML Formatting, headings,
More informationThe default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:
CSS Tutorial Part 2: Lists: The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows: ul { list-style-type: circle; or
More informationInternet Programming 1 ITG 212 / A
Internet Programming 1 ITG 212 / A Lecture 10: Cascading Style Sheets Page Layout Part 2 1 1 The CSS Box Model top margin top border top padding left margin left border left padding Content right padding
More informationHTML/XML. HTML Continued Introduction to CSS
HTML/XML HTML Continued Introduction to CSS Entities Special Characters Symbols such as +, -, %, and & are used frequently. Not all Web browsers display these symbols correctly. HTML uses a little computer
More informationKB9000 Programmable Touch Bumpbar PROGRAMMING MANUAL
KB9000 Programmable Touch Bumpbar PROGRAMMING MANUAL Table of Contents 1 Introduction... 2 2 Software Installation... 2 3 Programming the KB9000... 3 3.1 Connecting the keyboard... 3 3.2 Starting the utility...
More informationFSA Algebra 1 EOC Practice Test Guide
FSA Algebra 1 EOC Practice Test Guide This guide serves as a walkthrough of the Algebra 1 EOC practice test. By reviewing the steps listed below, you will have a better understanding of the test functionalities,
More informationCIW: Advanced HTML5 and CSS3 Specialist. Course Outline. CIW: Advanced HTML5 and CSS3 Specialist. ( Add-On ) 16 Sep 2018
Course Outline CIW: Advanced HTML5 and CSS3 Specialist 16 Sep 2018 ( Add-On ) Contents 1. Course Objective 2. Pre-Assessment 3. Exercises, Quizzes, Flashcards & Glossary Number of Questions 4. Expert Instructor-Led
More informationHTML Exercise 21 Making Simple Rectangular Buttons
HTML Exercise 21 Making Simple Rectangular Buttons Buttons are extremely popular and found on virtually all Web sites with multiple pages. Buttons are graphical elements that help visitors move through
More informationCIW: Site Development Associate. Course Outline. CIW: Site Development Associate. ( Add-On ) 26 Aug 2018
Course Outline CIW: Site Development Associate 26 Aug 2018 ( Add-On ) Contents 1. Course Objective 2. Pre-Assessment 3. Exercises, Quizzes, Flashcards & Glossary Number of Questions 4. Expert Instructor-Led
More informationData Visualization (DSC 530/CIS )
Data Visualization (DSC 530/CIS 602-01) HTML, CSS, & SVG Dr. David Koop Data Visualization What is it? How does it differ from computer graphics? What types of data can we visualize? What tasks can we
More informationc122sep814.notebook September 08, 2014 All assignments should be sent to Backup please send a cc to this address
All assignments should be sent to p.grocer@rcn.com Backup please send a cc to this address Note that I record classes and capture Smartboard notes. They are posted under audio and Smartboard under XHTML
More informationJS Lab 1: (Due Thurs, April 27)
JS Lab 1: (Due Thurs, April 27) For this lab, you may work with a partner, or you may work alone. If you choose a partner, this will be your partner for the final project. If you choose to do it with a
More informationCorel Ventura 8 Introduction
Corel Ventura 8 Introduction Training Manual A! ANZAI 1998 Anzai! Inc. Corel Ventura 8 Introduction Table of Contents Section 1, Introduction...1 What Is Corel Ventura?...2 Course Objectives...3 How to
More information