Added some prettier graphics to be used as laser beams.
This commit is contained in:
parent
00bfc53b7b
commit
d37bca5bc2
Binary file not shown.
After Width: | Height: | Size: 210 B |
Binary file not shown.
After Width: | Height: | Size: 203 B |
|
@ -66,18 +66,23 @@ class Laser(worldobject.WorldObject):
|
|||
|
||||
self.start_dark = 0
|
||||
|
||||
self.surf = pygame.Surface(self.level.game.window.get_size(),
|
||||
pygame.SRCALPHA)
|
||||
|
||||
def update(self, e, t, dt):
|
||||
self.start_dark = (t % 200) / 100
|
||||
worldobject.WorldObject.update(self, e, t, dt)
|
||||
|
||||
def draw(self, window):
|
||||
self.surf.fill((0, 0, 0, 0))
|
||||
|
||||
colors = [(155, 0, 0), (255, 0, 0)]
|
||||
c = self.start_dark
|
||||
if self.x0d != self.x1d:
|
||||
length = self.x1d - self.x0d
|
||||
for i in range(0, length, 8):
|
||||
x0d = self.x0d + i
|
||||
pygame.draw.line(window, colors[c],
|
||||
pygame.draw.line(self.surf, colors[c],
|
||||
(x0d - self.level.camera_x,
|
||||
self.y0d - self.level.camera_y),
|
||||
(x0d + min(8, length - i) - self.level.camera_x,
|
||||
|
@ -87,10 +92,11 @@ class Laser(worldobject.WorldObject):
|
|||
length = self.y1d - self.y0d
|
||||
for i in range(0, length, 8):
|
||||
y0d = self.y0d + i
|
||||
pygame.draw.line(window, colors[c],
|
||||
pygame.draw.line(self.surf, colors[c],
|
||||
(self.x0d - self.level.camera_x,
|
||||
y0d - self.level.camera_y),
|
||||
(self.x0d - self.level.camera_x,
|
||||
y0d + min(8, length - i) - self.level.camera_y), 2)
|
||||
c ^= 1
|
||||
|
||||
|
||||
window.blit(self.surf, (0, 0))
|
||||
|
|
Loading…
Reference in New Issue