90 likes | 109 Views
Programming Games. Show Virtual somethings. Review for midterm. Work session. Homework: Prepare for midterm. Research test. Write JavaScript code to change a certain img picture to classday.gif if it is Monday or Thursday. Fill in the ????. Write your source. d = new Date();
E N D
Programming Games Show Virtual somethings. Review for midterm. Work session. Homework: Prepare for midterm
Research test Write JavaScript code to change a certain img picture to classday.gif if it is Monday or Thursday. Fill in the ????. Write your source. d = new Date(); if ( ???? ) {place.src="classday.gif";} <body> <img name="place" src="notclass.gif"/>
Midterm review • Read the guide. • Review ALL the lecture notes. • Ask questions • Come to office hours • ???
Basic programming concepts • function • variable • datatype • event • array • operators • statements: assignment, if, for, switch, function call • notation (syntax): uses of parentheses, brackets, square brackets, pointy brackets
HTML basics • style, script and body elements • element consists of opening tag, contents of element, ending/closing tag. • opening tag has a type and may have other attributes including name, id, etc. • certain tags have specific attributes • a has href • img has src
Advice • Study midterm guide. The questions will be identical or strongly similar to these questions! • The midterm will NOT ask for large sections of code from the class projects.
Advice: Programming • organization of code • function definitions and variables (var statements) in <script> element • structured content in <body> element • In some applications, HTML elements are created dynamically. • event handling (responding to player actions, time) • buttons: using <button> or <a> or Form containing <input type="submit"> element • setInterval, setTimer • addEventListener
Advice: General • Plan: your design is independent of code, though when doing the coding, the design may evolve. • Work iteratively. Save with new names. Plan testing. • Make names meaningful to your program. • Distinguish names in html and names of internal variables and functions. • Avoid using the same name for different things. • Indent systematically for readability. JavaScript ignores it. • Note: Python uses indents, not { and } • Take advantage of tools: • Firefox: Web Console for catching syntactic errors plus incorrect names and missing files • Sublime: • save as .html to get color coding • Use Find • There are tools in other browsers and editors. • There are more debugging tools in Firefox and other browsers.
Homework • Study for midterm. • come to office hours today. • email with questions. • Make proposal (to the forum on moodle) with a topic for your midterm project. • It can build on previous projects. ….or not. • It must be your work. • Work on your JavaScript project.