Code Monkey home page Code Monkey logo

digitalcrafts-meetup-pacman's Introduction

MizPacman: a simple game in JavaScript + CSS + HTML

Thanks to DojoAcademy for the original tutorial!

This is an adaptation of their code, for DigitalCrafts's JavaScript meetup.

Goals

This is not a full game. It's a way to demonstrate how web pages work. It relies only on the core technologies found in every modern browser: HTML, CSS, and JavaScript.

Review questions

By the end of the tutorial, you should be able to answer these questions:

  • How does a browser work with HTML?
  • How does the browser draw?
  • What does CSS stand for?
  • How do you make a web page use CSS?
  • What is the box model?
  • In CSS, what is the cascade?
  • How do you make a web page interactive?
  • How do you make a web page use javascript?
  • What is a variable?
  • What is a function?
  • What is an event?

Guidelines

To get the most out of this tutorial:

Setup

Overview: How do web pages work?

Most web pages are built using these three technologies: HTML, CSS, and JavaScript

what is html

  • HTML stands for HyperText Markup Language
  • You write HTML using tags, of which there are many.
  • A <div> is a generic tag, great for games, not great when you need more specific tags.
    • (For example, the HTML for a blog post should use paragraph tags: <p>.)
  • Tags are meant to structure and organize your content.
  • Your content can be text, images, video, etc.
  • You can nest tags inside one another.
    • You might have a paragraph (as a p tag) and an anchor tag (an a tag).
    • In this case, the anchor tag is nested inside of the paragraph tag

What is CSS

  • CSS stands for Cascading Style Sheets.
  • The tags you write in your html have to be drawn to the screen.
  • For every tag, the browser draws a rectangle.
  • You have to tell the browser how to draw the rectangles.
  • There are default styles built into the browser, but you can specify custom ones.
  • The best way to associate styles with an element on the page? use classes

Using JavaScript

  • A variable is a programming term for a label or an identifier.
    • You need variables so that you can refer to data using a convenient name.
  • What is a function?
    • A function is like a recipe, which contains one or more steps.
    • A function can be used over and over again.
    • Usually, a function takes input (called "arguments") and returns output.
  • What is an event?
    • As you click, tap, scroll, and type, your browser responds. Each of these interactions is called an event.
    • You can customize how the browser responds by writing functions that handle different kinds of events.

For the more curious: requestAnimationFrame

If you were to add more complexity (ghosts, time limits, etc.), you should check out the requestAnimationFrame API. An excellent introduction is here.

Some handy keyboard shortcuts in vs code:

  • move line up/down: opt + up/down
  • toggle comment: cmd + /

You can find a listing of more shortcuts on the vs code website.

digitalcrafts-meetup-pacman's People

Contributors

radishmouse avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.