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) | ||||
| 
 | ||||
|         self.orig_alpha = pygame.surfarray.array_alpha(self.img) | ||||
|         self.is_currently_opaque = True | ||||
| 
 | ||||
|     def update_alpha(self): | ||||
|         if (self.y + self.z >= self.level.player.y + self.level.player.z): | ||||
|             self.set_alpha(0.5) | ||||
|         else: | ||||
|         be_opaque = not (self.y + self.z >= self.level.player.y | ||||
|                          + self.level.player.z) | ||||
|         if be_opaque and not self.is_currently_opaque: | ||||
|             self.is_currently_opaque = True | ||||
|             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): | ||||
|         if self.movable: | ||||
| @ -60,6 +65,7 @@ class ArrowBlock(Block): | ||||
|         self.__dict__.update(locals()) | ||||
|         worldobject.WorldObject.__init__(self, level, x, y, | ||||
|                                          direction=direction, movable=movable) | ||||
|         self.is_currently_opaque = True | ||||
| 
 | ||||
|         self.frame = 0 | ||||
|         self.anim_speed = 15 | ||||
| @ -109,7 +115,8 @@ class RisingBlock(Block): | ||||
|     def __init__(self, level, x, y, movable=False, is_up=True): | ||||
|         self.__dict__.update(locals()) | ||||
|         worldobject.WorldObject.__init__(self, level, x, y, movable=movable) | ||||
| 
 | ||||
|         self.is_currently_opaque = True | ||||
|          | ||||
|         self.frame = 0 | ||||
|         self.anim_speed = 15 | ||||
|         self.setting = [0, 0] | ||||
|  | ||||
| @ -136,9 +136,3 @@ class Level3(level.Level): | ||||
|     def restart(self): | ||||
|         for obj in self.objects: | ||||
|             obj.reset_pos() | ||||
| 
 | ||||
| def infrange(): | ||||
|     n = 0 | ||||
|     while True: | ||||
|         yield n | ||||
|         n += 1 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Niels Serup
						Niels Serup