Ajuste leve na velocidade permitindo movimentos mais sutis
[Projeto-PCG.git] / weaponmanager.lua
blob38a4aec402d7044d7904a082cb7b3b1d7b6ef908
1 function Weapon(t)
2 local w = regweapon(t.righthand[1],t.righthand[2],
3 t.lefthand[1],t.lefthand[2],
4 t.name,t.firerate,
5 t.tip[1],t.tip[2])
6 regfirefunction(w,t.whenfire)
7 for i = 1, #t.sprite do
8 regspriteline(w,t.sprite[i][1],t.sprite[i][2],t.sprite[i][3],t.sprite[i][4],
9 t.sprite[i].color[1],t.sprite[i].color[2],t.sprite[i].color[3])
10 end
11 local minX, minY, maxX, maxY = math.huge, math.huge, -math.huge, -math.huge
12 for i = 1, #t.sprite do
13 minX = math.min(minX, t.sprite[i][1], t.sprite[i][3])
14 minY = math.min(minY, t.sprite[i][2], t.sprite[i][4])
15 maxX = math.max(maxX, t.sprite[i][1], t.sprite[i][3])
16 maxY = math.max(maxY, t.sprite[i][2], t.sprite[i][4])
17 end
18 regcollision(t.name, minX, minY, minX, maxY)
19 regcollision(t.name, minX, minY, maxX, minY)
20 regcollision(t.name, maxX, maxY, minX, maxY)
21 regcollision(t.name, maxX, maxY, maxX, minY)
22 return t
23 end
25 function Line(t)
26 if t.color == nil then
27 t.color = {0,0,0}
28 end
29 return t
30 end
32 function default(t,k,v)
33 if t[k] == nil then
34 t[k] = v
35 end
36 end
38 function Shot(t)
39 default(t,"gravity",0)
40 default(t,"duration",3000)
41 default(t,"speed",10)
42 local s = createshot(t.x,t.y,t.angle,t.duration,t.weapon,t.gravity,t.speed,t.damage)
43 for i = 1, #t.sprite do
44 regspritelineshot(s,t.sprite[i][1],t.sprite[i][2],t.sprite[i][3],t.sprite[i][4],
45 t.sprite[i].color[1],t.sprite[i].color[2],t.sprite[i].color[3])
46 end
47 end