Now only updates alpha when it has to. Much faster.
This commit is contained in:
parent
6c90ec0f6b
commit
3d76f7fdbd
|
@ -34,12 +34,17 @@ class Block(worldobject.WorldObject):
|
||||||
worldobject.WorldObject.__init__(self, level, x, y, movable=movable)
|
worldobject.WorldObject.__init__(self, level, x, y, movable=movable)
|
||||||
|
|
||||||
self.orig_alpha = pygame.surfarray.array_alpha(self.img)
|
self.orig_alpha = pygame.surfarray.array_alpha(self.img)
|
||||||
|
self.is_currently_opaque = True
|
||||||
|
|
||||||
def update_alpha(self):
|
def update_alpha(self):
|
||||||
if (self.y + self.z >= self.level.player.y + self.level.player.z):
|
be_opaque = not (self.y + self.z >= self.level.player.y
|
||||||
self.set_alpha(0.5)
|
+ self.level.player.z)
|
||||||
else:
|
if be_opaque and not self.is_currently_opaque:
|
||||||
|
self.is_currently_opaque = True
|
||||||
self.set_alpha(1)
|
self.set_alpha(1)
|
||||||
|
elif not be_opaque and self.is_currently_opaque:
|
||||||
|
self.is_currently_opaque = False
|
||||||
|
self.set_alpha(0.5)
|
||||||
|
|
||||||
def use(self, obj):
|
def use(self, obj):
|
||||||
if self.movable:
|
if self.movable:
|
||||||
|
@ -60,6 +65,7 @@ class ArrowBlock(Block):
|
||||||
self.__dict__.update(locals())
|
self.__dict__.update(locals())
|
||||||
worldobject.WorldObject.__init__(self, level, x, y,
|
worldobject.WorldObject.__init__(self, level, x, y,
|
||||||
direction=direction, movable=movable)
|
direction=direction, movable=movable)
|
||||||
|
self.is_currently_opaque = True
|
||||||
|
|
||||||
self.frame = 0
|
self.frame = 0
|
||||||
self.anim_speed = 15
|
self.anim_speed = 15
|
||||||
|
@ -109,7 +115,8 @@ class RisingBlock(Block):
|
||||||
def __init__(self, level, x, y, movable=False, is_up=True):
|
def __init__(self, level, x, y, movable=False, is_up=True):
|
||||||
self.__dict__.update(locals())
|
self.__dict__.update(locals())
|
||||||
worldobject.WorldObject.__init__(self, level, x, y, movable=movable)
|
worldobject.WorldObject.__init__(self, level, x, y, movable=movable)
|
||||||
|
self.is_currently_opaque = True
|
||||||
|
|
||||||
self.frame = 0
|
self.frame = 0
|
||||||
self.anim_speed = 15
|
self.anim_speed = 15
|
||||||
self.setting = [0, 0]
|
self.setting = [0, 0]
|
||||||
|
|
|
@ -136,9 +136,3 @@ class Level3(level.Level):
|
||||||
def restart(self):
|
def restart(self):
|
||||||
for obj in self.objects:
|
for obj in self.objects:
|
||||||
obj.reset_pos()
|
obj.reset_pos()
|
||||||
|
|
||||||
def infrange():
|
|
||||||
n = 0
|
|
||||||
while True:
|
|
||||||
yield n
|
|
||||||
n += 1
|
|
||||||
|
|
Loading…
Reference in New Issue