import cocos
from cocos.actions import *

class Player:
    
    def __init__(self):
        self.sprite = cocos.sprite.Sprite('img/raoul.png')
        self.pos = 0,0
        self.ammo = 5
        self.range = 6
        self.shooting = False

    def set_pos(self, i, j, force=False):
        self.pos = i,j
        if force:
            self.sprite.position = i*32+16, j*32+16
        else:
            self.sprite.do(MoveTo((i*32+16, j*32+16), duration=0.2))

    def add_to_layer(self, layer):
        layer.add(self.sprite)

    def remove_from_layer(self, layer):
        layer.remove(self.sprite)

    def update_visibility(self, value):
        self.sprite.visible = value