All Projects → notchris → phaser3-planck

notchris / phaser3-planck

Licence: other
Implement planck.js physics in Phaser3

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects
CSS
56736 projects

Projects that are alternatives of or similar to phaser3-planck

Platform-game
I built a platform game, Grab Fruits!, with Phaser library. A player is expected to collect as many fruits as possible without touching spiders.
Stars: ✭ 26 (+44.44%)
Mutual labels:  phaser3
shooterGame
This project is about a platform/shooter game created with Phaser JS to learn the basic structure of Phaser
Stars: ✭ 13 (-27.78%)
Mutual labels:  phaser3
ts-phaser-bomb-game
Bomberman clone using websockets and phaser 3
Stars: ✭ 18 (+0%)
Mutual labels:  phaser3
starfall-phaser3-typescript
A tiny game written on Phaser 3 on Typescript
Stars: ✭ 52 (+188.89%)
Mutual labels:  phaser3
phaser3-faq
A guide to Phaser 3
Stars: ✭ 69 (+283.33%)
Mutual labels:  phaser3
phaser3-dungeon-crawler-starter
A starter project for creating a Dungeon Crawler with Phaser 3
Stars: ✭ 69 (+283.33%)
Mutual labels:  phaser3
genie-starter-pack
This is the Starter Pack for Genie games. Containing everything a games developer might need to start building a game using the Genie framework. Every game should be forked into a new repository from this repo.
Stars: ✭ 15 (-16.67%)
Mutual labels:  phaser3
phaser3-typescript-template
A Phaser 3 TypeScript Template
Stars: ✭ 30 (+66.67%)
Mutual labels:  phaser3
infinite-jumper-template-phaser3
Starting point template source code from Infinite Jumper in Phaser 3 in Modern JavaScript book.
Stars: ✭ 46 (+155.56%)
Mutual labels:  phaser3
phaser3-simple-rpg
A simple Phaser3 RPG using Typescript ⚔️
Stars: ✭ 80 (+344.44%)
Mutual labels:  phaser3
genie
BBC Genie Games Framework
Stars: ✭ 23 (+27.78%)
Mutual labels:  phaser3
space-commit
The game where contributors become literal heroes! 🏆 Winner of the GitHub Actions Hackathon 2021
Stars: ✭ 37 (+105.56%)
Mutual labels:  phaser3
phaser3-multiplayer-game-example
Phaser 3 multiplayer game example using geckos.io
Stars: ✭ 114 (+533.33%)
Mutual labels:  phaser3
Opensc2k
OpenSC2K - An Open Source remake of Sim City 2000 by Maxis
Stars: ✭ 4,753 (+26305.56%)
Mutual labels:  phaser3
phaser-plugin-game-scale
Scale or resize the game canvas. Phaser v3.15 only
Stars: ✭ 35 (+94.44%)
Mutual labels:  phaser3
phaser-parcel
A Phaser 3 game template using Parcel bundler
Stars: ✭ 64 (+255.56%)
Mutual labels:  phaser3
phaser-3-vsc-typescript-nodejs
Template for a new Phaser 3 project with Visual Studio Code, TypeScript, and Node.js.
Stars: ✭ 18 (+0%)
Mutual labels:  phaser3
phaser-jam-template
A Phaser Template to kick off your Game Jam with everything you need. Typescript, code quality, building for itch, various input methods, examples, bootloader, preloader, main game, end screen, credits screen and license screen.
Stars: ✭ 18 (+0%)
Mutual labels:  phaser3
mmo-arch
Base Architecture for creating scalable games using microservices through Angular, Phaser, NestJS, NATS, and MySQL
Stars: ✭ 25 (+38.89%)
Mutual labels:  phaser3
phaser-ui-comps
Phaser 3 UI Components built by Adobe Animate
Stars: ✭ 60 (+233.33%)
Mutual labels:  phaser3

Phaser3 Planck Physics Plugin

This plugin integrates the Planck.js (Based on Box2d) physics engine with Phaser3, allowing for advanced collision detection and dynamic body types. This plugin is still in development, please feel free to submit a PR or issue to help us improve this integration.

Examples

Features

  • Support for Planck bodies (Box, Circle, Polygon, Edge)
  • Distance Joints, Revolute Joints, Conveyers
  • Sensors & Collision Filtering
  • Trajectory projection
  • ...and more!

Installation

You can install the latest version of phaser3-planck with your package manager.

npm install -S phaser3-planck

Usage

Setup

First, import the package and update your global game configuration to include the plugin.

import PhaserPlanck from 'phaser3-planck'
const  config = {
	type:  Phaser.AUTO,
    width: 640,
    height: 480,
    plugins: {
        scene: [
            { key: 'PhaserPlanck', plugin: PhaserPlanck, mapping: 'planck' }
        ]
    },
    physics: {
        planck: {
            debug: false,
            scaleFactor: 30,
            gravity: {
                x: 0,
                y: 3
            }
        }
    },
	scene: []
};

new  Phaser.Game(config);

Creating Bodies

You can create different bodies in your scene using the following syntax:

// Box
const box = this.planck.add.sprite(0, 0, 'boxSprite')
box.setBody('box')

// Circle
const circle = this.planck.add.sprite(0,0,'circleSprite')

// Polygon
const polygon  = this.planck.add.sprite(0, 0, 'polygonSprite')
polygon.setBody('polygon', {
    points: [[0,64],[64, 64], [64, 0]]
})

// Edge (Line)
const edge = this.planck.add.sprite(0,0,'edgeSprite')
edge.setBody('edge', {
    x1: 100,
    y1: 100,
    x2: 300,
    y2: 200
})

Configuring Bodies

The central Body class that all bodies extend, provides similar API methods / properties to Planck. A list of these properties / methods can be viewed below.

Important: When using native Planck methods (on sprite.body), you must pass metric values. Sprite values are converted automatically from metric to screen coordinates within their preUpdate method. We include some convenience methods (listed below) that accept screen coordinates, which are then converted to metric. These methods can be used directly on the sprite class.


Sprite methods

.setPosition (x, y)

Updates the position of the sprite

.getPosition ()

Returns the position (in screen coordinates) of the sprite

.setRotation (radians)

Updates the rotation of the sprite (accepts radians)

.getRotation ()

Returns the rotation (in radians) of the sprite

.setStatic ()

Sets the current sprite body to static (will not be affected by gravity). Static bodies can still be transformed

.setDynamic ()

Sets the current sprite body to dynamic (will be affected by gravity). Bodies are dynamic by default.

.setSensor ()

Sets the current sprite body behavior to 'sensor'. Sensors will not collide with other bodies, but will still fire collision events

.isSensor ()

Returns true if the current body is a sensor


Status

Bodies

Type Status
Box ✔️
Circle ✔️
Edge ✔️
Polygon ✔️

Joints

Type Status
Distance ✔️
Friction
Gear
Motor
Mouse
Prismatic
Pulley
Revolute ✔️
Rope
Weld
Wheel

Other

Type Status
Sensors ✔️
Conveyers ✔️
One-way Platforms

Contributing

Created by notchris & KingCosmic Please feel free to post a PR / issue, we are looking for contributors to help with this effort. Thanks!

You are welcome to contact me on:

  • Discord: notchris#4207
  • IRC (Freenode): notchris
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].