diff skaapsteker/sprites/player.py @ 632:0675f390653c

Initial port to Python 3 and Pygame 2.
author Simon Cross <hodgestar@gmail.com>
date Fri, 20 Jan 2023 20:01:06 +0100
parents 1fdfc7f03d98
children
line wrap: on
line diff
--- a/skaapsteker/sprites/player.py	Tue Mar 17 22:40:45 2020 +0200
+++ b/skaapsteker/sprites/player.py	Fri Jan 20 20:01:06 2023 +0100
@@ -183,13 +183,13 @@
                 self._last_time = time.time()
         else:
             old_frame = self._animation_frame
-            self._animation_frame += abs(v_x) / 300
+            self._animation_frame += abs(v_x) // 300
             time_diff = time.time() - self._last_time
             if int(self._animation_frame) - int(old_frame) > 0:
                 # Check time diff
                 if time_diff < 0.10:
                     # Delay animation frame jump
-                    self._animation_frame -= abs(v_x) / 300
+                    self._animation_frame -= abs(v_x) // 300
                 else:
                     self._last_time = time.time()
             elif time_diff > 0.20:
@@ -235,8 +235,8 @@
                     continue
                 clip = obj.collide_rect.clip(self.collide_rect)
                 clip_area += clip.width * clip.height
-                if clip.width > TILE_SIZE[0] / 2 and \
-                        self.collide_rect.bottom < obj.collide_rect.top + TILE_SIZE[1] / 3:
+                if clip.width > TILE_SIZE[0] // 2 and \
+                        self.collide_rect.bottom < obj.collide_rect.top + TILE_SIZE[1] // 3:
                    delta = self.rect.bottom - self.collide_rect.bottom
                    self.collide_rect.bottom = obj.collide_rect.top - 1
                    self.rect.bottom = self.collide_rect.bottom + delta
@@ -294,7 +294,7 @@
 
     def steal_life(self, damage_done):
         if 'steal' in self._me.tails:
-            self._me.cur_health += damage_done * len(self._me.tails) / 32
+            self._me.cur_health += damage_done * len(self._me.tails) // 32
             self._me.cur_health = min(self._me.cur_health, self._me.max_health)
 
     def restore(self):
@@ -547,10 +547,10 @@
         image = sprite.image
         if image.get_width() > image.get_height():
             new_width = FoxHud.INVENTORY_SIZE
-            new_height = int(image.get_height() * (float(FoxHud.INVENTORY_SIZE) / image.get_width()))
+            new_height = int(image.get_height() * (float(FoxHud.INVENTORY_SIZE) // image.get_width()))
         else:
             new_height = FoxHud.INVENTORY_SIZE
-            new_width = int(image.get_width() * (float(FoxHud.INVENTORY_SIZE) / image.get_height()))
+            new_width = int(image.get_width() * (float(FoxHud.INVENTORY_SIZE) // image.get_height()))
         if image.get_width() <= FoxHud.INVENTORY_SIZE and image.get_height() <= FoxHud.INVENTORY_SIZE:
             self.inventory_image = image
         else:
@@ -590,4 +590,3 @@
         self.shape = 'human_with_fan'
         self._me.shape = self.shape
         self.set_image()
-