projects
/
tabakrolletjie.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add total power and damage.
[tabakrolletjie.git]
/
tabakrolletjie
/
lights.py
diff --git
a/tabakrolletjie/lights.py
b/tabakrolletjie/lights.py
index 03adf387cb2fb299ac57bc2942d7870532c31719..8b688f71907588608f698084615eb8f4b6c37e8f 100644
(file)
--- a/
tabakrolletjie/lights.py
+++ b/
tabakrolletjie/lights.py
@@
-1,6
+1,8
@@
""" May it be a light for you in dark places, when all other lights go out.
"""
""" May it be a light for you in dark places, when all other lights go out.
"""
+import math
+
import pymunk
import pymunk.pygame_util
import pygame.display
import pymunk
import pymunk.pygame_util
import pygame.display
@@
-83,6
+85,9
@@
class LightManager(object):
if light.on and light.ray_manager.reaches(shape.body.position)
]
if light.on and light.ray_manager.reaches(shape.body.position)
]
+ def total_power_usage(self):
+ return sum(light.power_usage() for light in self._lights)
+
def render_light(self, surface):
for light in self._lights:
light.render_light(surface)
def render_light(self, surface):
for light in self._lights:
light.render_light(surface)
@@
-213,6
+218,16
@@
class BaseLight(object):
rx, ry = self.ray_manager.pygame_position(surface)
surface.blit(self.fitting_image(), (rx - 24, ry - 24), None, 0)
rx, ry = self.ray_manager.pygame_position(surface)
surface.blit(self.fitting_image(), (rx - 24, ry - 24), None, 0)
+ def power_usage(self):
+ if not self.on:
+ return 0.0
+ area = math.pi * (self.ray_manager.max_radius ** 2) # radius
+ area = area * (self.ray_manager.spread / (2 * math.pi)) # spread
+ return 5 * area * self.intensity
+
+ def base_damage(self):
+ return 5 * self.intensity
+
def toggle(self):
self.colour_pos += 1
if self.colour_pos >= len(self.colour_cycle):
def toggle(self):
self.colour_pos += 1
if self.colour_pos >= len(self.colour_cycle):