Git Product home page Git Product logo

phaser-pointline's Introduction

Phaser Point-Line

A simple movement / physics system built for Phaser 3 based on points and lines

Usage: Simply instantiate the object at the start of your create() function. For Debug drawing to work correctly, the graphics object must be created at the end of your create() function:

create(){
   this.pointLine = new Pointline(this, gravity, debug);
   
   //add a dynamic body (with sprite)
      this.player.sprite = this.pointLine.addSprite(
         this.xInit,  	                                          //initial world X value
         this.yInit, 	                                          //initial word y value
         2.5, 				                                          //wdith / 2 of bounding box
         'player', 		                                          //which sprite from loaded adssets
         0, 				                                          //X offset of body point
         0				                                             //y offset of body point
      );
      
  //add a line
      let floor = this.pointLine.addLine({
         type : 'ground',                                         //could be 'wall' or 'platform' or 'slope'
         coords : {x1:0, y1:-7},                                  //coords of first point (leftmost or bottom most)
         length : 1000,                                           //or height for walls
         checkDirections : {checkUp:true, checkDown:false},       //checkLeft or checkRight for walls
         velMult : 1                                              //how fast do objects move on this (ground / platforms / slopes only
      });
   
   //world collisions
      this.pointLine.addWorldCollider(0,0,1000,160);             //world boundaries
      this.pointLine.addToWorldCollider([this.player.sprite]);   //add player to world collider

   //player collisions
      this.pointLine.addCollider('lines', this.player.sprite);   //add a collider for the player sprite
      this.pointLine.addToCollider('lines',floor);               //add the floor to that collider, also accepts array of lines
   
   /*
   * Everything else
   */
   
   this.pointLine.gfx = this.add.graphics();
}

phaser-pointline's People

Contributors

erbarratt 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.