Git Product home page Git Product logo

jscanvasgame's Introduction

jscanvasgame

little game framework with javascript and canvas.

Canvas to draw the elemets of your game, and JavaScript to do some action. Start with the a minimum of code, keyboard, mouse, touch and an animation loop is all we need.

  • objects can draw (no image handle, yet)
  • keycodes to define a keypress event
  • mouseclick return a position
  • touch (one finger now) return the position
  • FPS count (canvas can be very slow)

overview demo and scoure

// define the ball
var bPos = {x:50,y:50,w:10,h:10};
// define a direction object
var bDir = {x:-1,y:1};
...
function draw() {
  bPos.x += bDir.x*6;
  bPos.y += bDir.y*4;
  ...
  // test if the ball is outside the view
  if(bPos.y<0 || (bPos.y+bPos.h)>HEIGHT) {
    // if lower then 0 or greater than height -> change the direction
    bDir.y *= -1;
    }
  if(bPos.x<0 || (bPos.x+bPos.w)>WIDTH) { 
    bDir.x *= -1;
    }
}

Exsample code from tennis 4 two branch Add github pages, code exsample

jscanvasgame's People

Contributors

dexta avatar

Watchers

 avatar  avatar

Forkers

bliebke

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.