All entities can move, not only players
This commit is contained in:
		@@ -21,18 +21,6 @@ class Player(FightingEntity):
 | 
			
		||||
        self.map.currenty = y
 | 
			
		||||
        self.map.currentx = x
 | 
			
		||||
 | 
			
		||||
    def move_up(self) -> bool:
 | 
			
		||||
        return self.check_move(self.y - 1, self.x, True)
 | 
			
		||||
 | 
			
		||||
    def move_down(self) -> bool:
 | 
			
		||||
        return self.check_move(self.y + 1, self.x, True)
 | 
			
		||||
 | 
			
		||||
    def move_left(self) -> bool:
 | 
			
		||||
        return self.check_move(self.y, self.x - 1, True)
 | 
			
		||||
 | 
			
		||||
    def move_right(self) -> bool:
 | 
			
		||||
        return self.check_move(self.y, self.x + 1, True)
 | 
			
		||||
 | 
			
		||||
    def level_up(self) -> None:
 | 
			
		||||
        while self.current_xp > self.max_xp:
 | 
			
		||||
            self.level += 1
 | 
			
		||||
 
 | 
			
		||||
@@ -135,6 +135,22 @@ class Entity:
 | 
			
		||||
        self.y = y
 | 
			
		||||
        self.x = x
 | 
			
		||||
 | 
			
		||||
    def move_up(self, force: bool = False) -> bool:
 | 
			
		||||
        return self.move(self.y - 1, self.x) if force else \
 | 
			
		||||
            self.check_move(self.y - 1, self.x, True)
 | 
			
		||||
 | 
			
		||||
    def move_down(self, force: bool = False) -> bool:
 | 
			
		||||
        return self.move(self.y + 1, self.x) if force else \
 | 
			
		||||
            self.check_move(self.y + 1, self.x, True)
 | 
			
		||||
 | 
			
		||||
    def move_left(self, force: bool = False) -> bool:
 | 
			
		||||
        return self.move(self.y, self.x - 1) if force else \
 | 
			
		||||
            self.check_move(self.y, self.x - 1, True)
 | 
			
		||||
 | 
			
		||||
    def move_right(self, force: bool = False) -> bool:
 | 
			
		||||
        return self.move(self.y, self.x + 1) if force else \
 | 
			
		||||
            self.check_move(self.y, self.x + 1, True)
 | 
			
		||||
 | 
			
		||||
    def act(self, m: Map) -> None:
 | 
			
		||||
        """
 | 
			
		||||
        Define the action of the entity that is ran each tick.
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user