Corrigindo bug de mouse
[Projeto-PCG.git] / weapons.lua
blob8dfdf87b0a44c358cc1c2ad363ac663bbe15f314
1 local cabo = {-15,-15,-15,-15+10}
2 local cabo2 = {-15+1,-15+1,-15+1,-15+10+1}
3 local cano = {-15,-15+10,-45,-15+10}
4 local cano2 = {-15+1,-15+10+1,-45+1,-15+10+1}
6 math.randomseed( os.time() )
8 function randomspread(spread)
9 return math.random()*2*spread-spread
10 end
12 shotgun = Weapon{
13 name = "Shotgun",
14 righthand = {-15,-15},
15 lefthand = {-30,-15+10},
16 tip = {-45,-15+10},
17 firerate = 1000,
18 sprite = {
19 Line(cabo),
20 Line(cabo2),
21 Line(cano),
22 Line(cano2)},
23 whenfire = function (x,y,angle,w)
24 for i = 1,5 do
25 Shot {
26 x = x,
27 y = y,
28 angle = angle+randomspread(0.2),
29 weapon = w,
30 duration = 1000,
31 speed = 4,
32 sprite = {
33 Line{0,0,3,0},
34 Line{3,0,3,3},
35 Line{3,3,0,3},
36 Line{0,3,0,0},
39 end
40 end
43 function addXY(x,y,...)
44 local t = {...}
45 for i = 1, #t do
46 t[i][1] = t[i][1] + x
47 t[i][2] = t[i][2] + y
48 t[i][3] = t[i][3] + x
49 t[i][4] = t[i][4] + y
50 end
51 return unpack(t)
52 end
54 function mulXY(x,y,...)
55 local t = {...}
56 for i = 1, #t do
57 t[i][1] = t[i][1] * x
58 t[i][2] = t[i][2] * y
59 t[i][3] = t[i][3] * x
60 t[i][4] = t[i][4] * y
61 end
62 return unpack(t)
63 end
65 local t = 0
66 flamethrower = Weapon{
67 name = "Flamethrower",
68 righthand = {-20,-13},
69 lefthand = {-25,-10},
70 tip = {-65,-15+10},
71 firerate = 60,
72 sprite = {addXY(-10,0,
73 Line{-20,-15,-20,-15+10},
74 Line{-20,-15,-35,-15},
75 Line{-35,-15,-35,-15+10},
76 Line{-5,-15,-15,-15+10},
77 Line{-5-8,-15+8,-5-8,-15},
78 Line{-15,-15+10,-50,-15+10},
79 Line{-40,-15+10,-50,-15},
80 Line{-50,-15,-65,-15},
81 Line{-65,-15,-65,-10},
82 Line{-60,-15+6,-60,-15+13},
83 Line{-50,-15+6,-60,-15+6},
84 Line{-50,-15+13,-60,-15+13},
85 Line{-50,-15+6,-50,-15+13}
88 whenfire = function (x,y,angle,w)
89 for i = 1,math.random(4) do
90 local flametip = math.random()*4
91 local flamesprite = {mulXY(3,4,
92 Line{flametip,0,0,2},
93 Line{0,2,0,3},
94 Line{0,3,1,4},
95 Line{1,4,3,4},
96 Line{3,4,4,3},
97 Line{4,3,4,2},
98 Line{4,2,flametip,0}
100 t = t + 0.4
101 Shot {
102 x = x,
103 y = y,
104 angle = angle+math.sin(t)*0.6+randomspread(0.4),
105 weapon = w,
106 speed = 3,
107 duration = 500+math.random(500)-250,
108 gravity = -0.04,
109 sprite = flamesprite,