def jump(self): if self.action != 'Jump': return BehaviorTree.FAIL dx, dy = self.delta dy -= gravity dy = clamp(0, dy, 15) self.delta = (dx, dy) self.time += gfw.delta_time frame = self.time * Hornet.FPS self.fidx = int(frame) % len(self.images[self.action]) landform.get_ceiling(self) tempX, tempY = self.pos gobj.move_obj(self) l, _, r, t = self.get_bb_real() if l <= self.wall_l or r >= self.wall_r: self.pos = tempX, self.pos[1] if t >= self.ceiling: self.pos = tempX, tempY self.delta = dx, 0 self.action = 'Fall' self.time = 0 images = self.images['Jump'] self.fall_image = images[len(images) - 1] return BehaviorTree.SUCCESS if self.fidx == len(self.images['Jump']) - 1: self.action = 'Fall' self.time = 0 images = self.images['Jump'] self.fall_image = images[len(images) - 1] return BehaviorTree.SUCCESS return BehaviorTree.RUNNING
def update(self): dx, dy = self.knight.delta dy -= gravity self.knight.delta = (dx, dy) self.time += gfw.delta_time landform.get_ceiling(self.knight) tempX, tempY = self.knight.pos gobj.move_obj(self.knight) l, _, r, t = self.knight.get_bb_real() if l <= self.knight.wall_l or r >= self.knight.wall_r: self.knight.pos = tempX, self.knight.pos[1] if t >= self.knight.ceiling: self.knight.pos = tempX, tempY self.knight.delta = dx, 0 self.knight.set_state(FallState) tfidx = self.fidx frame = self.time * Knight.FPS self.fidx = int(frame) % len(self.images) if self.fidx < tfidx: self.fidx = tfidx if dy <= 0: self.knight.set_state(FallState)
def update(self): self.time += gfw.delta_time gobj.move_obj(self.knight) frame = self.time * Knight.FPS * 2 if frame < len(self.images): self.fidx = int(frame) else: self.knight.mask = 0
def update(self): self.simon.check_position() frame_number = 8 self.time += gfw.delta_time gobj.move_obj(self.simon) gobj.move_draw_obj(self.simon) if self.simon.delta == (0, 0): frame_number = 8 else: frame_number = 10 frame = self.time * 10 self.frame = int(frame) % frame_number
def update(self): dx, dy = self.delta if self.h.flip == 'h': dx -= 0.7 else: dx += 0.7 self.delta = dx, dy gobj.move_obj(self) self.time += gfw.delta_time frame = self.time * 10 if self.fidx != len(self.images) - 1: self.fidx = int(frame) % len(self.images)
def update(self): if self.action != 'Death': l, foot, r, _ = self.get_bb() cx = (l + r) / 2 landform.get_floor(self, cx, foot) if self.floor is not None: l, b, r, t = self.floor.get_bb() if foot > t: dx, dy = self.delta dy -= 0.4 self.delta = (dx, dy) else: x, y = self.pos self.pos = x, y + t - foot dx, dy = self.delta self.delta = (dx, 0) landform.get_wall(self) landform.get_ceiling(self) tempX, tempY = self.pos dx, dy = self.delta gobj.move_obj(self) l, _, r, t = self.get_bb_real() if l <= self.wall_l: self.pos = tempX, self.pos[1] self.flip = 'h' self.delta = (1, dy) elif r >= self.wall_r: self.pos = tempX, self.pos[1] self.flip = '' self.delta = (-1, dy) if t >= self.ceiling: self.pos = tempX, tempY self.delta = dx, 0 self.time += gfw.delta_time frame = self.time * 10 self.fidx = int(frame) if self.health == 0: self.sounds['enemy_death_sword.wav'].play() self.sounds['crawler.wav'].set_volume(0) self.action = 'Death' self.time = 0 self.delta = (0, 0) else: self.time += gfw.delta_time frame = self.time * 10 self.fidx = int(frame) self.fidx = clamp(0, self.fidx, len(self.images[self.action]) - 1)
def update(self): self.x = clamp(self.minx, self.x, self.maxx) # 플레이어가 화면을 벗어나지 못하도록 if self.dx == 0: self.fidx = 0 else: self.time += gfw.delta_time frame = self.time * 10 self.fidx = int(frame) % 7 if self.dx > 0: self.action = 0 elif self.dx < 0: self.action = 1 gobj.move_obj(self) self.update_size() self.update_invisible() self.update_angry()
def move(target): tempX, tempY = target.pos gobj.move_obj(target) l, _, r, _ = target.get_bb_real() if l <= target.wall_l or r >= target.wall_r: target.pos = tempX, target.pos[1]