kittykatattack / bump Goto Github PK
View Code? Open in Web Editor NEWA set of 2D collision utilities for games.
License: MIT License
A set of 2D collision utilities for games.
License: MIT License
Hi, I'd like to know what kind of license this library has. I'd like to incorporate it into a project but am unsure if it is open source. Thanks.
I have a platfomer with a constant acceleration built in to simulate gravity:
let playerGravity = 0.2;
playerSprite.vy += playerGravity;
collision detection for playerSprite and array of sprites that are allowed to collide with the playerSprite:
if( b.hitTestRectangle(playerSprite, collSprites[i])){
b.rectangleCollision(playerSprite, collSprites[i], false);
where:
b = new Bump(PIXI);
on "impact" where playerSprite lands on top of a tile with which it can collide first aligns the playerSprite to the tile, then after ~1 second @ 60fps, the playerSprite disappears. Movement is also hindered after collision to whole tiles before playerSprite disappears.
It would be nice if there was a package.json.
In scripts perhaps a npm run build
script that would build the source.
Then I (And anyone else) would know how to commit the built source!
And you can also publish to NPM..if you are interested.
Best,
anySprite.circular = true;
will make the sprite be interpreted as circular. In fact it doesn't work. I notice there's a block in the source code:if (aIsASprite && bIsASprite) {
//Yes, but what kind of sprites?
if (a.diameter && b.diameter) {
//They're circles
return circleVsCircle(a, b);
} else if (a.diameter && !b.diameter) {
//The first one is a circle and the second is a rectangle
return circleVsRectangle(a, b);
} else {
//They're rectangles
return rectangleVsRectangle(a, b);
}
}
It seems that the function hit
uses diameter
as the flag of circle rather than circular
. After my testing ,anySprite.diameter= true;
works well.
movingCircleCollision
works well----I mean both the circles move when they hit each other. But rectangleCollision
and circleRectangleCollision
won't move the second sprite passed into function. Is that a bug?b.hit(circle, rect, true, true);
AddCollisionProperties doesn't seem to work for polygons. Properties needed for collisions are not valid
i need to setting up start time in bezier curve between pointA to pointB。
how to do it,please
I'm trying to use the contain
function to keep a ball (sprite) inside a playing field (container). Struggling to get this done I went into the code to see if I was using it correctly.
Maybe i'm just wrongly interpreting this so correct me if I'm wrong.
Normally x and y are used as anchor positions of the object, let's say for simplicity sake that they indicate the top left corner in this example. The width and height are then used for... width and height. So if you want to know what the x-coordinate is of the right side you do x + width
.
In the contain
function left
and top
collision are calculated as if the sprite and the container are on the same level (as if they have the same parent). Because both x's are compared. If the sprite would be in the container then you should just compare sprite.x < 0
(leaving out gravities to make it simpler).
right
and bottom
are calculated as if they are nested aka as if the sprite is in the container.
Example how it should be for right if they are not nested like in the left and top function: you take the right most pixel sprite.x + sprite.width
and you compare it to the right most part of the container container.x + container.width
. But in the code it is just compared to the width as if the sprite is inside the container hereby conflicting with the left and top usage.
I'm willing to look into this and fix this if I'm correct.
I am not sure if this is a bug with bump.js or Sprite.hitArea.
According to doc at: http://pixijs.download/release/docs/PIXI.Sprite.html#hitArea if a Sprite has been assigned a hitArea, Bound checking will check the hitArea instead of Bounds. After assigning a hitArea to a sprite, bump.js reacts to the Bounds, and not hitArea.
Would nice to see support for rotated objects (using SAT, swept OOB...) for collision tests, and the colliding angle in collision response.
Hi everyone,
I think i have found a problem in findCollisionType function.
In findCollisionType to determine if an object is a circle, the existence of diameter member is tested :
[...]
if (a.diameter && b.diameter) {
//They're circles
return circleVsCircle(a, b);
} else if (a.diameter && !b.diameter) {
//The first one is a circle and the second is a rectangle
return circleVsRectangle(a, b);
[...]
But diameter is never added in addCollisionProperties, while the radius is it, so I suggest to use radius instead of diameter, and the code of findCollisionType become :
[...]
if (a.radius && b.radius) {
//They're circles
return circleVsCircle(a, b);
} else if (a.radius && !b.radius) {
//The first one is a circle and the second is a rectangle
return circleVsRectangle(a, b);
[...]
It can have the value "topLeft", "topMiddle", "topRight", "leftMiddle", "rightMiddle", "bottomLeft", "bottomMiddle", or "bottomRight". If there’s no collision it will be undefined.
Yet half of my collisions are turning up as false. I truly don't have a clue as to why this would be. If there's no collision it should be returning up as "undefined". Either way hit() detects a collision, but when the hitTestCircleRectangle() is run, sometimes I get false.
Any ideas, Maybe this is a bug?
Hi, sorry for my Eng.
When i try use bump.js via CDN like https://cdn.rawgit.com/kittykatattack/bump/2fe38b76/bin/bump.js
all working correct.
But when i try use webpack or another build system from npm_modules i get error: Bump is undefined...
Builded code don't have 'var Bump ='.
This don't work for me:
let bump = new Bump(PIXI);
app.js:2 Uncaught ReferenceError: Bump is not defined
yarn info bump.js
yarn info v1.5.1
warning package.json: No license field
{ name: 'bump.js',
description: 'A 2D Collision library for Pixi',
'dist-tags':
{ latest: '1.0.3' },
versions:
[ '1.0.0',
'1.0.1',
'1.0.2',
'1.0.3' ],
maintainers:
[ { name: 'happierall',
email: '[email protected]' } ],
time:
{ modified: '2016-10-09T12:35:04.165Z',
created: '2016-10-09T12:12:07.356Z',
'1.0.0': '2016-10-09T12:12:07.356Z',
'1.0.1': '2016-10-09T12:16:08.974Z',
'1.0.2': '2016-10-09T12:23:39.232Z',
'1.0.3': '2016-10-09T12:35:04.165Z' },
homepage: 'https://github.com/kittykatattack/bump#readme',
keywords:
[ 'collision',
'2d',
'pixi' ],
repository:
{ type: 'git',
url: 'git+https://github.com/kittykatattack/bump.git' },
author:
{ name: 'kittykatattack' },
bugs:
{ url: 'https://github.com/kittykatattack/bump/issues' },
license: 'MIT',
readmeFilename: 'README.md',
version: '1.0.3',
main: 'bin/bump.js',
scripts: {},
dist:
{ shasum: 'e0bd953d1ac46d60ab24610d7c632f92295cf8d4',
tarball: 'https://registry.npmjs.org/bump.js/-/bump.js-1.0.3.tgz' },
directories: {} }
PIXI.js v4
You mention a new version, when PIXI 4 comes out... which has. Are you still maintaining the lib? Or has Bump2 (https://github.com/LCluber/Bump.js) become the follower?
Would be great if you could mention something in the ReadMe! Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.