Ajuste leve na velocidade permitindo movimentos mais sutis
[Projeto-PCG.git] / weapons.lua
blob6e9613bb20bde3b875943785ac89d4055386eef7
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 damage = 5,
33 sprite = {
34 Line{0,0,3,0},
35 Line{3,0,3,3},
36 Line{3,3,0,3},
37 Line{0,3,0,0},
40 end
41 end
44 function addXY(x,y,...)
45 local t = {...}
46 for i = 1, #t do
47 t[i][1] = t[i][1] + x
48 t[i][2] = t[i][2] + y
49 t[i][3] = t[i][3] + x
50 t[i][4] = t[i][4] + y
51 end
52 return unpack(t)
53 end
55 function mulXY(x,y,...)
56 local t = {...}
57 for i = 1, #t do
58 t[i][1] = t[i][1] * x
59 t[i][2] = t[i][2] * y
60 t[i][3] = t[i][3] * x
61 t[i][4] = t[i][4] * y
62 end
63 return unpack(t)
64 end
67 local rainbowcolors = {{221,0,0},
68 {254,98,48},
69 {254,246,0},
70 {0,188,0},
71 {0,155,254},
72 {0,0,131},
73 {48,0,155}}
74 for i = 1,7 do
75 rainbowcolors[i][1] = rainbowcolors[i][1]/255
76 rainbowcolors[i][2] = rainbowcolors[i][2]/255
77 rainbowcolors[i][3] = rainbowcolors[i][3]/255
78 end
80 local rainbowsprite = {}
81 local rainbowsegments = 40
82 local rainbowsize = 400
83 local rainbowheight = 30
84 for i = 1, rainbowsegments do
85 for j = 1,7 do
86 rainbowsprite[#rainbowsprite+1] = Line{
87 (i/rainbowsegments)*rainbowsize,
88 math.sin((i/rainbowsegments)*math.pi)*-rainbowheight+j,
89 ((i+1)/rainbowsegments)*rainbowsize,
90 math.sin(((i+1)/rainbowsegments)*math.pi)*-rainbowheight+j,
91 color = rainbowcolors[j],
93 end
94 end
97 rainbow = Weapon{
98 name = "CareBear",
99 righthand = {10,-30},
100 lefthand = {30,-10},
101 tip = {-10,15},
102 firerate = 1000,
103 sprite = {},
104 whenfire = function (x,y,angle,w)
105 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
106 local peitoy = math.sin(angle)*x+math.cos(angle)*y
107 local s = {}
108 local dir = 1
109 local add = 0
110 if math.abs(angle) < math.pi/2 then
111 dir = -1
112 add = 17
114 for i = 1, #rainbowsprite do
115 s[i] = Line {
116 rainbowsprite[i][1]*dir+add,
117 rainbowsprite[i][2],
118 rainbowsprite[i][3]*dir+add,
119 rainbowsprite[i][4],
120 color = rainbowsprite[i].color
123 Shot {
124 x = peitox,
125 y = peitoy,
126 angle = 0,
127 weapon = w,
128 speed = 0,
129 duration = 600,
130 sprite = s,
131 damage = 70,
136 local t = 0
137 flamethrower = Weapon{
138 name = "Flamethrower",
139 righthand = {-20,-13},
140 lefthand = {-25,-10},
141 tip = {-65,-15+10},
142 firerate = 60,
143 sprite = {addXY(-10,0,
144 Line{-20,-15,-20,-15+10},
145 Line{-20,-15,-35,-15},
146 Line{-35,-15,-35,-15+10},
147 Line{-5,-15,-15,-15+10},
148 Line{-5-8,-15+8,-5-8,-15},
149 Line{-15,-15+10,-50,-15+10},
150 Line{-40,-15+10,-50,-15},
151 Line{-50,-15,-65,-15},
152 Line{-65,-15,-65,-10},
153 Line{-60,-15+6,-60,-15+13},
154 Line{-50,-15+6,-60,-15+6},
155 Line{-50,-15+13,-60,-15+13},
156 Line{-50,-15+6,-50,-15+13}
159 whenfire = function (x,y,angle,w)
160 red = {math.random()/4+0.75,math.random()/3,0}
161 for i = 1,math.random(4) do
162 local flametip = math.random()*4
163 local flamesprite = {mulXY(3,4,
164 Line{flametip,0,0,2,color = red},
165 Line{0,2,0,3,color = red},
166 Line{0,3,1,4,color = red},
167 Line{1,4,3,4,color = red},
168 Line{3,4,4,3,color = red},
169 Line{4,3,4,2,color = red},
170 Line{4,2,flametip,0,color = red}
172 t = t + 0.4
173 Shot {
174 x = x,
175 y = y,
176 angle = angle+math.sin(t)*0.6+randomspread(0.4),
177 weapon = w,
178 speed = 3,
179 duration = 500+math.random(500)-250,
180 sprite = flamesprite,
181 damage = 1,