fuzzy
This commit is contained in:
parent
93af99ecf7
commit
8f7be5556b
50
NS.py
50
NS.py
|
@ -25,7 +25,7 @@ from lib.pgfw.pgfw.Sprite import Sprite, RainbowSprite
|
||||||
from lib.pgfw.pgfw.Animation import Animation
|
from lib.pgfw.pgfw.Animation import Animation
|
||||||
from lib.pgfw.pgfw.Audio import SoundEffect
|
from lib.pgfw.pgfw.Audio import SoundEffect
|
||||||
from lib.pgfw.pgfw.extension import (get_step, get_step_relative, get_delta, reflect_angle,
|
from lib.pgfw.pgfw.extension import (get_step, get_step_relative, get_delta, reflect_angle,
|
||||||
render_box)
|
render_box, get_hsla_color)
|
||||||
from lib.pgfw.pgfw.gfx_extension import aa_filled_polygon
|
from lib.pgfw.pgfw.gfx_extension import aa_filled_polygon
|
||||||
|
|
||||||
class NS(Game, Animation):
|
class NS(Game, Animation):
|
||||||
|
@ -987,6 +987,9 @@ class Timer(GameChild):
|
||||||
|
|
||||||
TEXT = u"\u25F7"
|
TEXT = u"\u25F7"
|
||||||
BAR_POSITION = 448, 11
|
BAR_POSITION = 448, 11
|
||||||
|
SIZE = 160
|
||||||
|
TOP = 120
|
||||||
|
RING_OFFSET = 8
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
GameChild.__init__(self, parent)
|
GameChild.__init__(self, parent)
|
||||||
|
@ -1012,40 +1015,29 @@ class Timer(GameChild):
|
||||||
self.time_remaining -= self.get_game().time_filter.get_last_frame_duration()
|
self.time_remaining -= self.get_game().time_filter.get_last_frame_duration()
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
# self.background.update()
|
|
||||||
# self.label.update()
|
|
||||||
if self.time_remaining > 5500:
|
if self.time_remaining > 5500:
|
||||||
color = Color(0, 255, 0)
|
hue = 120
|
||||||
elif self.time_remaining > 3000:
|
elif self.time_remaining > 3000:
|
||||||
color = Color("orange")
|
hue = 30
|
||||||
else:
|
else:
|
||||||
color = Color("red")
|
hue = 0
|
||||||
ds = self.get_display_surface()
|
ds = self.get_display_surface()
|
||||||
max_time = self.get_configuration("time", "timer-max-time")
|
max_time = self.get_configuration("time", "timer-max-time")
|
||||||
size = 160
|
remaining_ratio = float(self.time_remaining) / max_time
|
||||||
top = 120
|
left = ds.get_width() - self.SIZE / 2
|
||||||
image = Image.new("RGBA", (size, size))
|
ds.blit(self.get_ring(get_hsla_color(hue, lightness=20, alpha=67), remaining_ratio),
|
||||||
shadow = Image.new("RGBA", (size, size))
|
(left, self.TOP + self.RING_OFFSET))
|
||||||
|
ds.blit(self.get_ring(get_hsla_color(hue, lightness=80, alpha=67), remaining_ratio),
|
||||||
|
(left, self.TOP - self.RING_OFFSET))
|
||||||
|
ds.blit(self.get_ring(get_hsla_color(hue, alpha=67), remaining_ratio), (left, self.TOP))
|
||||||
|
|
||||||
|
def get_ring(self, color, remaining):
|
||||||
|
image = Image.new("RGBA", (self.SIZE, self.SIZE))
|
||||||
draw = ImageDraw.Draw(image)
|
draw = ImageDraw.Draw(image)
|
||||||
draw_shadow = ImageDraw.Draw(shadow)
|
draw.pieslice((0, 0, self.SIZE - 1, self.SIZE - 1), 90, remaining * 180 + 90,
|
||||||
draw.pieslice((0, 0, size - 1, size - 1), 90, float(self.time_remaining) / max_time * 180 + 90,
|
fill=(color.r, color.g, color.b, color.a))
|
||||||
fill=(color.r, color.g, color.b, 128))
|
draw.ellipse((self.SIZE / 4, self.SIZE / 4, self.SIZE / 4 * 3, self.SIZE / 4 * 3), (0, 0, 0, 0))
|
||||||
draw_shadow.pieslice((0, 0, size - 1, size - 1), 90, float(self.time_remaining) / max_time * 180 + 90,
|
return fromstring(image.tobytes(), image.size, image.mode)
|
||||||
fill=(0, 0, 0, 128))
|
|
||||||
draw.ellipse((40, 40, 120, 120), (0, 0, 0, 0))
|
|
||||||
draw_shadow.ellipse((40, 40, 120, 120), (0, 0, 0, 0))
|
|
||||||
surface = fromstring(image.tobytes(), image.size, image.mode)
|
|
||||||
surface_shadow = fromstring(shadow.tobytes(), shadow.size, shadow.mode)
|
|
||||||
ds.blit(surface_shadow, (ds.get_width() - size / 2, top + 8))
|
|
||||||
ds.blit(surface, (ds.get_width() - size / 2, top))
|
|
||||||
# mask = Surface(self.bar.get_size())
|
|
||||||
# mask.fill((128, 128, 128))
|
|
||||||
# width = min(mask.get_width(), mask.get_width() * float(self.time_remaining) /
|
|
||||||
# self.get_configuration("time", "timer-max-time"))
|
|
||||||
# mask.fill(color, (mask.get_width() - width, 0, width, mask.get_height()))
|
|
||||||
# surface = self.bar.copy()
|
|
||||||
# surface.blit(mask, (0, 0), None, BLEND_RGBA_MIN)
|
|
||||||
# self.get_display_surface().blit(surface, self.BAR_POSITION)
|
|
||||||
|
|
||||||
|
|
||||||
class Life(GameChild):
|
class Life(GameChild):
|
||||||
|
|
|
@ -32,3 +32,4 @@
|
||||||
202333
|
202333
|
||||||
278582
|
278582
|
||||||
286504
|
286504
|
||||||
|
179511
|
||||||
|
|
Loading…
Reference in New Issue