mirror of
https://github.com/tanema/light_world.lua.git
synced 2024-12-24 20:24:19 +00:00
minimized methods again
This commit is contained in:
parent
5add341a14
commit
302bd42d5f
@ -195,11 +195,11 @@ function love.update(dt)
|
|||||||
if phyLight[i]:getType() == "polygon" then
|
if phyLight[i]:getType() == "polygon" then
|
||||||
phyLight[i]:setPoints(phyBody[i]:getWorldPoints(phyShape[i]:getPoints()))
|
phyLight[i]:setPoints(phyBody[i]:getWorldPoints(phyShape[i]:getPoints()))
|
||||||
elseif phyLight[i]:getType() == "circle" then
|
elseif phyLight[i]:getType() == "circle" then
|
||||||
phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY())
|
phyLight[i]:setPosition(phyBody[i]:getPosition())
|
||||||
elseif phyLight[i]:getType() == "image" then
|
elseif phyLight[i]:getType() == "image" then
|
||||||
phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY())
|
phyLight[i]:setPosition(phyBody[i]:getPosition())
|
||||||
elseif phyLight[i]:getType() == "refraction" then
|
elseif phyLight[i]:getType() == "refraction" then
|
||||||
--phyLight[i]:setPosition(phyBody[i]:getX(), phyBody[i]:getY())
|
--phyLight[i]:setPosition(phyBody[i]:getPosition())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if phyLight[i]:getType() == "refraction" then
|
if phyLight[i]:getType() == "refraction" then
|
||||||
@ -367,7 +367,8 @@ function drawForground(l,t,w,h)
|
|||||||
elseif phyLight[i]:getType() == "circle" then
|
elseif phyLight[i]:getType() == "circle" then
|
||||||
math.randomseed(i)
|
math.randomseed(i)
|
||||||
love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255))
|
love.graphics.setColor(math.random(0, 255), math.random(0, 255), math.random(0, 255))
|
||||||
love.graphics.circle("fill", phyLight[i]:getX(), phyLight[i]:getY(), phyLight[i]:getRadius())
|
local cx, cy = phyLight[i]:getPosition()
|
||||||
|
love.graphics.circle("fill", cx, cy, phyLight[i]:getRadius())
|
||||||
elseif phyLight[i]:getType() == "image" then
|
elseif phyLight[i]:getType() == "image" then
|
||||||
if normalOn and phyLight[i].normal then
|
if normalOn and phyLight[i].normal then
|
||||||
love.graphics.setColor(255, 255, 255)
|
love.graphics.setColor(255, 255, 255)
|
||||||
|
@ -134,7 +134,8 @@ end
|
|||||||
|
|
||||||
function drawForground(l,t,w,h)
|
function drawForground(l,t,w,h)
|
||||||
love.graphics.setColor(63, 255, 127)
|
love.graphics.setColor(63, 255, 127)
|
||||||
love.graphics.circle("fill", circleTest:getX(), circleTest:getY(), circleTest:getRadius())
|
local cx, cy = circleTest:getPosition()
|
||||||
|
love.graphics.circle("fill", cx, cy, circleTest:getRadius())
|
||||||
love.graphics.polygon("fill", rectangleTest:getPoints())
|
love.graphics.polygon("fill", rectangleTest:getPoints())
|
||||||
love.graphics.setColor(255, 255, 255)
|
love.graphics.setColor(255, 255, 255)
|
||||||
love.graphics.draw(image, 64 - image:getWidth() * 0.5, 64 - image:getHeight() * 0.5)
|
love.graphics.draw(image, 64 - image:getWidth() * 0.5, 64 - image:getHeight() * 0.5)
|
||||||
|
25
lib/body.lua
25
lib/body.lua
@ -109,30 +109,9 @@ function body:setPosition(x, y)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- set x position
|
|
||||||
function body:setX(x)
|
|
||||||
if x ~= self.x then
|
|
||||||
self.x = x
|
|
||||||
self:refresh()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- set y position
|
|
||||||
function body:setY(y)
|
|
||||||
if y ~= self.y then
|
|
||||||
self.y = y
|
|
||||||
self:refresh()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- get x position
|
-- get x position
|
||||||
function body:getX()
|
function body:getPosition()
|
||||||
return self.x
|
return self.x, self.y
|
||||||
end
|
|
||||||
|
|
||||||
-- get y position
|
|
||||||
function body:getY(y)
|
|
||||||
return self.y
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get width
|
-- get width
|
||||||
|
Loading…
Reference in New Issue
Block a user