feat(world/actor): put more info in the definition
This commit is contained in:
parent
cf9c82814d
commit
e2af541dde
2 changed files with 12 additions and 8 deletions
|
@ -2,6 +2,7 @@
|
||||||
local Player = actor {
|
local Player = actor {
|
||||||
type = "player",
|
type = "player",
|
||||||
dimensions = {w = 16, h = 16},
|
dimensions = {w = 16, h = 16},
|
||||||
|
friction = {x = 480*3, y = 480*3},
|
||||||
isSolid = true,
|
isSolid = true,
|
||||||
visuals = {
|
visuals = {
|
||||||
mode = "box",
|
mode = "box",
|
||||||
|
@ -14,8 +15,6 @@ function Player:onInit()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Player:update(dt)
|
function Player:update(dt)
|
||||||
self.friction.x, self.friction.y = 480*3, 480*3
|
|
||||||
|
|
||||||
if love.keyboard.isDown("up") then
|
if love.keyboard.isDown("up") then
|
||||||
self.speed.y = -120
|
self.speed.y = -120
|
||||||
end
|
end
|
||||||
|
|
|
@ -33,12 +33,12 @@ local physicsUtils = require "framework.scenes.world.actors.physics.utils"
|
||||||
function Physics:initPhysics(position, dimensions, isSolid)
|
function Physics:initPhysics(position, dimensions, isSolid)
|
||||||
self.position = Vector3D(position.x, position.y, position.z or 0)
|
self.position = Vector3D(position.x, position.y, position.z or 0)
|
||||||
self.speed = Vector3D(0, 0, 0)
|
self.speed = Vector3D(0, 0, 0)
|
||||||
self.friction = Vector3D(0, 0, 0)
|
|
||||||
self.gravity = Vector3D(0, 0, 0)
|
|
||||||
self.gravityAxis = ""
|
|
||||||
self.bounceFactor = 0
|
|
||||||
|
|
||||||
self.isSolid = (isSolid == true)
|
self:setGravity(self.def.gravity or {})
|
||||||
|
self:setFriction(self.def.friction or {})
|
||||||
|
self.bounceFactor = self.def.bounceFactor or 0
|
||||||
|
|
||||||
|
self.isSolid = (self.def.isSolid == true)
|
||||||
|
|
||||||
self.haveCollisions = true
|
self.haveCollisions = true
|
||||||
|
|
||||||
|
@ -74,7 +74,8 @@ end
|
||||||
|
|
||||||
-- Setter functions
|
-- Setter functions
|
||||||
|
|
||||||
function Physics:setGravity(axis, value)
|
function Physics:setGravity(gravity)
|
||||||
|
local axis, value = gravity.axis or "", gravity.value or 0
|
||||||
self.gravity = Vector3D(0, 0, 0)
|
self.gravity = Vector3D(0, 0, 0)
|
||||||
self.gravityAxis = axis or ""
|
self.gravityAxis = axis or ""
|
||||||
if (self.gravityAxis == "") then
|
if (self.gravityAxis == "") then
|
||||||
|
@ -91,6 +92,10 @@ function Physics:setGravity(axis, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Physics:setFriction(friction)
|
||||||
|
self.friction = Vector3D(friction.x or 0, friction.y or 0, friction.z or 0)
|
||||||
|
end
|
||||||
|
|
||||||
-- Getter functions
|
-- Getter functions
|
||||||
-- Help to get informations from the physics
|
-- Help to get informations from the physics
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue