GithubHelp home page GithubHelp logo

ashwin6-dev / jump-p5js-game Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 1.9 MB

A game made using p5.js library

JavaScript 62.82% HTML 28.53% CSS 8.65%
game p5js p5js-game js javascript html css jump

jump-p5js-game's Introduction

Jump - A game made with p5.js

A game made using p5.js library. You can play this game here : https://ashwins-code.github.io/jump-p5js-game/Jump/

What is p5.js?

p5.js is a JS library which makes it easy to create 2D canvas graphics for the web. You can find more about it on their website https://p5js.org/.

Very basic example using p5.js

var x;
var y;
var width;
var height;

/* 

p5.js always needs a setup and draw function.

*/

function setup() {
  /*
    This is the first function that is called. It is where you should initialise the things that you need
  */
  
  createCanvas(500, 500) //creates a canvas that is 500px by 500px
  x = 250
  y = 250
  width = 50
  height = 50
}

function draw() {
  /*
    This function is called every frame. This is where you would write your code to draw to the canvas
  */
  
  background("black") // clears the canvas and fills it black
  rect(x, y, width, height) // draws a rectangle of width "width" and height "height" at position (x, y)
  
  x += 0.5
  y += 0.5
  
  // Note: position (0, 0) is the top left corner. This means increasing the the variable "y" moves the rectangle downwards (unlike normal coordinate systems) 
}

You can run this code in your browser or in the p5.js Web Editor (found here : https://editor.p5js.org/). You should find a white square moving towards the bottom right corner!

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.