示例#1
0
    def __init__(self, x, y, z):
        super().__init__(x, y, z)

        self.add_collision_sphere(0, 0, 20, 20)
        self.sprite_shift_x = 32
        self.sprite_shift_y = 60

        colorkey = (255, 255, 255)
        self.spritesheet = SpriteSheet("player")
        self.animation = Animation(self.spritesheet)
        self.animation.add_animation_from_sheet("up", (0, 0, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("left", (0, 64, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("down", (0, 128, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("right", (0, 192, 64, 64), 9,
                                                colorkey)

        self.animation.add_animation_from_sheet("stand_up", (0, 0, 64, 64), 1,
                                                colorkey)
        self.animation.add_animation_from_sheet("stand_left", (0, 64, 64, 64),
                                                1, colorkey)
        self.animation.add_animation_from_sheet("stand_down", (0, 128, 64, 64),
                                                1, colorkey)
        self.animation.add_animation_from_sheet("stand_right",
                                                (0, 192, 64, 64), 1, colorkey)

        self.animation.set("stand_down")
        self.image = self.animation.get_image()

        self.action = State.STANDING

        self.interact_range = 100
示例#2
0
    def __init__(self, x, y, z):
        super().__init__(x, y, z)

        self.spritesheet = SpriteSheet("rock", (50 * 8, 50 * 8))
        self.animation = Animation(self.spritesheet)
        self.animation.add_animation_from_sheet("none", (0, 0, 50, 50), 8,
                                                (255, 255, 255))
        self.image = self.animation.get_image()
        self.sprite_shift_x = 25
        self.sprite_shift_y = 50

        self.add_collision_box(-15, -20, 30, 20)

        self.canMove = False
示例#3
0
    def __init__(self, x, y, z):
        super().__init__(x, y, z)

        self.spritesheet = SpriteSheet("rock", (25 * 8, 25 * 8))
        self.animation = Animation(self.spritesheet)
        self.animation.add_animation_from_sheet("none", (0, 0, 25, 25), 8,
                                                (255, 255, 255))
        self.image = self.animation.get_image()
        self.sprite_shift_x = 12.5
        self.sprite_shift_y = 25

        self.add_collision_box(-7.5, -10, 15, 10)

        self.canMove = False
示例#4
0
    def __init__(self, x, y, z):
        super().__init__(x, y, z)

        self.spritesheet = SpriteSheet("rick", (4 * 30, 4 * 40))
        self.animation = Animation(self.spritesheet)
        self.animation.add_animation_from_sheet("down", (0, 0, 30, 40), 4,
                                                (0, 0, 0))
        self.animation.add_animation_from_sheet("right", (0, 40, 30, 40), 4,
                                                (0, 0, 0))
        self.animation.add_animation_from_sheet("left", (0, 80, 30, 40), 4,
                                                (0, 0, 0))
        self.animation.add_animation_from_sheet("up", (0, 120, 30, 40), 4,
                                                (0, 0, 0))
        self.image = self.animation.get_image()

        self.sprite_shift_x = 15
        self.sprite_shift_y = 40

        self.add_collision_sphere(0, 0, 10, 10)

        self.canMove = True

        self.dialogue = Dialogue()
        self.dialogue.add_stage(0, "E", next_stage=1)
        self.dialogue.add_stage(1, "Hello!", next_stage=2)
        self.dialogue.add_stage(2, "How are you?", [(3, "Good"), (4, "OK"),
                                                    (5, "Bad")])
        self.dialogue.add_stage(3,
                                "That is great!\nI am doing Fine as well",
                                next_stage=6)
        self.dialogue.add_stage(
            4,
            "Well at least you aren't bad\nThat would be...\nBAD!!",
            next_stage=6)
        self.dialogue.add_stage(5,
                                "Thats not very good is it :(\n:(\n:(",
                                next_stage=6)
        self.dialogue.add_stage(6, "Please select a class:",
                                [(7, "MAGE\n(spooky)"),
                                 (8, "FIGHTER\n(less spooky)")])
        self.dialogue.add_stage(7,
                                "WOW A MAGE\npress [ENTER] to continue",
                                next_stage=9)
        self.dialogue.add_stage(8,
                                "WOW A FIGHER\npress [ENTER] to continue",
                                next_stage=9)
        self.dialogue.add_stage(9, "Bye   ", [], delay=50, end=True)
示例#5
0
class Player(Entity):
    def __init__(self, x, y, z):
        super().__init__(x, y, z)

        self.add_collision_sphere(0, 0, 20, 20)
        self.sprite_shift_x = 32
        self.sprite_shift_y = 60

        colorkey = (255, 255, 255)
        self.spritesheet = SpriteSheet("player")
        self.animation = Animation(self.spritesheet)
        self.animation.add_animation_from_sheet("up", (0, 0, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("left", (0, 64, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("down", (0, 128, 64, 64), 9,
                                                colorkey)
        self.animation.add_animation_from_sheet("right", (0, 192, 64, 64), 9,
                                                colorkey)

        self.animation.add_animation_from_sheet("stand_up", (0, 0, 64, 64), 1,
                                                colorkey)
        self.animation.add_animation_from_sheet("stand_left", (0, 64, 64, 64),
                                                1, colorkey)
        self.animation.add_animation_from_sheet("stand_down", (0, 128, 64, 64),
                                                1, colorkey)
        self.animation.add_animation_from_sheet("stand_right",
                                                (0, 192, 64, 64), 1, colorkey)

        self.animation.set("stand_down")
        self.image = self.animation.get_image()

        self.action = State.STANDING

        self.interact_range = 100

    def update(self, local_entities, player):
        self.animation.update()
        self.image = self.animation.get_image()

        speed = 5

        animation_state = self.animation.get_state()
        if animation_state == "up":
            self.y -= speed
        if animation_state == "left":
            self.x -= speed
        if animation_state == "down":
            self.y += speed
        if animation_state == "right":
            self.x += speed

    def do_action(self, action):
        if action == "standing":
            animation_state = self.animation.get_state()
            if animation_state == "up":
                self.animation.set("stand_up")
            if animation_state == "left":
                self.animation.set("stand_left")
            if animation_state == "down":
                self.animation.set("stand_down")
            if animation_state == "right":
                self.animation.set("stand_right")
            return
        self.animation.set(action)

    def __getstate__(self):
        return (self.x, self.y, self.action)

    def __setstate__(self, state):
        super().__setstate__((state[0], state[1]))
        self.action = state[2]