daily pastebin goal
35%
SHARE
TWEET

Untitled

ilyabelow Mar 15th, 2019 (edited) 54 in 19 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Moving():
  2.  
  3.     def __init__(self, hitbox):
  4.         self.hitbox = hitbox
  5.  
  6.     def update(self):
  7.         pass
  8.  
  9. # ================================================
  10. # так
  11. # ================================================
  12.  
  13. def Player(Moving):
  14.     def __init__(self):
  15.         super(Player, self).__init__((25,25))
  16.         self.controller = Joystick()
  17.  
  18.     def update(self):
  19.         # движение в зависимости от положения левого стика
  20.  
  21. def Enemy(Moving):
  22.     def __init__(self):
  23.         super(Enemy, self).__init__((50,50))
  24.         self.angriness = 5     
  25.  
  26.     def update(self):
  27.         # движение к игроку
  28.  
  29. # ================================================
  30. # или так
  31. # ================================================
  32.  
  33. T_PLAYER = 1
  34. T_ENEMY = 2
  35.  
  36. def construct_moving(type):
  37.     if type = T_PLAYER:
  38.         moving = Moving((25, 25))
  39.         moving.controller = Joystick()
  40.         def update(self):
  41.             # движение в зависимости от положения левого стика
  42.         moving.update = update
  43.         return moving
  44.     if type = T_ENEMY:
  45.         moving = Moving((50, 50))
  46.         moving.angriness = 5       
  47.         def update(self):
  48.             # движение к игроку
  49.         moving.update = update
  50.         return moving
  51.     return None
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top