Beispiel #1
0
 def update(self):
     self.fidx = (self.fidx + 1) % 8
     if self.target == None:
         self.speed = 1
         if len(self.target_list) != 0:
             self.target = copy.copy(self.target_list[0])
             self.target_list.pop(0)
             self.delta = helper.delta(self.pos, self.target, self.speed)
     helper.move_toward_obj(boy)
Beispiel #2
0
    def update(self):
        x, y = self.pos
        dx, dy = self.delta
        self.pos = x + dx, y + dy

        if self.target is not None:
            ddx = -self.delta[0]
            helper.move_toward_obj(self)
            if self.target == None:
                print("Removing target: ", self.targets[0],
                      " from %d target(s)." % len(self.targets))
                del self.targets[0]
                if len(self.targets) > 0:
                    helper.set_target(self, self.targets[0])
Beispiel #3
0
    def update(self):
        x, y = self.pos
        dx, dy = self.delta
        self.pos = x + dx, y + dy

        if self.target is not None:
            ddx = -self.delta[0]
            helper.move_toward_obj(self)
            if self.target == None:
                print("Done")
                print("Removing target: ", self.targets[0], " from %d target(s)." % len(self.targets))
                del self.targets[0]
                if len(self.targets) > 0:
                    helper.set_target(self, self.targets[0])
                    self.updateAction(self.delta[0], 0)
                else:
                    self.speed = 0
        self.fidx = (self.fidx + 1) % 8
Beispiel #4
0
    def update(self):
        stage1 = ((26, 45), (94, 90), (162, 135), (230, 180))

        x, y = self.pos
        dx, dy = self.delta
        self.pos = x + dx, y + dy
        self.animation += self.count
        bex, bey = self.pos
        if (self.animation > 0.9):
            self.animation = 0
        if (x > 741):
            self.pos = 741, y + dy
        if (x < 60):
            self.pos = 60, y + dy
        if (y > 538):
            self.pos = x + dx, 538
        if (y < 81):
            self.pos = x + dx, 81

        unx1, uny1 = stage1[3]
        if (self.action == 1 and (unx1 - 20 <= x and unx1 + 90 >= x
                                  and uny1 + 20 <= y and uny1 + 80 >= y)):
            self.pos = x - 5, y
        elif (self.action == 0 and (unx1 - 20 <= x and unx1 + 90 >= x
                                    and uny1 + 20 <= y and uny1 + 80 >= y)):
            self.pos = x + 5, y
        elif (self.action == 5 and (unx1 - 20 <= x and unx1 + 90 >= x
                                    and uny1 + 20 <= y and uny1 + 80 >= y)):
            self.pos = x, y - 5
        elif (self.action == 4 and (unx1 - 20 <= x and unx1 + 90 >= x
                                    and uny1 + 20 <= y and uny1 + 80 >= y)):
            self.pos = x, y + 5

        if self.target is not None:
            ddx = -self.delta[0]
            helper.move_toward_obj(self)
            if self.target == None:
                del self.targets[0]
                if len(self.targets) > 0:
                    helper.set_target(self, self.targets[0])
                    self.updateAction(self.delta[0], 0)
                else:
                    self.speed = 0
                    self.updateAction(0, ddx)
Beispiel #5
0
    def Update(self):
        self.fidx = (self.fidx + 1) % 8
        helper.move_toward_obj(boy)

        if self.target == None:
            self.speed = 1
Beispiel #6
0
    def update(self):
        map1 = ((94,45),(94,135),(94,225),(94,320),(94,415),(94,508) ,\
                (230,45),(230,135),(230,225),(230,320),(230,415),(230,508) ,\
                (365,45),(365,135),(365,225),(365,320),(365,415),(365,508) ,\
                (503,45),(503,135),(503,225),(503,320),(503,415),(503,508) ,\
                (639,45),(639,135),(639,225),(639,320),(639,415),(639,508))

        x, y = self.pos
        dx, dy = self.delta
        self.pos = x + dx, y + dy
        self.animation += self.count

        if (self.animation > 0.9):
            self.animation = 0
        if (x > 741):
            self.pos = 741, y + dy
        if (x < 60):
            self.pos = 60, y + dy
        if (y > 538):
            self.pos = x + dx, 538
        if (y < 81):
            self.pos = x + dx, 81

        sx1, sy1 = self.save1
        if sx1 - 100 <= x and sx1 + 100 >= x and sy1 - 70 <= y and sy1 + 70 >= y:
            self.lifecount -= 0.01
        else:
            self.lifecount -= 0.05
        sx2, sy2 = self.save2
        if sx2 - 100 <= x and sx2 + 100 >= x and sy2 - 70 <= y and sy2 + 70 >= y:
            self.lifecount -= 0.01
        else:
            self.lifecount -= 0.05

        sx3, sy3 = self.save3
        if sx3 - 100 <= x and sx3 + 100 >= x and sy3 - 70 <= y and sy3 + 70 >= y:
            self.lifecount -= 0.01
        else:
            self.lifecount -= 0.05

        print("1p", self.lifecount)
        if self.lifecount < 0:
            gfw.change(winp2)

        for i in range(30):
            unx1, uny1 = map1[i]
            if (self.action == 1 and (unx1 - 20 < x and unx1 + 90 > x
                                      and uny1 + 20 < y and uny1 + 80 > y)):
                self.pos = x - 5, y
            elif (self.action == 0 and (unx1 - 20 < x and unx1 + 90 > x
                                        and uny1 + 20 < y and uny1 + 80 > y)):
                self.pos = x + 5, y
            elif (self.action == 5 and (unx1 - 20 < x and unx1 + 90 > x
                                        and uny1 + 20 < y and uny1 + 80 > y)):
                self.pos = x, y - 5
            elif (self.action == 4 and (unx1 - 20 < x and unx1 + 90 > x
                                        and uny1 + 20 < y and uny1 + 80 > y)):
                self.pos = x, y + 5

        if self.target is not None:
            ddx = -self.delta[0]
            helper.move_toward_obj(self)
            if self.target == None:
                del self.targets[0]
                if len(self.targets) > 0:
                    helper.set_target(self, self.targets[0])
                    self.updateAction(self.delta[0], 0)
                else:
                    self.speed = 0
                    self.updateAction(0, ddx)
Beispiel #7
0
 def update(self):
     self.frame = (self.frame + 1) % 8
     helper.move_toward_obj(boy)
     if boy.target == None:
         boy.speed = 0