Tinha mexido no lanca chamas, corrigindo
[Projeto-PCG.git] / weapons.lua
blob583addb28354fc21a5b2549b64782d8fd9d4ffe5
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 = {-30,-15+10},
15 lefthand = {-15,-15},
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
66 local rainbowcolors = {{221,0,0},
67 {254,98,48},
68 {254,246,0},
69 {0,188,0},
70 {0,155,254},
71 {0,0,131},
72 {48,0,155}}
73 for i = 1,7 do
74 rainbowcolors[i][1] = rainbowcolors[i][1]/255
75 rainbowcolors[i][2] = rainbowcolors[i][2]/255
76 rainbowcolors[i][3] = rainbowcolors[i][3]/255
77 end
79 local rainbowsprite = {}
80 local rainbowsegments = 40
81 local rainbowsize = 400
82 local rainbowheight = 30
83 for i = 1, rainbowsegments do
84 for j = 1,7 do
85 rainbowsprite[#rainbowsprite+1] = Line{
86 (i/rainbowsegments)*rainbowsize,
87 math.sin((i/rainbowsegments)*math.pi)*-rainbowheight+j,
88 ((i+1)/rainbowsegments)*rainbowsize,
89 math.sin(((i+1)/rainbowsegments)*math.pi)*-rainbowheight+j,
90 color = rainbowcolors[j],
92 end
93 end
96 rainbow = Weapon{
97 name = "CareBear",
98 righthand = {10,-30},
99 lefthand = {30,-10},
100 tip = {-10,15},
101 firerate = 1000,
102 sprite = {},
103 whenfire = function (x,y,angle,w)
104 local peitox = math.cos(angle)*x-math.sin(angle)*y --desfaz todo o calculo que eh feito pra ajuste de tip... mas vale apena :D
105 local peitoy = math.sin(angle)*x+math.cos(angle)*y
106 local s = {}
107 local dir = 1
108 local add = 0
109 if math.abs(angle) < math.pi/2 then
110 dir = -1
111 add = 17
113 for i = 1, #rainbowsprite do
114 s[i] = Line {
115 rainbowsprite[i][1]*dir+add,
116 rainbowsprite[i][2],
117 rainbowsprite[i][3]*dir+add,
118 rainbowsprite[i][4],
119 color = rainbowsprite[i].color
122 Shot {
123 x = peitox,
124 y = peitoy,
125 angle = 0,
126 weapon = w,
127 speed = 0,
128 duration = 600,
129 sprite = s,
134 local t = 0
135 flamethrower = Weapon{
136 name = "Flamethrower",
137 righthand = {-20,-13},
138 lefthand = {-25,-10},
139 tip = {-65,-15+10},
140 firerate = 60,
141 sprite = {addXY(-10,0,
142 Line{-20,-15,-20,-15+10},
143 Line{-20,-15,-35,-15},
144 Line{-35,-15,-35,-15+10},
145 Line{-5,-15,-15,-15+10},
146 Line{-5-8,-15+8,-5-8,-15},
147 Line{-15,-15+10,-50,-15+10},
148 Line{-40,-15+10,-50,-15},
149 Line{-50,-15,-65,-15},
150 Line{-65,-15,-65,-10},
151 Line{-60,-15+6,-60,-15+13},
152 Line{-50,-15+6,-60,-15+6},
153 Line{-50,-15+13,-60,-15+13},
154 Line{-50,-15+6,-50,-15+13}
157 whenfire = function (x,y,angle,w)
158 red = {math.random()/4+0.75,math.random()/3,0}
159 for i = 1,math.random(4) do
160 local flametip = math.random()*4
161 local flamesprite = {mulXY(3,4,
162 Line{flametip,0,0,2,color = red},
163 Line{0,2,0,3,color = red},
164 Line{0,3,1,4,color = red},
165 Line{1,4,3,4,color = red},
166 Line{3,4,4,3,color = red},
167 Line{4,3,4,2,color = red},
168 Line{4,2,flametip,0,color = red}
170 t = t + 0.4
171 Shot {
172 x = x,
173 y = y,
174 angle = angle+math.sin(t)*0.6+randomspread(0.4),
175 weapon = w,
176 speed = 3,
177 duration = 500+math.random(500)-250,
178 sprite = flamesprite,