Added some prettier graphics to be used as laser beams.

This commit is contained in:
Sakse Dalum 2012-08-20 19:51:02 +02:00
parent 00bfc53b7b
commit d37bca5bc2
3 changed files with 9 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

View File

@ -66,18 +66,23 @@ class Laser(worldobject.WorldObject):
self.start_dark = 0 self.start_dark = 0
self.surf = pygame.Surface(self.level.game.window.get_size(),
pygame.SRCALPHA)
def update(self, e, t, dt): def update(self, e, t, dt):
self.start_dark = (t % 200) / 100 self.start_dark = (t % 200) / 100
worldobject.WorldObject.update(self, e, t, dt) worldobject.WorldObject.update(self, e, t, dt)
def draw(self, window): def draw(self, window):
self.surf.fill((0, 0, 0, 0))
colors = [(155, 0, 0), (255, 0, 0)] colors = [(155, 0, 0), (255, 0, 0)]
c = self.start_dark c = self.start_dark
if self.x0d != self.x1d: if self.x0d != self.x1d:
length = self.x1d - self.x0d length = self.x1d - self.x0d
for i in range(0, length, 8): for i in range(0, length, 8):
x0d = self.x0d + i x0d = self.x0d + i
pygame.draw.line(window, colors[c], pygame.draw.line(self.surf, colors[c],
(x0d - self.level.camera_x, (x0d - self.level.camera_x,
self.y0d - self.level.camera_y), self.y0d - self.level.camera_y),
(x0d + min(8, length - i) - self.level.camera_x, (x0d + min(8, length - i) - self.level.camera_x,
@ -87,10 +92,11 @@ class Laser(worldobject.WorldObject):
length = self.y1d - self.y0d length = self.y1d - self.y0d
for i in range(0, length, 8): for i in range(0, length, 8):
y0d = self.y0d + i y0d = self.y0d + i
pygame.draw.line(window, colors[c], pygame.draw.line(self.surf, colors[c],
(self.x0d - self.level.camera_x, (self.x0d - self.level.camera_x,
y0d - self.level.camera_y), y0d - self.level.camera_y),
(self.x0d - self.level.camera_x, (self.x0d - self.level.camera_x,
y0d + min(8, length - i) - self.level.camera_y), 2) y0d + min(8, length - i) - self.level.camera_y), 2)
c ^= 1 c ^= 1
window.blit(self.surf, (0, 0))