def __init(self): back = gfw.Sprite('./res/bk/bb.png') back.x = gfw.SCREEN_WIDTH * 0.5 back.y = gfw.SCREEN_HEIGHT * 0.5 gfw.renderer.add(back) self.font = gfw.Text('./res/font.ttf', 48) self.font.x = SCREEN_WIDTH - 680.0 self.font.y = SCREEN_HEIGHT * 0.5 self.font.color_r = 255 self.font.color_g = 255 self.font.color_b = 255 self.font.text = 'SCORE: 0' gfw.renderer.add_font(self.font) self.black_screen = gfw.Sprite('./res/bk/bb.png') self.black_screen.x = gfw.SCREEN_WIDTH * 0.5 self.black_screen.y = gfw.SCREEN_HEIGHT * 0.5 self.black_screen.alpha = 0.0 self.black_screen.active = False gfw.renderer.add(self.black_screen) self.ok_button = gfw.Sprite('./res/ok_button.png') self.ok_button.x = SCREEN_WIDTH * 0.5 self.ok_button.y = SCREEN_HEIGHT * 0.3 gfw.renderer.add(self.ok_button) self.bgm_score = load_wav('./res/sound/score.wav') self.select_button = load_wav('./res/sound/button_off.wav') self.bgm_score.play()
def __init(self): self.back = gfw.Sprite('./res/title.png') self.back.x = gfw.SCREEN_WIDTH * 0.5 self.back.y = gfw.SCREEN_HEIGHT * 0.5 gfw.renderer.add(self.back) self.back_kpu = gfw.Sprite('./res/title_kpu.png') self.back_kpu.x = gfw.SCREEN_WIDTH * 0.5 self.back_kpu.y = gfw.SCREEN_HEIGHT * 0.5 gfw.renderer.add(self.back_kpu) self.white_screen = gfw.Sprite('./res/bk/bw.png') self.white_screen.x = gfw.SCREEN_WIDTH * 0.5 self.white_screen.y = gfw.SCREEN_HEIGHT * 0.5 self.white_screen.alpha = 0.0 gfw.renderer.add(self.white_screen) self.black_screen = gfw.Sprite('./res/bk/bb.png') self.black_screen.x = gfw.SCREEN_WIDTH * 0.5 self.black_screen.y = gfw.SCREEN_HEIGHT * 0.5 self.black_screen.alpha = 0.0 self.black_screen.active = False gfw.renderer.add(self.black_screen) self.loading = load_wav('./res/sound/loading.wav') self.pressed_button = load_wav('./res/sound/button_on.wav') self.loading_done = load_wav('./res/sound/title.wav') self.loading.play()
def __init__(self, data, offset_x): super().__init__(data, offset_x) self.ate_sound = load_wav('./res/sound/jelly.wav') self.frame_count = 0 self.kind = int(data['name'][1]) self.score = 0 if data['name'] == 'j0' or data['name'] == 'j1': self.spr = gfw.Sprite('./res/basic_jellies.png') self.frame_count = 3 self.spr.cell_image_width = 38 self.spr.cell_index_x = self.kind * self.frame_count self.score = 10 else: self.spr = gfw.Sprite('./res/bear_jellies.png') if self.kind % 2 == 0: self.frame_count = 1 else: self.frame_count = 2 if self.kind == 2: self.spr.cell_index_x = 0 elif self.kind == 3: self.spr.cell_index_x = 1 elif self.kind == 4: self.spr.cell_index_x = 3 elif self.kind == 5: self.spr.cell_index_x = 4 elif self.kind == 6: self.spr.cell_index_x = 6 elif self.kind == 7: self.spr.cell_index_x = 7 elif self.kind == 8: self.spr.cell_index_x = 9 elif self.kind == 9: self.spr.cell_index_x = 10 self.spr.cell_image_width = 55 self.score = 20 self.spr.cell_image_height = 51 self.spr.x = data["x"] + offset_x self.spr.y = data["y"] self.spr.is_clip_image = True self.spr.padding_size = 2 self.spr.cell_index_y = 0 gfw.renderer.add(self.spr) self.init_col_box()
def __init__(self, data, offset_x): super().__init__(data, offset_x) self.kind = data['name'][1] self.ate_sound = load_wav('./res/sound/hpup_' + self.kind + '.wav') self.ate_sound.set_volume(128) self.spr = gfw.Sprite('./res/potion_' + self.kind + '.png') self.spr.x = data["x"] + offset_x self.spr.y = data["y"] if self.kind == '1': self.spr.is_clip_image = True self.spr.cell_image_width = 144 self.spr.cell_image_height = 144 self.spr.padding_size = 2 self.spr.cell_index_x = 0 self.spr.cell_index_y = 0 gfw.renderer.add(self.spr) self.elapsed_time = 0.0 self.hp = 0.0 if self.kind == 0: self.hp = 10.0 else: self.hp = 20.0 self.init_col_box()
def __init__(self, data, offset_x): super().__init__(data, offset_x) self.attack_sound = load_wav('./res/sound/obs.wav') self.attack_sound.set_volume(128) self.kind = data['name'][1] self.spr = gfw.Sprite('./res/stage/6/o' + self.kind + '.png') self.spr.x = data["x"] + offset_x self.spr.y = data["y"] if int(self.kind) > 4: self.spr.is_clip_image = True self.spr.padding_size = 0 self.spr.cell_index_x = 0 self.spr.cell_index_y = 0 if int(self.kind) == 5: self.spr.cell_image_width = 69 self.spr.cell_image_height = 131 elif int(self.kind) == 6: self.spr.cell_image_width = 118 self.spr.cell_image_height = 249 gfw.renderer.add(self.spr) self.init_col_box() self.elapsed_time = 0.0
def __init__(self, data, offset_x): super().__init__(data, offset_x) self.spr = gfw.Sprite('./res/stage/6/t1.png') self.spr.x = data["x"] + offset_x self.spr.y = data["y"] gfw.renderer.add(self.spr) self.init_col_box()
def __init__(self, image_path, repeat_count, speed, scale): self.speed = speed self.repeat_count = repeat_count self.back_pieces = [ gfw.Sprite(image_path) for i in range(repeat_count) ] for i in range(0, repeat_count): piece = self.back_pieces[i] piece.scale_x = scale piece.scale_y = scale piece.x = i * piece.image.w * piece.scale_x piece.origin_x = 0.0 piece.origin_y = 0.0 gfw.renderer.add(piece)
def __init__(self, image_path, cell_image_w, cell_image_h, min_y, tile_y): self.min_y = min_y self.tile_y = tile_y self.cookie = gfw.Sprite(image_path) self.cookie.is_clip_image = True self.cookie.padding_size = 2 self.cookie.cell_image_width = cell_image_w self.cookie.cell_image_height = cell_image_h self.cookie.cell_index_x = 1 self.cookie.cell_index_y = 4 self.cookie.scale_x = 1.0 self.cookie.scale_y = 1.0 self.cookie.x = 120.0 self.cookie.y = self.min_y gfw.renderer.add(self.cookie) self.acc = 0.0 self.elapsed_time = 0.0 self.speedY = 0.0 self.state = RUN self.jump_sound = load_wav('./res/sound/jump.wav') self.slide_sound = load_wav('./res/sound/slide.wav') self.col_box_x = self.cookie.x self.col_box_y = self.cookie.y self.col_box_w = 0.0 self.col_box_h = 0.0 self.run_col_box_w = 0.0 self.run_col_box_h = 0.0 self.run_col_offset_y = 0.0 self.slide_col_box_w = 0.0 self.slide_col_box_h = 0.0 self.slide_col_offset_y = 0.0 self.jump_col_box_w = 0.0 self.jump_col_box_h = 0.0 self.jump_col_offset_y = 0.0 self.djump_col_box_w = 0.0 self.djump_col_box_h = 0.0 self.djump_col_offset_y = 0.0 self.hp = 100.0
def __init__(self, data, offset_x): super().__init__(data, offset_x) self.ate_sound = load_wav('./res/sound/dessert.wav') self.spr = gfw.Sprite('./res/desserts.png') self.spr.x = data["x"] + offset_x self.spr.y = data["y"] self.spr.cell_image_width = 66 self.spr.cell_image_height = 66 self.spr.is_clip_image = True self.spr.padding_size = 2 self.kind = random.randrange(0, 30) self.spr.cell_index_x = self.kind self.spr.cell_index_y = 0 gfw.renderer.add(self.spr) self.score = 30 self.init_col_box()
def init(self): self.start = False self.stop_game = False self.bgm = load_music('./res/sound/bgm_gameplay.mp3') self.bgm.repeat_play() self.game_over_sound = load_music('./res/sound/end.mp3') self.game_over_sound.set_volume(64) self.select_button_sound = load_wav('./res/sound/button_off.wav') self.font = gfw.Text('./res/font.ttf', 32) self.font.x = SCREEN_WIDTH - 250.0 self.font.y = SCREEN_HEIGHT - 60.0 self.font.color_r = 0 self.font.color_g = 0 self.font.color_b = 0 self.font.text = 'SCORE: 0' gfw.renderer.add_font(self.font) self.background1 = Background('./res/bk/bk6-1.png', 2, 400.0, 2) self.background2 = Background('./res/bk/bk6-2.png', 2, 450.0, 2) self.background3 = Background('./res/bk/bk6-3.png', 2, 480.0, 2) self.background4 = Background('./res/bk/bk6-4.png', 2, 550.0, 2) self.tile = Background('./res/stage/6/t0.png', 12, 450.0, 1) self.items = [] self.tiles = [] self.obstacles = [] object_datas = {} for i in range(50): objects = None if self.start == False: with open('./res/data/objects0.json') as f: objects = json.load(f) self.start = True else: path = './res/data/objects' + str( random.randrange(0, self.ITEM_P_COUNT)) + '.json' if not path in object_datas: with open('./res/data/objects' + str(random.randrange(0, self.ITEM_P_COUNT)) + '.json') as f: object_datas[path] = json.load(f) objects = object_datas[path] for o in objects: obj_first_name = o['name'][0] if obj_first_name == 'j': self.items.append(Jelly(o, i * gfw.SCREEN_WIDTH)) elif obj_first_name == 'd': self.items.append(Dessert(o, i * gfw.SCREEN_WIDTH)) elif obj_first_name == 'p': self.items.append(Potion(o, i * gfw.SCREEN_WIDTH)) elif obj_first_name == 't': self.tiles.append(Tile(o, i * gfw.SCREEN_WIDTH)) elif obj_first_name == 'o': self.obstacles.append(Obstacle(o, i * gfw.SCREEN_WIDTH)) self.cookie = None if self.cookie_type == 0: self.cookie = BraveCookie() else: self.cookie = ZombieCookie() self.hp_bar = gfw.Sprite('./res/hp_bar.jpg') self.hp_bar.x = 30.0 self.hp_bar.y = SCREEN_HEIGHT - 42.0 self.hp_bar.scale_x = 0.5 self.hp_bar.scale_y = 0.5 self.hp_bar.origin_x = 0.0 self.hp_bar.origin_y = 1.0 gfw.renderer.add(self.hp_bar) self.potion_0 = gfw.Sprite('./res/potion_0.png') self.potion_0.y = SCREEN_HEIGHT self.potion_0.origin_x = 0.0 self.potion_0.origin_y = 1.0 gfw.renderer.add(self.potion_0) self.hp = gfw.Sprite('./res/hp.png') self.hp.x = 70.0 # max: 535, min: 70.0 self.hp.y = SCREEN_HEIGHT - 42.0 self.hp.scale_x = 0.5 self.hp.scale_y = 0.5 self.hp.origin_x = 0.0 self.hp.origin_y = 1.0 gfw.renderer.add(self.hp) self.black_screen = gfw.Sprite('./res/bk/bb.png') self.black_screen.x = gfw.SCREEN_WIDTH * 0.5 self.black_screen.y = gfw.SCREEN_HEIGHT * 0.5 self.black_screen.alpha = 0.0 self.black_screen.active = False gfw.renderer.add(self.black_screen) self.resume_button = gfw.Sprite('./res/resume_button.png') self.resume_button.x = SCREEN_WIDTH * 0.5 - 180.0 self.resume_button.y = SCREEN_HEIGHT * 0.5 self.resume_button.active = False gfw.renderer.add(self.resume_button) self.exit_button = gfw.Sprite('./res/exit_button.png') self.exit_button.x = SCREEN_WIDTH * 0.5 + 180.0 self.exit_button.y = SCREEN_HEIGHT * 0.5 self.exit_button.active = False gfw.renderer.add(self.exit_button) self.score = 0.0