Debian Codegraph @

scripts/factory_damage.lua

raw symbols SCIP
1 local gl = require 'gl'
2
3 local time = 0
4
5 function update()
6 time = time + 1
7 end
8
9 function draw()
10 -- ugh. . . sprite needs to be more flexible
11 gl.glPushMatrix()
12 gl.glTranslated(self.transform.pos.x, self.transform.pos.y, 0)
13 local f = self.transform.facing
14 gl.glRotated(180/math.pi * math.atan2(f.y, f.x), 0, 0, 1)
15
16 local opacity = (self.sprite.color[4] or 1) * math.random()
17 gl.glColor4d(1, 1, 1, opacity)
18 local health = self.ship.health_percentage()
19 if health < game.constants.low_health_threshold then
20 game.resources.factory_heavy_damage_sprites[math.floor(time/4)%3+1]:draw()
21 elseif health < game.constants.high_health_threshold then
22 game.resources.factory_light_damage_sprites[math.floor(time/4)%3+1]:draw()
23 end
24 gl.glColor3d(1, 1, 1)
25
26 gl.glPopMatrix()
27 end