-
Notifications
You must be signed in to change notification settings - Fork 0
/
animations.lua
78 lines (69 loc) · 2.19 KB
/
animations.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
67
68
69
70
71
72
73
74
75
76
77
78
animations = {}
animations.list = {}
local qFrame=11
local time = 0.9
color = {
red = {255,0,80,255},
green = {0,255,0,255},
blue = {0,0,255,255},
clear = {255,255,255}
}
function animations.load()
animations.image = love.graphics.newImage("/Assets/acidgun_die.png")
local aw = animations.image:getWidth()
local ah = animations.image:getHeight()
local w = aw/5
local h = ah/3
animations.quads = {}
for i=0,qFrame-1 do
table.insert(animations.quads,love.graphics.newQuad((i%5)*w,math.floor(i/5)*h,w,h,aw,ah))
end
animations.width=w
animations.height=h
end
function animations.update(dt)
for i,v in ipairs(animations.list) do
if animComp.update(dt,v.aComp)==-1 then
table.remove(animations.list,i)
end
end
end
function animations.quit()
table.removeAll(animations.list)
end
function animations.createSplash(x,y,col)
local c
if col == nil then c=color.clear else c=col end
table.insert(animations.list,{x=x,y=y,aComp = animComp.newAnim(qFrame,time,false),color=c})
end
function animations.createRandomExplosion(x,y,width,height,col)
animations.createSplash(x+love.math.random()*width,y+love.math.random()*height,col)
end
function animations.draw()
for i,v in ipairs(animations.list) do
love.graphics.setColor(v.color)
love.graphics.draw(animations.image,animations.quads[v.aComp.curr_frame],v.x,v.y,0,1.2,1.2,animations.width/2,animations.height/2)
end
love.graphics.setColor(color.clear)
end
function animations.loadQuads(quant,nCol,each_w,each_h,sprite_width,sprite_height)
local quads={}
for i=0,quant-1 do
table.insert(quads,love.graphics.newQuad(i%nCol*each_w,math.floor(i/nCol)*each_h,each_w,each_h,sprite_width,sprite_height))
end
return quads
end
--[[
player.sprites[run].quads = {
love.graphics.newQuad(0,0,w,h,aw,ah),
love.graphics.newQuad(w,23,w,h-23,aw,ah),
love.graphics.newQuad(2*w,34,w,h-34,aw,ah),
love.graphics.newQuad(3*w,43,w,h-43,aw,ah),
love.graphics.newQuad(4*w,50,w,h-50,aw,ah),
love.graphics.newQuad(0,h,w,h,aw,ah),
love.graphics.newQuad(w,h,w,h,aw,ah),
love.graphics.newQuad(2*w,h,w,h,aw,ah),
love.graphics.newQuad(3*w,h,w,h,aw,ah),
love.graphics.newQuad(4*w,h,w,h,aw,ah)
}
]]