def onClick(context): global garage, player_info if context == 'racestart': game_framework.push_state(racing_state) if context == 'buy': have = player_info['coin'] cost = car_info[str(garage.slot[garage.select])]['cost'] if have >= cost: player_info['coin'] -= cost player_info['level'] += 1 player_info['have'].append(garage.slot[garage.select]) save_data() else: pass if context == 'before': game_framework.pop_state() if context == 'la': if garage.slot[0] > 0: garage.slot = [x - 1 for x in garage.slot] if context == 'ra': if garage.slot[2] < MAX_LEV - 1: garage.slot = [x + 1 for x in garage.slot] if context[0] == 's' and len(context) == 2: if context == 's1': garage.select = 0 if context == 's2': garage.select = 1 if context == 's3': garage.select = 2 if context == 'diff_up': garage.difficulty = pico2d.clamp(0, garage.difficulty + 1, 5) if context == 'diff_down': garage.difficulty = pico2d.clamp(0, garage.difficulty - 1, 5)
def update(self): self.q3l = (int(self.focus_object.pivot.x) - self.canvas_width // 2) % self.w self.q3b = (int(self.focus_object.pivot.y) - self.canvas_height // 2) % self.h self.q3w = pico2d.clamp(0, self.w - self.q3l, self.w) self.q3h = pico2d.clamp(0, self.h - self.q3b, self.h) # quadrant 2 self.q2l = 0 self.q2b = 0 self.q2w = 0 self.q2h = 0 # quadrand 4 self.q4l = 0 self.q4b = 0 self.q4w = 0 self.q4h = 0 # quadrand 1 self.q1l = 0 self.q1b = 0 self.q1w = 0 self.q1h = 0 pass
def update(self): # fill here self.window_left = pico2d.clamp( 0, int(self.focus_object.pivot.x) - self.canvas_width // 2, self.w - self.canvas_width) self.window_bottom = pico2d.clamp( 0, int(self.focus_object.pivot.y) - self.canvas_height // 2, self.h - self.canvas_height) pass
def update(self): global player, bg, info # ============= 좌표 업데이트 ============== self.frame_timer += info.elapsed self.draw_timer += info.elapsed if self.draw_timer > self.draw_interval: self.draw_timer = 0 self.frame = (self.frame + 1) % self.max_frame if self.frame_timer > DELAY: self.frame_timer = 0 #self.y_speed = pico2d.clamp(-self.max_speed, self.y_speed + self.accel, self.max_speed) #속도 += 가속도 self.y_speed = pico2d.clamp(-self.max_speed, self.y_speed + self.accel, self.max_speed) #속도 += 가속도 self.y += (self.y_speed - player.car.y_speed) self.x_speed = self.dir * self.max_speed / 2 self.x = pico2d.clamp(100, self.x + self.x_speed, cw - 100)
def arrow_up(): if self.csr_difficult == -1: self.csr_music = pico2d.clamp(0, self.csr_music - 1, len(self.music_list) - 1) change_art() else: # 앞의 난이도로 이동 difficult_list = self.music_list[ self.csr_music].get_difficult_csr_list() self.csr_difficult = difficult_list[ difficult_list.index(self.csr_difficult) - 1]
def arrow_down(): if self.csr_difficult == -1: self.csr_music = pico2d.clamp(0, self.csr_music + 1, len(self.music_list) - 1) change_art() else: # 뒤의 난이도로 이동 difficult_list = self.music_list[ self.csr_music].get_difficult_csr_list() self.csr_difficult = difficult_list[ (difficult_list.index(self.csr_difficult) + 1) % len(difficult_list)]
def update(self): global player if self.state == DEAD: self.reset() # ============= 좌표 업데이트 ============== self.x_speed = 200*DELAY*self.dir*math.log2(self.level+1) self.x = pico2d.clamp(100, self.x + self.x_speed, WIDTH - 100) self.y_speed = pico2d.clamp(-MAX_SPEEDS[self.level], self.y_speed + self.accel, MAX_SPEEDS[self.level]) #속도 += 가속도 self.y -= (player.car.y_speed - self.y_speed) #내 차와의 상대속도만큼 y위치 변경 if self.y < -100 or self.y > HEIGHT + 200: self.reset() # ============= 상태 업데이트 ============== if self.y_speed == 0: self.state = STOP elif self.dir == 1: self.state = RIGHT elif self.dir == -1: self.state = LEFT else: self.state = UP self.counter = (self.counter + 1)%100
def update(self): self.timer -= GameFrameWork.frame_time if self.timer < 0: self.timer += self.MOVING_TIMER self.pivot.y += self.dir * 1 if self.pivot.y >= (self.starting_y + self.jump_max): self.dir = -1 elif self.pivot.y <= (self.starting_y - self.jump_max): self.dir = 1 self.pivot.y = pico2d.clamp(self.starting_y - self.jump_max, self.pivot.y, self.starting_y + self.jump_max) pass
def wave(level): global cars, lock print('wave level: ', level) wave_cars = [] w = (cw - 200) / 20 for i in range(level): new_cars = [Car(pico2d.clamp(0, i, MAX_LEV - 1)) for _ in range(20)] for j in range(len(new_cars)): if j == 0: new_cars[j].y = ch + ((i + 1) * 30) new_cars[j].x = 100 else: new_cars[j].x = new_cars[j - 1].x + w new_cars[j].y = new_cars[j - 1].y new_cars[j].y_speed = -1 wave_cars += new_cars with lock: cars += wave_cars
def arrow_down(): self.csr = pico2d.clamp(0, self.csr + 1, 1)
def arrow_up(): self.csr = pico2d.clamp(0, self.csr - 1, 1)
def do_RUN(self): self.frame = (self.frame + 1) % 8 self.x += self.velocity self.x = pico2d.clamp(25, self.x, 800 - 25)