hdictus / breezefield Goto Github PK
View Code? Open in Web Editor NEWa physics library wrapper for love2d
License: MIT License
a physics library wrapper for love2d
License: MIT License
It would be quite useful to be able to specify draw order for objects. At the moment, one must implement draw ordering on his own, which basically restricts you from using world:draw
, and it's quite unfortunate due to how simple it is to use.
At the moment, there isn't much documentation on this library. Although, I'd consider it kind of a thin wrapper for Love's native physics engine, it's still a good idea to improve on documentation. Like, I had to look into the source code in order to find out the callback names for object collisions.
So far I'm really enjoying the library, it really makes it easy to prototype in early stages of development. Thank you for making it!
Currently, it's not quite comfort to install this module on my own love2d project.
Simply git clone and copy do not work, which ends in Error: lib/breezefield/init.lua:13: module 'breezefield/collider' not found:
I have to import collider and world separately if I locate breezefield in a deeper dir.
Hence, I'd be really appreciated if an all-in-one file could be provided.
I
I use classic for classes from rxi
on call functions on collision:
little_ball = {}
little_ball.__index = little_ball
setmetatable(little_ball, bf.Collider) -- this is important
-- otherwise setting the new object's metatable to little_ball overwrites
function spawn_random_ball()
little_ball.new(love.math.random(love.graphics.getWidth()), 0)
end
function little_ball.new(x, y)
local n = bf.Collider.new(world, 'Circle', x, y, 5)
setmetatable(n, little_ball)
return n
end
bf.Collider is deprecated, and world:newCollider complains that it is not being called as a function
the above example doesn't work with classic:
Collider = Object:extend()
Collider.__index = Collider
setmetatable(Collider, bf.Collider)
function Collider:new(position, size, t)
if t then
if t.shape then
local shape = t.shape
else
local shape = 'Rectangle'
end
else
shape = 'Rectangle'
end
local n = world:newCollider(shape, position.x or game.xc, position.y or game.yc, size.x or 36, size.y or 36)
setmetatable(n, Collider)
return n
end
it complains that the extend method of classic is not found, even tho I defined __index to Collider, then I try:
Collider = Object:extend()
function Collider:new(position, size, t)
self.__index = self
setmetatable(self, bf.Collider)
if t then
if t.shape then
self.shape = t.shape
else
self.shape = 'Rectangle'
end
else
self.shape = 'Rectangle'
end
local n = world:newCollider(self.shape, {position.x or game.xc, position.y or game.yc, size.x or 36, size.y or 36})
setmetatable(n, Collider)
return n
end
which seems like a way, but it complains that at line 5, setmetatable(self, bf.Collider)
, it fails to find index collider
, which now seems like a breezefield's flaw.
before this all, I tried making the world:newCollider as self.collider in Collider
. geez, this is getting repetitive. well, turns out I can't access self when handling collisions:
Player = Collider:extend()
function Player:new(t)
self:set_self(t) -- function to set all properties of t to self
Player.super:new(self.position, self.size, self.shape)
-- important notice that I am keeping information in Player, not Player.collider
self.SPEED = 7070
self.dir = 1
self.velocity = vector.new(0, 0)
self.velocity.x = self.SPEED * self.dir
self.collider:setFixedRotation(true)
self.coltest = 0
-- I can't access self, because self.collider is passed as an argument, not self, and I couldn't just use self as that would be the function itself, not Player
-- I have to put the preSolve inside new because self.collider is only defined on Player.new, so it throws an error of collider not existing
function self.collider:preSolve(other, collision)
self.collider.coltest = "a"
if other.groups then
self.collider.coltest = "has group"
if other.isStatic() then
self.coltest = collision:getNormal()
if collision:getNormal() == -1 or collision:getNormal() == 1 then
self.dir = self.dir * -1
end
end
end
end
end
so I ask:
Sorry I am new to game development.I am practicing running game like browser's dinosaur game.So I need a fixed y value for jumping.And also need acceleration value for camera.Kindly suggest me some methods.
Is it possible to load and use tiled custom properties? Like collidable from a tiled map to mark it as collidable?
I tried using bf.Collider.new(world, "Circle", {0, 0, 20})
like in the basic example in README, but it didn't work.
The reason this occurs is because the ...
argument table gets wrapped in another table:
function Collider.new(world, collider_type, ...)
-- deprecated
return world:newCollider(collider_type, {...})
end
Removing the brackets fixes the issue:
function Collider.new(world, collider_type, ...)
-- deprecated
return world:newCollider(collider_type, ...)
end
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.