Skip to Navigation | Skip to Content

MAT 175 - Web Design - JavaScript + jQuery

Menu

Class Schedule

Week 1 (1/25)

Topics and Learning Objectives

  • Overview/Introduction to the Class and Syllabus
  • Basic Programming Concepts
  • Overview of JavaScript and Programming
  • The Language of JavaScript

TASKS

Recommended and/or supplemental tasks

Videos and tutorials

About Code

Code.org - Hour of Code

  • Hour of Code (~1 hour)
    Made for "kids of all ages" this is a simple and fun introduction to programming concepts and a good way to get your feet wet.

Overview of Our Class and JavaScript Programming :: Instructor Videos

Hello World :: Instructor Videos

  • Where To Put Your Code (14:20)
    Hello world, <script tags>, inline vs. external code
  • Output and Console (14:56)
    Hello World x 4 (alert, console.log(), document.write, innerHTML() and the browser console)

Codecademy - Interactive Tutorials

LINKS & Resources

The Book

JavaScript Resources and Reference

> Go to Top

Week 2 (2/1)

Topics and Learning Objectives

  • Introduction to the HTML5 Canvas Exercise
  • Working with <canvas> and JavaScript APIs for drawing
  • Drawing primitive shapes with code
  • Defining drawing functions and making our own drawing plugin

Tasks

Recommended and/or supplemental tasks

  • Review this JavaScript Basics Crash Course/Documentation from the Mozilla Developer Network (recommended)
  • Check out some or all of The JavaScript Programming Language (1:49:54) - A good overview with some history of the JavaScript Programming language from one of the foremost experts, Doug Crockford (author of JavaScript: The Good Parts). This is from a course/presentation at Yahoo and oriented towards a programmer/developer audience. As such, you may not understand all of it, but that's okay. It's still worth watching if you're interested. (optional)

Videos and tutorials

Exercise #1 - Canvas Drawing - Instructor Videos

Codecademy - Interactive Tutorials

Codecademy - Interactive Tutorials

Exercise #1: Canvas Drawing Exercise (Due 2/8)

Explore drawing with the HTML5 <canvas> tag and JavaScript.

Adhere to the following guidelines:

  • Create 3 drawings/web pages that use the <canvas> tag and JavaScript.
    1. One of the drawings should represent your basic coding exploration of the <canvas> tag and JS for creating primitive shapes (lines, rectangles, circles, triangles) with varied fills, strokes, colors, and line-widths. It does not need to be particularly artistic, but should have sample code similar to (but not identical to/forked from) the video tutorial demos.
    2. One of your drawings should be sketched on paper first and then translated to code/canvas. Include a photo or scan of your paper sketch on the webpage along with the rendered canvas. Strive to create something compositionally interesting and well-balanced, but comprised of relatively simple/primitive shapes (rectangles, lines, circles, etc.).
    3. One of your drawings should be conceived of and made with code-only (not on paper first) using a drawing functions/plugin that you create (as discussed in the video tutorial on Creating Custom Functions for Drawing). Strive to create something artistic and somewhat more complex.
  • Design at minimum size of 300 x 300 and a maximum size of 1920 x 1080. Each drawing does not need to be the same size.
  • Perhaps, take inspiration from modernists such as Piet Mondrian or Wassily Kandinsky or artists and designers from the Suprematist or Bauhaus movements who creatively utilized primitive shapes within their artwork.
  • Put your name somewhere on the webpage(s).
  • Create an "exercise1" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpages(.html) and JavaScript(.js) files to this folder on the server. See FTP Information for details.
  • Choose your favorite from among your rendered canvas images, right-click on it to "Save Image As" and get a .png file, and include it in your reply to the Canvas Discussion Board set up for this purpose.
  • Be creative and have fun.

LINKS & Resources

JavaScript Resources and Reference

Canvas Resources

> Go to Top

Week 3 (2/8)

Topics and Learning Objectives

  • Core Programming Concepts
  • Variables and Datatypes
  • Numbers and Math
  • Math.random() and other Math object methods
  • Comparison and Logical Operators
  • If/Then Conditional Logic and Decision Making

Tasks

  • Complete Exercise #1 (due 2/8) and participate in the Exercise #1 - Canvas Drawings and Reflection discussion
  • If you have not yet do so, create your "codeLibrary" folder on the MAT server and add at least one file to it to get it started. See the introduction to the code library video below for more information.
  • Read Chapter 3 on Functions (pp. 85 - 99) and Chapter 4 on Decisions (pp. 145 - 169) in the JavaScript & jQuery textbook by John Duckett (available for free through O'Reilly Books Online)
  • On Codecademy.com, complete the Introduction to JavaScript - Conditional Statements module (as per below)
  • Complete Quiz #2 (by 2/15) - Covers the Week #3 topics/videos
  • Begin work on Exercise # 2 (due 3/1)
  • View the Week #3 Videos and Tutorials below

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Introduction to Exrercise #2, my videos, and the codeLibrary

Linting and JavaScript Linting Errors in Dreamweaver

Variables and Values

Numbers and Math

Conditional Logic and Decision Making

Codecademy - Interactive Tutorials

Exercise #2: SIMULATE THE GAME OF CRAPS (Due 3/1)

Rules of the game:

In the game of Craps, a "Pass Line" bet proceeds as follows. Using two six-sided dice, the first roll of the dice in a craps round is called the "Come Out Roll." The bet immediately wins when the come out roll is 7 or 11, and loses when the come out roll is 2, 3, or 12. If anything else is rolled (4, 5, 6, 8, 9, or 10) on the come out roll, that number becomes "the point." The player keeps rolling the dice until either 7 or the point is rolled. If the point is rolled first, then the player wins. If the player rolls a 7 first, then the player loses.

Your basic task (the threshold for a 'C'):

Write a JavaScript program that plays the game of craps using the rules stated above. The program should simulate a game and calculate if the player would win or lose.

1) Simulate one game of craps correctly and output the come out roll, the point roll (the final point roll, if there is one), and result of the game (if the player won or lost).

Include some styling (using CSS and/or JS) so that the output and interface is reasonably attractive and the game doesn't just output to console (such as representing the dice as images, styling the text output, or creating a visual interface for the game).

Even better (the threshold for a 'B'):

2) Make this interactive so that a user can play (i.e. initiate the dice roll and/or set a bet amount).

Better still (the threshold for an 'A'):

3) Make the UX and/or UI really nice. Make the user interface (UI) nice through graphic design, imagery/graphics, and CSS styling. Make the user experience (UX) nice through interaction design, such as providing engaging interactivity, user feedback, using animation to convey dice rolls or other activity, and generally creating a pleasant 'playing' experience.

Even better again (to the point of potential extra credit):

4) Allow a choice to "Simulate 1000 games" of craps based on $10 wagers and a $1000 starting bankroll and track/output the number won, the number lost, and the amount of money left in the bank roll after the 1000 games.

5) In addition to #4 above, create/draw a graph that tracks the bankroll across all 1000 games, updating the graph with each roll. (i.e. visualize the data).

6) Or, do other stuff... Such as simulating 10,000 games and computing the probability of winning (i.e. Wins / (Wins + Losses). Or do something else... fork the idea, take it in a different direction. Create a different game even.

Finally, turn in your exercise and reflect upon it:

Create an "exercise2" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpage(.html/.css) and JavaScript(.js) files to this folder on the server. See FTP Information for details.

Once you've completed your exercise, participate in the Exercise #2 Review and Reflection Discussion in Canvas.

To follow along with the videos tutorials, you are welcome to use my dice imagery as graphic resources (dice.zip).

LINKS & Resources

> Go to Top

Week 4 (2/15)

Topics and Learning Objectives

  • Working with Functions
  • Applying Programming Concepts to Simulate a Game of Craps
  • User Input
  • Visualizing Output
  • Making the Craps Game Interactive and Playable

Tasks

Videos and Tutorials

Working with Functions

  • Functions, Part 1 (11:12)
    Introduction to functions. Declaring and calling functions.
  • Functions, Part 2 (12:23)
    Using parameters and passing arguments. Working with multiple arguments (examples including a keepScore() function and a madLibs() generator)
  • Functions, Part 3 (17:06)
    Returning values from functions (examples including functions for inserting copyright dates and Celsius to Fahrenheit converters)
  • Functions, Part 4 (19:39)
    Function expressions, immediately invoked function expressions (iife), recursive functions.

Simulating a Game of Craps - Exercise #2 Demos

  • Craps, Part 1 (6:13)
    Variables and Math.random() to simulate a dice roll
  • Craps, Part 2 (19:47)
    Visualizing the output of the dice with text and image (image.src). Random images. (Feel free to download dice.zip to obtain the dice imagery).
  • Craps, Part 3 (15:24)
    Visualizing output with sprite sheet image and CSS background position (setAttribute)
  • Craps, Part 4 (21:17)
    Understanding the game logic, using if conditional statements and a rollDice() function
  • Craps, Part 5 (19:51)
    Making the game interactive so the user can play, using addEventListener to add click events
  • Craps, Part 6 (15:08)
    Adding user feedback, creating win() and lose() functions.
  • Craps, Part 7 (8:08)
    Tracking bets and the chip stack using variables.
  • Craps, Part 8 (19:41)
    Using an input field to enable the user to change the bet amount and extracting and validating the value of this field (value, paseInt, isNaN).
  • Also see bonus videos in Week #5

Codecademy - Interactive Tutorials

LINKS & Resources

> Go to Top

Week 5 (2/22)

Topics and Learning Objectives

  • Working with Functions
  • Working with Loops
  • Making the Craps Game Interactive and Playable

Tasks

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Simulating a Game of Craps - Bonus Videos

Looping and Iteration

CodeCademy - Interactive Tutorials

LOOPS Code Challenge - GOOD OR BAD DEAL (DUE 3/8)

This coding challenge is required (I want you to try to accomplish it and it will count towards your class participation), but it will not hurt your grade if you don't solve it. However, if you accomplish it and come up with the correct answer, I will provide extra credit (2%).

The Scenario

In what you suspect is a trick, a mysterious man says he'll give you one million dollars with the caveat that you have to pay him back starting with 1 penny and then double that amount for 30 days. In other words, you would give him 1 penny (.01) on day 1, two (.02) pennies on day 2, 4 (.04) pennies on day 3, 8 pennies on day 4 etc. such that you continuously double the amount of the previous day's payment each day for a month (30 days).

Is the total sum that you would pay more or less than one million dollars? In other words, is this a good or bad deal? If a bad deal, on what day would it become so?

Your Task

Using JavaScript and loops (for, while, or do while), write some code to determine if this is a good or bad deal. If a bad deal, make your code output the day on which it would it become so. Respond with your solution in this discussion forum in Canvas (replies to which you will not be able to access until you post your own solution).

I will provide my own solution after 3/8 (so this is a hard deadline for this extra credit opportunity).

LINKS & Resources

> Go to Top

Week 6 (3/1)

Topics and Learning Objectives

  • Exercise #2 Review
  • Loops Code Challenge
  • Approaching Programming Problems: Computational Thinking, Algorithms, Pseudo-Code, FlowCharts
  • Generative Art — Drawing to <canvas> using JavaScript Variables, Loops, Functions, Conditionals, and Randomization

Tasks

Videos and Tutorials

On Computational Thinking and Problem Solving

Generative Art and Exercise #3 Demos— Drawing to <canvas> using JavaScript Variables, Loops, Functions, Conditionals, and Randomization

CodeCademy - Interactive Tutorials

Exercise #3: generative art with the html5 canvas and JavaScript (Due 3/15)

Generative art is art that creates itself, somewhat autonomously, while embracing randomness and chance as an organizing principle. Generative artists intentionally introduce randomness as part of the creation process, such that the same program (or process) in generative art will produce novel results each time it is run.

Your Task

Explore creating generative art by drawing to the HTML5 <canvas> using JavaScript variables, functions, loops, conditionals, and randomization techniques.

In this exercise, we will revisit and extend upon the topics from the Canvas Drawing Exercise (Exercise #1) by adding many of the programmatic concepts that we have learned since, such as working with Math randomization, variables, loops, conditionals, and functions.

Your task is to program a 'generative' artwork that builds upon what you have learned in the class thus far. Start by viewing the generative art video tutorials provided. Perhaps, draw insipration from this article on 'Why Love Generative Art" which provides a good overview and some historical context for generative art.

Then, try to make your own generative artwork using the HTML5 <canvas> and JavaScript. Your program/artwork can rely on relatively simple primitive shapes (lines, rectangles, triangles, circles, etc.), but should produce different results each time the browser is refreshed (or the artwork is 'clicked'). This means that it must use variables and randomization in some way. You are encouraged to also explore working with loops, functions, conditionals, etc. as appropriate to your program and creative vision. While generative artworks embrace some level of chaos, try to create something that you find artistically interesting and aesthetically appealing. Consider creating your own custom color palette that can be randomly applied and/or creating generative patterns, such as iterative tiling patterns that might be applied to wallpaper or fabric. Design at any size you wish up to a maximum size of 1920 x 1080.

Upload and Reflect

Create an "exercise3" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpages(.html) and JavaScript(.js) files to this folder on the server. See FTP Information for details.

Once you've completed your exercise, participate in the Exercise #3 Review and Reflection Discussion in Canvas.

To follow along with the videos tutorials related to generative art, you are welcome to use this starter file and code (generative.zip).

LINKS & Resources

> Go to Top

Week 7 (3/8)

Topics and Learning Objectives

  • Strings and String Methods
  • Working with Arrays
  • Array Methods
  • Working with Arrays, Loops, Functions, Logic
  • Applying Arrays - Simple Interactive Quiz and Guessing Game Examples

Tasks

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

Strings and String Methods

Working with Arrays

  • Arrays, Part 1 - Introduction (12:13)
    Introduction to arrays. Accessing array data. Arrays with values of varying types. Short intro to multidimensional arrays.
  • Arrays, Part 2 - Creating (11:26)
    Creating arrays. Array Constructors and Array Literals. Accessing array elements by their index.
  • Arrays, Part 3 - Looping (14:38)
    The array length property. Looping through arrays with the for loop and for in loop.
  • Arrays, Part 4 - Methods (16:41)
    Array methods including toString(), join(), sort(), reversw(), concat(), and slice().
  • Arrays, Part 5 - Methods (16:37)
    Array methods including push(), pop(), shift(), unshift(), and splice().

Interactive Quiz Example using Arrays, Loops, and Functions (and Prompt)

  • Quiz Example, Part 1 (10:42)
    Using prompt() for output/input and basic quiz logic.
  • Quiz Example, Part 2 (20:23)
    Using arrays and multidimensional arrays to store quiz questions, for loops to access the questions, and a custom function to ask the questions and check the answer logic.

Interactive Guessing Game Example

CodeCademy - Interactive Tutorials

LINKS & Resources

> Go to Top

Week 8 (3/15)

Topics and Learning Objectives

  • The Document Object Model (DOM)
  • Accessing and Modifying HTML and CSS content
  • Events, Event Handling, and Interactivity

Tasks

Recommended and/or supplemental tasks

Review of the following documentation from the Mozilla Developer Network is recommended:

Videos and Tutorials

The Document Object Model (DOM)

Events and Event Handling

CodeCademy - Interactive Tutorials

Exercise #4: Interactive quiz, interactive story, or guessing game (DUE 4/7)

Design and program an interactive quiz, interactive short story, or interactive guessing game of some kind.

If you choose to do an interactive quiz, consider personality quiz games such as "What kind of ___ are you?" or "Which ____ character are you?" as models. If you chose to do an interactive story, consider choose-your-own adventure games with branching options based on user choices as models. If you choose to do a guessing game, consider games like battleship or hangman as models. While these may serve as models, the assignment is open to your unique interpretations. In any case, you will need to provide instructions, allow for user input (of answers or choices), and then display appropriate accompanying output or feedback (based on user answers or choices). Your exercise should include a user interface and appropriate JavaScript programming as per below.

Your User Interface

Create/design an attractive and usable user interface with HTML and/or JavaScript that provides the user with instructions, allows for user input (of answers or choices), processes that input, and then displays appropriate accompanying output or feedback (based on user answers or choices). Try to make the user interface (UI) and user experience (UX) nice through graphic design, interactivity, imagery/graphics, and CSS styling.

Your JavaScript Program

Explore JavaScript programming techniques and logic in the construction of your exercise. Use variables, functions, conditional statements and logic, loops, arrays, objects, DOM and event scripting, and/or other programming as appropriate to your concept. Allow for user input via prompts, input fields (such as text fields or radio buttons), or mouse or keyboard events. Generate dynamic output and/or feedback in the browser (in the form of text, images, alerts, etc.) using .textContent, .innerHTML, document.write(), by manipulating the CSS (adding or removing a className), or other methods.

Submit and Reflect

Put your name somewhere on the interface, webpage, or code (such as using comments at the top). Create an "exercise4" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpage(.html/.css) and JavaScript(.js) files to this folder on the server. See FTP Information for details. Once you've completed your exercise, participate in the Exercise #4 Review and Reflection Discussion in Canvas.

LINKS & Resources

> Go to Top

Spring Break (3/22) - No Class This Week

  • Go the beach
  • Get some rest
  • Do some catching up

> Go to Top

Week 9 (3/29)

Topics and Learning Objectives

  • Applying Arrays, Loops, Functions, Conditionals, the DOM, Events + More
  • Interactive Quiz Demo/Example
  • Audio Quiz Game Demo/Example
  • Focus on Exercise #4

Tasks

Videos and Tutorials

Interactive Quiz - Mobile Application Example

JavaScript Bell Choir Interactive Quiz Game - Bonus Example

LINKS & Resources

> Go to Top

Week 10 (4/5)

Topics and Learning Objectives

  • Introduction to jQuery
  • jQuery Features/Benefits
  • Using jQuery to find/select DOM elements
  • Getting and setting HTML attributes and CSS styles with jQuery
  • jQuery and Events
  • jQuery and Effects/Animation

Tasks

Exercise #5A: Interactive, anImated Slideshow, content slider, or filter gallery using jQuery (Due 4/19)

Invent, design and program an interactive and animated slideshow, content slider, or filter gallery (or something similar) using jQuery and JavaScript.

Your exercise and your jQuery must be custom-made by you and not use prepackaged plugins or other people's code (other than reference to the jQuery library itself and, of couse, you may use the sample code I provide in the videos). You may use jQuery objects/methods exclusively or combine jQuery with native (or "vanilla") JavaScript.

Design an an attractive user interface for your exercise. Animate the transitions between your content sections and/or images (such as by using crossfade effects or slide in/slide out effects). Enable some form of interactive control over your content for the user (such as the ability to progress, go forward and back, or start and stop).

Create an "exercise5a" folder within your "Lastname_Firstname" folder on the MAT server. Upload your webpage(.html) and dependent files (images, .js, .css) to this folder on the server. See FTP Information for details.

Exercise #5B: Explore a jQuery plugin (Due 4/21)

Research jQuery plugins, find one you like, implement it in a webpage to provide a use-case example, and comment on your experience with it in Canvas.

Begin by researching/reviewing jQuery plugins via the plugin directory at jQuery, via web searches, or via some of the links below (to plugins I've used or have liked).

Once you have found a plugin that interests you, implement it on a sample webpage. Most plugins come with documentation about how to use them. Review this documentation and create your own example of the use or application of the plugin on a sample page. If the plugin has customization options, explore these options (as you feel appropriate to your concept and understanding of the plugin's capabilities).

Create an "exercise5b" folder within your "Lastname_Firstname" folder on the MAT server. Upload your sample webpage and any dependent files to this "exercise5b" folder. See FTP Information for details.

Partcipate in the Canvas discussion forum and comment on your experience with Exercises 5A and 5B. Include links to your sample webpages. Explain what plugin you used and what it can do or why someone might use it (include a link to the plugin's homepage too). Also comment on your experience implementing the plugin and some of its customization options (if any).

Videos and Tutorials

jQuery

Links & Resources

jQuery

Google Hosted Libraries /CDN for jQuery

W3 Schools

SOme Plugins to explore

> Go to Top

Week 11 (4/12)

Topics and Learning Objectives

  • Applying jQuery Selectors, DOM Manipulation, CSS, Events, and Effects
  • Slideshow jQuery Application Examples
  • Work on Exercise #5 (A + B)

Tasks

Videos and Tutorials

jQuery Interactive Slideshow Example #1 with Thumbnails and Foward/Next Buttons - Execise #5A Demos

jQuery Slideshow Example #2 with Pause/Play Interactivity - Exercise #5A Demos

Links & Resources

> Go to Top

Week 12 (4/19)

Topics and Learning Objectives

  • More jQuery fun
  • Applying jQuery to a Web App - List-O-Mania Example
  • jQuery UI (sortable, drag and drop +)

Tasks

Videos and Tutorials

Applying jQuery to Create a List-Making Web App (Exercise #6 Demos)

Exercise #6: List-O-Mania — jQuery Web App (Due 5/3)

Your basic task:

Create a "list-making" web application, programmed using jQuery and JavaScript. The application should allow a user to add and remove items from a list.

Center your app around a theme (such as a grocery or shopping list, a packing list for travel or camping, a to-do list, a rankings list, a "movies I want to see" list, etc.). In other words, focus your app on a particular type of list and use that type to dictate the style and functionality of the user interface (UI) and user experience (UX).

Include some styling (using CSS and/or graphics) so that the interface is attractive and user friendly.

Apply your knowledge of jQuery (but you may also use native JavaScript) in the creation of your web app. The app can be any kind of list-making application wherein the user can add and delete items from a visual list (by visual, I mean that this list should display within the user interface in the browser and not simply be tracked internally or output to console or something).

You may wish to enhance your app through:

  • Animating the addition or deletion of items (or other things) using jQuery animation methods, such as slideDown(), fadeIn(), animate(), etc.
  • Allowing the user to mark, select, or "check off" list items (to mark them as complete or accomplished or featured in some way)
  • Allowing the user to re-order the list by drag and drop (or other means)
  • Using the HTML5 localStorage Web API to store list item data locally within the user's browser (or phone).
  • Making the UX and/or UI really nice
  • Making the web app mobile friendly (using media queries or responsive design principles so that it works well on mobile phones and tablets)
  • Doing other things (creativity and/or extra functionality is always welcome)

Turn in your exercise and reflect upon it:

Create an "exercise6" folder within your "Lastname_Firstname" folder on the MAT server. Upload your webpage(.html) and dependent files (images, .js, .css) to this folder on the server. See FTP Information for details.

Once you've completed your exercise, participate in the Exercise #6 Review and Reflection Discussion in Canvas.

Links & Resources

jQuery

jQuery UI Library

  • jQuery UI (a set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library)

jQuery Touch Punch

Google Hosted Libraries /CDN for jQuery

W3 Schools

> Go to Top

Week 13 (4/26)

Topics and Learning Objectives

  • Working with the HTML5 localStorage API
  • More jQuery fun
  • Sprite sheet animations
  • Creating sprite sheets
  • Animating sprite sheets with JavaScript and HTML5 <canvas>

Tasks

Videos and Tutorials

The HTML5 Web Storage APIs (localStorage) and the List-O-Mania App

Generating Sprite Sheets for Animation (for Exercise #7)

Note: For our next exercise (introduced in Week #14), you will need to create a sprite sheet for an animated character. To get a jump on that, these videos review the process.

Links & Resources

jQuery

jQuery UI Library

  • jQuery UI (a set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library)

jQuery Touch Punch

Google Hosted Libraries /CDN for jQuery

W3 Schools

HTML5 Web Storage API

> Go to Top

Week 14 (5/3)

Topics and Learning Objectives

  • Animating sprite sheets with JavaScript and HTML5 <canvas>
  • Using requestAnimationFrame() for animation
  • Controlling frame rates and bounding areas
  • Adding keyboard controls for interactivity
  • Working with objects

Tasks

Videos and Tutorials

Generating Sprite Sheets for Animation (for Exercise #7)

Note: These were posted last week. But, I include them again here as Exercise #7 requires that you create a sprite sheet for an animated character.

Drawing Images and Animating Sprites with HTML5 Canvas and JavaScript (Exercise #7 Demos)

Sprite Sheet Image Files Used in Above Examples:

CodeCademy - Interactive Tutorials

Exercise #7: Sprite Sheet Character/game animation (Due 5/17)

Explore JavaScript game programming and animation concepts by creating a sprite sheet for an animated character/object that the user can interactively control and/or move with the keyboard (or mouse).

Your basic task:

Using Photoshop, Animate/Flash, or After Effects (or other software), create/design sequential/animated graphics for a character/object that can fly, swim, walk, run and/or jump. In general, your character should probably be animated to show the source of its propulsion (such as animated wings, legs, fins, or fire out of a rocket engine), but exactly the nature of the animation is up to you. Consider an animation that requires about 5 to 15 'frames' or separate images to complete the animation cycle (but you can do more or less frames if it works for your concept). The size of the character is up to you, but probably should be in the range of 100 - 300 px in height/width (so that it fits well on screen with some room to move).

Once you've created your graphics, export them to a sprite sheet (a single .png image that contains each of the 'frames' of your character animation evenly spaced such that each frame has the same height and width). Though many sprites sheets organize the images within into both rows and columns, to keep things simpler, I recommend creating an image with your 5 to 15 frames/images aligned horizontally (or vertically but not both).

Using your sprite sheet, JavaScript, and the HTML5 <canvas>, program a webpage (using the requestAnimationFrame() method and canvas drawing API) with your sprite animation such that your character animates on the screen.

Better:

Use keyboard or mouse input (events) to allow the user to interactively control the sprite animation and/or the movement (x, y position) of the character on screen.

Better still:

Consider adding some programmatic physics (gravity, friction, thrust, wind resistance, etc.) to the movement to make it seem more natural.

Better again:

You may wish to also create and animate background graphics in relation to your character's movement (perhaps using parallax scrolling and foreground, middle ground, or background animations that move in relation to the character).

Much better:

Add other elements or interactions to turn this more into a game. Optionally, consider utilizing libraries like Create JS or Phaser or p5.js to make things easier.

Finally:

You can use any size you think appropriate for your HTML5 canvas, but I recommend a size of 960 x 640 ( a reasonably common baseline size for HTML5 games).

Create an "exercise7" folder within your "Lastname_Firstname" folder on the mat server. Upload your webpage(.html) and dependent files (images, .js, .css) to this folder on the server. See FTP Information for details. Once you've completed your exercise, participate in the Exercise #7 Review and Reflection Discussion in Canvas.

Links & Resources

Sprite Sheet Image Files Used in Above Examples:

Mozilla Developer Network - Guide/Documentation

W3 Schools - Guide/Documentation

Using requestAnimationFrame and Spritesheets

> Go to Top

Week 15 (5/10)

Topics and Learning Objectives

  • Exploring game design and animation with JavaScript and HTML5 <canvas>
  • Working with objects to create a sprite object prototype and then looping through sprites to draw each object to the screen
  • Adding keyboard controls to your animated characters
  • Adding physics for more realistic motion
  • Adding and animating background graphics
  • Some 'shooting' game code

Tasks

Videos and Tutorials

Drawing Images, Animating Sprites, and HTML5 Gaming with Canvas and JavaScript (Demos for turning Exercise #7 into more of a Final Project)

Links & Resources

Mozilla Developer Network - Guide/Documentation

W3 Schools - Guide/Documentation

> Go to Top

Week 16 (5/17)

Topics and TASKS

There are no new tutorials this week. Your focus is on your final project.

> Go to Top

Week 16 (5/24) - The Current Week

TOPICS

  • Final Project Review and Reflection
  • Class Wrap Up and Evaluation

Tasks

The final day to turn in any work for grading consideration is Friday, 5/26. i cannot accept any late work beyond this date.

> Go to Top