Source

Fat x Fast / FatxFast / objects / ghost.py

Full commit

# This file is part of FatxFast.
#
#    FatxFast is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    FatxFast is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with FatxFast.  If not, see <http://www.gnu.org/licenses/>.

# Versioning based on: 
# http://en.wikipedia.org/wiki/Versioning#Designating_development_stage
__author__ = "dryatu (c) 2013"
__version__ = "1.2.5"
#
#try:
#    from pygame.math import Vector2
#except ImportError:
#    from FatxFast.utils.vector2 import Vector2
#from FatxFast.objects.character import Character
#from FatxFast.tilemap.maze import solver
#
#class Ghost(Character):
#    """Ghost will try to solve the tilemap when iniated. each update iteration
#    will move it one step closer to the finish line."""
#    def __init__(self, gamescene, **kwargs):
#        super(Ghost, self).__init__(gamescene, 
#            animeimage="ghost.png", collides=False, **kwargs)
#        self.solver = solver.BacktrackSolver()
#        self.solver.run(gamescene.tilemap)
#        self.solution = self.solver.get_linear_solution()
#        
#    def update(self, dt):
#        if self._pointer is None and len(self.solution):
#            self._pointer = Vector2(
#                self.gamescene.tilemap.get_coord_position(
#                    self.solution.pop()))
#            dx, dy = self.rect.x-self._pointer.x, self.rect.y-self._pointer.y
#            if dx:
#                self._movement_component = 'x'
#            elif dy:
#                self._movement_component = 'y'
#            if (
#                getattr(self.rect, self._movement_component) <
#                    getattr(self._pointer, self._movement_component)):
#                setattr(self.accelvector, self._movement_component, CHAR_ACCEL)
#            else:
#                setattr(self.accelvector, self._movement_component, -CHAR_ACCEL)
#        if (self._pointer and 
#            getattr(self.accelvector, self._movement_component) < 0):
#            if (getattr(self._pointer, self._movement_component) >= \
#                getattr(self.rect, self._movement_component)):
#                self._pointer = None
#        elif (self._pointer and 
#            getattr(self.accelvector, self._movement_component) < 0):
#            if (getattr(self._pointer, self._movement_component) >= \
#                getattr(self.rect, self._movement_component)):
#                self._pointer = None
#        super(Ghost, self).update(dt)