-
Notifications
You must be signed in to change notification settings - Fork 0
/
ParticleSystem.lua
66 lines (51 loc) · 1.8 KB
/
ParticleSystem.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--[[
(C) Copyright 2014 William Dyce
All rights reserved. This program and the accompanying materials
are made available under the terms of the GNU Lesser General Public License
(LGPL) version 2.1 which accompanies this distribution, and is available at
http://www.gnu.org/licenses/lgpl-2.1.html
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
--]]
--[[------------------------------------------------------------
ParticleSystem GAMEOBJECT
--]]------------------------------------------------------------
--[[------------------------------------------------------------
Includes
--]]--
local Class = require("unrequited/Class")
local Vector = require("unrequited/Vector")
local GameObject = require("unrequited/GameObject")
local log = require("unrequited/log")
local scaling = require("unrequited/scaling")
local useful = require("unrequited/useful")
--[[------------------------------------------------------------
Initialisation
--]]--
local ParticleSystem = Class
{
type = GameObject.newType("ParticleSystem"),
init = function(self, x, y, image, max)
self.particles = love.graphics.newParticleSystem(image, max)
self.particles:setSpread(2*math.pi)
GameObject.init(self, x, y)
end,
}
ParticleSystem:include(GameObject)
--[[------------------------------------------------------------
Game loop
--]]--
function ParticleSystem:update(dt)
self.particles:update(dt)
GameObject.update(self, dt)
self.particles:moveTo(self.x, self.y)
end
function ParticleSystem:draw()
love.graphics.draw(self.particles, 0, 0)
end
--[[------------------------------------------------------------
Export
--]]--
return ParticleSystem