Colorized planes
This commit is contained in:
parent
3163258761
commit
aebd0ba344
2 changed files with 11 additions and 3 deletions
|
@ -92,9 +92,12 @@ Plane = Class{
|
||||||
|
|
||||||
orientationAngle = 0,
|
orientationAngle = 0,
|
||||||
|
|
||||||
init = function(self, x, y, xDir, yDir, level)
|
init = function(self, x, y, xDir, yDir, r, g, b, level)
|
||||||
local density = 50
|
local density = 50
|
||||||
PhysicsEntity.init(self, x, y, level, "dynamic", 0.2)
|
PhysicsEntity.init(self, x, y, level, "dynamic", 0.2)
|
||||||
|
self.r = r
|
||||||
|
self.g = g
|
||||||
|
self.b = b
|
||||||
self.level = level
|
self.level = level
|
||||||
self.xsize = 4.0 * PIXELS_PER_METER
|
self.xsize = 4.0 * PIXELS_PER_METER
|
||||||
self.ysize = 4.3 * PIXELS_PER_METER
|
self.ysize = 4.3 * PIXELS_PER_METER
|
||||||
|
@ -352,6 +355,7 @@ Plane = Class{
|
||||||
PhysicsEntity.draw(self)
|
PhysicsEntity.draw(self)
|
||||||
love.graphics.push()
|
love.graphics.push()
|
||||||
|
|
||||||
|
love.graphics.setColor(self.r, self.g, self.b);
|
||||||
if self.goingRight then
|
if self.goingRight then
|
||||||
love.graphics.translate(self.body:getX(), self.body:getY())
|
love.graphics.translate(self.body:getX(), self.body:getY())
|
||||||
love.graphics.scale(-1, 1)
|
love.graphics.scale(-1, 1)
|
||||||
|
|
|
@ -25,10 +25,14 @@ Level = Class{
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
|
|
||||||
self.makePlanes = { [1] = function()
|
self.makePlanes = { [1] = function()
|
||||||
return Plane(100, 300, INITIAL_PLANE_SPEED, 0, self)
|
return Plane(100, 300, INITIAL_PLANE_SPEED, 0,
|
||||||
|
255, 0, 0, -- red
|
||||||
|
self)
|
||||||
end,
|
end,
|
||||||
[2] = function()
|
[2] = function()
|
||||||
return Plane(love.window.getWidth() - 100 - 100, 300, -INITIAL_PLANE_SPEED, 0, self)
|
return Plane(love.window.getWidth() - 100 - 100, 300, -INITIAL_PLANE_SPEED, 0,
|
||||||
|
0, 255, 0, -- green
|
||||||
|
self)
|
||||||
end }
|
end }
|
||||||
|
|
||||||
self.planes = { [1] = self.makePlanes[1](),
|
self.planes = { [1] = self.makePlanes[1](),
|
||||||
|
|
Loading…
Reference in a new issue