def enter(): global sound, check_start, font, title_font, sound2, sound3 gfw.world.init(['bg', 'tile', 'ui']) center = get_canvas_width() // 2, get_canvas_height() // 2 gfw.world.add(gfw.layer.bg, gobj.ImageObject('메인배경.png', center)) gfw.world.add(gfw.layer.ui, gobj.ImageObject('시작 제목.png', (200, 100))) stage_gen.load(gobj.res('tile.txt')) sound = load_music(gobj.res('반짝반짝작은별.mp3')) sound2 = load_music(gobj.res('반짝반짝작은별2.mp3')) sound3 = load_music(gobj.res('반짝반짝작은별3.mp3')) font = gfw.font.load(gobj.res('NanumGothic.TTF'), FONT_SIZE + 20) title_font = gfw.font.load(gobj.res('NanumGothic.TTF'), FONT_SIZE) highscore.load(FONT_SIZE) global END, check_start, play_speed, collision_count END = False check_start = False play_sound_time = 0 collision_count = 0 Tile.start = False Tile.SCORE = 0 evts = get_events() for e in evts: handle_event(e)
def build_world(): gfw.world.init(['bg', 'title']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('메뉴배경.png', center) gfw.world.add(gfw.layer.bg, bg) pos = (center[0], canvas_height * 0.87) title = gobj.ImageObject('음악선택이미지.png', pos) gfw.world.add(gfw.layer.title, title)
def enter(): enemy.dead = 0 enemy.life = 100 gfw.world.init(['bg', 'card', 'state', 'ui']) gfw.world.remove(highscore) center = get_canvas_width() // 2, get_canvas_height() // 1.4 center2 = get_canvas_width() // 2, 250 hp = 150, 700 gfw.world.add(gfw.layer.bg, gobj.ImageObject(theme + '/black.png', center2)) gfw.world.add(gfw.layer.bg, gobj.ImageObject(theme + '/bg.png', center)) #gfw.world.add(gfw.layer.bg, gobj.ImageObject(theme + '/gaugefg.png', hp)) x, y = start_x, start_y idxs = [n + 1 for n in range(9)] #print('before:', idxs) #random.shuffle(idxs) #print('after: ', idxs) for i in range(0, 9, +3): print(idxs[i:i + 3]) for i in idxs: c = Pattern(i, (x, y), theme) gfw.world.add(gfw.layer.card, c) x += Pattern.WIDTH + PADDING - 100 if x > get_canvas_width(): x = start_x y -= Pattern.HEIGHT + PADDING - 100 icon = Skil(1, (150, 200), theme) gfw.world.add(gfw.layer.card, icon) pla = Player(1, (550, 450), theme) gfw.world.add(gfw.layer.card, pla) ene = Enemy(1, (150, 480), theme) gfw.world.add(gfw.layer.card, ene) global last_card last_card = None global TIME, font TIME = 1000 font = gfw.font.load(gobj.res('ENCR10B.TTF'), 20) highscore.load() global bg_music, flip_wav bg_music = load_music(gobj.res('bg1.mp3')) bg_music.set_volume(60) flip_wav = load_wav(gobj.res('pipe.wav')) bg_music.repeat_play()
def enter(): global title_font, score_font gfw.world.init(['bg', 'button']) center = get_canvas_width() // 2, get_canvas_height() // 2 gfw.world.add(gfw.layer.bg, gobj.ImageObject('결과배경.png', center)) pos = get_canvas_width() // 2, 150 gfw.world.add(gfw.layer.button, gobj.ImageObject('결과화면 버튼.png', pos)) score_font = gfw.font.load(gobj.res('NanumGothic.TTF'), 100) title_font = gfw.font.load(gobj.res('NanumGothic.TTF'), TITLE_FONT_SIZE) highscore.load(TITLE_FONT_SIZE) highscore.add(Tile.SCORE)
def build_world(): global title gfw.world.init(['bg', 'title']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('메뉴배경.png', center) gfw.world.add(gfw.layer.bg, bg) pos = (center[0], canvas_height * 0.87) title = gobj.ImageObject('음악선택이미지.png', pos) gfw.world.add(gfw.layer.title, title) global main_sound main_sound = load_music(gobj.res('반짝반짝작은별.mp3'))
def build_world(): gfw.world.init(['bg', 'ui']) center = (gobj.canvas_width // 2, gobj.canvas_height // 2) bg = gobj.ImageObject('Title_Bg.png', center) gfw.world.add(gfw.layer.bg, bg) # Button(l, b, w, h, font, text, callback, btnClass=None): font = gfw.font.load(gobj.res('ENCR10B.TTF'), 40) l, b, w, h = gobj.canvas_width / 2 - 270 / 2, 120, 270, 140 btn = Button(l, b, w, h, font, '', lambda: push_play_select()) btn.normalBg = ('Play', 'Normal') btn.hoverBg = ('Play', 'Hover') btn.pressedBg = ('Play', 'Pressed') btn.update_Img() gfw.world.add(gfw.layer.ui, btn) b -= 100 btn = Button(l, b, w, h, font, "", lambda: push_record_select()) btn.normalBg = ('Record', 'Normal') btn.hoverBg = ('Record', 'Hover') btn.pressedBg = ('Record', 'Pressed') btn.update_Img() gfw.world.add(gfw.layer.ui, btn) global bgm bgm = load_music(gobj.res('Bgm_Main.mp3')) bgm.repeat_play()
def build_world(): gfw.world.init(['poker_bg','ingame_ui','card']) center = get_canvas_width()//2, get_canvas_height()//2 gfw.world.add(gfw.layer.poker_bg, gobj.ImageObject(theme + '/board.png', center)) global font font = gfw.font.load(gobj.res('StarcraftNormal.ttf'), 40) l,b,w,h = 25,550,get_canvas_width()-550,50 btn = Button(l,b,w,h,font,"ingame",lambda: start("ingame")) gfw.world.add(gfw.layer.ingame_ui, btn) x,y = 100,100 global c shape = ['Club','Diamond','Heart','spade'] index = [1,2,3,4,5,6,7,8,9,10,11,12,13] c1 = [random.choice(index)] c2 = [random.choice(shape)] for i in range(0,5): c = Card(c1[i],(x,y),c2[i],theme) gfw.world.add(gfw.layer.card, c) nc1 = random.choice(index) nc2 = random.choice(shape) c1.append(nc1) c2.append(nc2) x+=150 rank = check_hands.hands(c1,c2) print(rank)
def build_world(): global title_bg, menu_pointer gfw.world.init(['title_bg', 'menu_pointer']) title_bg = gobj.ImageObject('title.png', (canvas_width // 2, canvas_height // 2)) gfw.world.add(gfw.layer.title_bg, title_bg) menu_pointer = gobj.ImageObject('menu_pointer.png', (canvas_width // 2, canvas_height // 4)) gfw.world.add(gfw.layer.menu_pointer, menu_pointer) global title_bgm, change_selection, button_confirm title_bgm = gfw.sound.load_m('res/Sound/Title.mp3') change_selection = gfw.sound.load_w('res/Sound/ui_change_selection.wav') button_confirm = gfw.sound.load_w('res/Sound/ui_button_confirm.wav') title_bgm.repeat_play()
def enter(): global title_font, score_font gfw.world.init(['bg']) center = get_canvas_width() // 2, get_canvas_height() // 2 gfw.world.add(gfw.layer.bg, gobj.ImageObject('결과배경.png', center)) score_font = gfw.font.load(gobj.res('NanumGothic.TTF'), 100) title_font = gfw.font.load(gobj.res('NanumGothic.TTF'), TITLE_FONT_SIZE)
def enter(): gfw.world.init(['bg', 'card']) center = get_canvas_width()//2, get_canvas_height()//2 gfw.world.add(gfw.layer.bg, gobj.ImageObject(theme + '/bg.png', center)) x,y = start_x, start_y idxs = [n + 1 for n in range(10)] * 2 # print('before:', idxs) random.shuffle(idxs) # print('after: ', idxs) for i in range(15, -1, -5): print(idxs[i:i+5]) for i in idxs: c = Card(i, (x,y), theme) gfw.world.add(gfw.layer.card, c) x += Card.WIDTH + PADDING if x > get_canvas_width(): x = start_x y += Card.HEIGHT + PADDING global last_card last_card = None global score, font score = 0 font = gfw.font.load(gobj.res('ENCR10B.TTF'), 20) global bg_music, flip_wav bg_music = load_music(gobj.res('bg.mp3')) bg_music.set_volume(60) flip_wav = load_wav(gobj.res('pipe.wav')) bg_music.repeat_play()
def enter(): gfw.world.init(['bg', 'monster', 'unit', 'unit', "gameclear"]) Monster.load_all_images() Unit.load_all_images() life_gauge.load() gameclear.load() global selectedUnit if load(): unit = gfw.world.object(gfw.layer.unit, 0) else: unit = Unit(1) selectedUnit = unit gfw.world.add(gfw.layer.unit, unit) gfw.world.add(gfw.layer.unit, Unit(1)) gfw.world.add(gfw.layer.unit, Unit(1)) gfw.world.add(gfw.layer.unit, Unit(1)) bg = gobj.ImageObject('background.jpg', (canvas_width // 2, canvas_height // 2)) gfw.world.add(gfw.layer.bg, bg) magic_circle = gobj.ImageObject( 'magic.png', (gobj.magic_circle_pos[0], gobj.magic_circle_pos[1])) gfw.world.add(gfw.layer.bg, magic_circle) global font, font2 font = gfw.font.load(gobj.RES_DIR + '/Sweet_story.otf', 50) font2 = gfw.font.load(gobj.RES_DIR + '/ConsolaMalgun.ttf', 20) global monster_time monster_time = 1 global monster_level monster_level = 1 global monster_level_up_time monster_level_up_time = 50 global unit_time unit_time = 50 global music_bg, end_music music_bg = load_music('res/Track 5.mp3') music_bg.set_volume(10) end_music = load_music('res/Track 26.mp3') end_music.set_volume(10) music_bg.repeat_play()
def enter(): gfw.world.init(['result']) global end_time, change end_time = 0 change = False global clear_bgm, over_bgm if GAME_CLEAR: clear_bgm = gfw.sound.load_m('res/Sound/S30 White Palace.mp3') clear = gobj.ImageObject('GameClear.png', (canvas_width // 2, canvas_height // 2)) clear_bgm.repeat_play() gfw.world.add(gfw.layer.result, clear) else: over_bgm = gfw.sound.load_m('res/Sound/Hollow Shade Music.mp3') over = gobj.ImageObject('GameOver.png', (canvas_width // 2, canvas_height // 2)) over_bgm.repeat_play() gfw.world.add(gfw.layer.result, over)
def enter(): gfw.world.init(['bg', 'ui']) center = (canvas_width // 2, canvas_height // 2) sound.init() if gobj.IS_VICTORY: bg = gobj.ImageObject('victory.png', center) sound.se_victory.play() else: bg = gobj.ImageObject('defeat.png', center) sound.se_defeat.play() gfw.world.add(gfw.layer.bg, bg) global font font = gfw.font.load(gobj.res('Sam3KRFont.ttf'), 35) global l, b, w, h l, b, w, h = 50, 100, get_canvas_width() - 100, 80 btn = Button(l, b, w, h, font, "Back to Title", lambda: back_to_title()) gfw.world.add(gfw.layer.ui, btn)
def __init__(self, index, pos, theme='.'): fps = random.randrange(3, 5) fps2 = random.randrange(3, 6) self.x, self.y = pos self.bg = gobj.AnimObject3(theme + '/enemyn1.png', pos, fps) self.fg = gobj.ImageObject(theme + '/enemyn2.png', pos) self.bbg = gobj.AnimObject3(theme + '/enemyn3.png', pos, fps) self.image = self.bg self.index = index
def enter(): gfw.world.init(['bg', 'zombie', 'player']) global player player = Player() gfw.world.add(gfw.layer.player, player) bg = gobj.ImageObject('kpu_1280x960.png', (canvas_width // 2, canvas_height // 2)) gfw.world.add(gfw.layer.bg, bg) global zombie_time zombie_time = 1 Zombie.load_all_images()
def build_world(): bg_music.set_volume(10) bg_music.repeat_play() gfw.world.init(['bg', 'ui']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('lobbyBG.png', center) gfw.world.add(gfw.layer.bg, bg) global font font = gfw.font.load(gobj.res('ENCR10B.TTF'), 40) l, b, w, h = 670, 450, get_canvas_width() / 3, 80 btn = Button(l, b, w, h, font, "Play game", lambda: start("horz_state")) gfw.world.add(gfw.layer.ui, btn)
def music_end(): global numOfHit, numOfNote, resultFont, isEnd, music gfw.world.add( gfw.layer.ui, gobj.ImageObject('Play_Result.png', (get_canvas_width() / 2, get_canvas_height() / 2))) percent = numOfHit / numOfNote * 100 gfw.world.add( gfw.layer.ui, textAlert(resultFont, str(percent), get_canvas_width() / 2, get_canvas_height() / 2 - 130, 300, 200, 500)) resultMusic = load_wav(gobj.res('Bgm_Result.wav')) resultMusic.play(1) isEnd = True
def build_world(): gfw.world.init(['bg', 'ui']) center = (canvas_width//2, canvas_height//2) bg = gobj.ImageObject('gameover.png', center) gfw.world.add(gfw.layer.bg, bg) font = gfw.font.load(gobj.res('ENCR10B.TTF'), 40) l,b,w,h = 600,450,get_canvas_width()/3 + 90,80 btn = Button(l,b,w,h,font,"retry game", lambda: gfw.pop()) gfw.world.add(gfw.layer.ui, btn) value = 'save score : %.lf' %horz_state.score l,b,w,h = 600,250,get_canvas_width()/3 + 90,80 btn = Button(l,b,w,h,font, value, lambda: menuStart("menu_state")) gfw.world.add(gfw.layer.ui, btn)
def build_world(): gfw.world.init(['bg', 'ui']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('title.png', center) gfw.world.add(gfw.layer.bg, bg) font = gfw.font.load(gobj.res('Sam3KRFont.ttf'), 40) l, b, w, h = 500, 250, get_canvas_width() - 1000, 80 btn = Button(l, b, w, h, font, "Start", lambda: start()) gfw.world.add(gfw.layer.ui, btn) b -= 100 btn = Button(l, b, w, h, font, "Option", lambda: option()) gfw.world.add(gfw.layer.ui, btn) sound.init() sound.bgm_title.repeat_play()
def update(): global lose_image, win_image, TIME, Ehp count = 0 center = (320, 640) Ehp = enemy.life global aa, skilefx, skilefy, ene if Ehp <= 0: gfw.world.add(gfw.layer.state, gobj.ImageObject(theme + '/win.png', (320, 800))) gfw.world.add(gfw.layer.ui, highscore) return gfw.world.update() if skil.active == True or pattern.active == True: aa += gfw.delta_time skilx = Skileffect(1, (skilefx, skilefy), theme) gfw.world.add(gfw.layer.card, skilx) gfw.world.remove(skilx) if aa >= 1.2: aa = 0 skilefx = 500 skil.active = 0 pattern.active = 0 pattern.skil = 0 skilefx = skilefx - aa * 7 else: skilefx = 500 aa = 0 if gfw.world.count_at(gfw.layer.card) > 0: if TIME <= 1: return else: TIME -= gfw.delta_time * 30 # print(gfw.world.count_at(gfw.layer.card), score, gfw.delta_time, gfw.frame_interval) if enemy.dead == 1: highscore.add(TIME)
def enter(): gfw.world.init(['bg', 'ui']) center = (canvas_width//2, canvas_height//2) bg = gobj.ImageObject('bg.png', center) gfw.world.add(gfw.layer.bg, bg) # Button(l, b, w, h, font, text, callback, btnClass=None): font = gfw.font.load(gobj.res('ENCR10B.TTF'), 40) l,b,w,h = 50,350,get_canvas_width()-100,80 btn = Button(l,b,w,h,font,"Play Card Version", lambda: print("Card")) gfw.world.add(gfw.layer.ui, btn) b -= 120 btn = Button(l,b,w,h,font,"Play Twice Version", lambda: print("Twice")) gfw.world.add(gfw.layer.ui, btn)
def build_world(): gfw.world.init(['bg', 'ui', 'player']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('character.png', center) gfw.world.add(gfw.layer.bg, bg) global font font = gfw.font.load(gobj.res('CookieRun.TTF'), 30) l, b, w, h = 650, 50, 200, 80 btn = Button(l, b, w, h, font, "로비", lambda: gfw.change(lobby_state)) gfw.world.add(gfw.layer.ui, btn) global player player = Player() gfw.world.add(gfw.layer.player, player)
def build_world(): gfw.world.init(['mainmenu_bg', 'ui']) center = get_canvas_width() // 2, get_canvas_height() // 2 mainmenu_bg = gobj.ImageObject('main_menu.png', center) gfw.world.add(gfw.layer.mainmenu_bg, mainmenu_bg) font = gfw.font.load(gobj.res('StarcraftNormal.ttf'), 40) l, b, w, h = 25, 100, get_canvas_width() - 550, 80 btn = Button(l, b, w, h, font, "Start", lambda: start("ingame")) gfw.world.add(gfw.layer.ui, btn) l += 250 btn = Button(l, b, w, h, font, "Ranking", lambda: start("ranking")) gfw.world.add(gfw.layer.ui, btn) l += 250 btn = Button(l, b, w, h, font, "Quit", lambda: start("quit")) gfw.world.add(gfw.layer.ui, btn)
def build_world(): gfw.world.init(['bg', 'ui']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('bg.png', center) gfw.world.add(gfw.layer.bg, bg) # Button(l, b, w, h, font, text, callback, btnClass=None): font = gfw.font.load(gobj.res('ENCR10B.TTF'), 40) l, b, w, h = 50, 350, get_canvas_width() - 100, 80 btn = Button(l, b, w, h, font, "LV1", lambda: start("lv1")) gfw.world.add(gfw.layer.ui, btn) b -= 120 btn = Button(l, b, w, h, font, "LV2", lambda: start("lv2")) gfw.world.add(gfw.layer.ui, btn)
def build_world(): gfw.world.init(['ingame_bg','ingame_ui']) center = get_canvas_width()//2, get_canvas_height()//2 global font font = gfw.font.load(gobj.res('StarcraftNormal.ttf'), 40) gfw.world.add(gfw.layer.ingame_bg, gobj.ImageObject(theme + '/tile_map.png', center)) l,b,w,h = 25,550,get_canvas_width()-550,50 btn = Button(l,b,w,h,font,"poker",lambda: start("poker")) gfw.world.add(gfw.layer.ingame_ui, btn) l+=250 btn = Button(l,b,w,h,font,"Ranking",lambda: play()) gfw.world.add(gfw.layer.ingame_ui, btn) l+=250 btn = Button(l,b,w,h,font,"option",lambda: play()) gfw.world.add(gfw.layer.ingame_ui, btn) b =0 btn = Button(l,b,w,h,font,"play",lambda:play() ) gfw.world.add(gfw.layer.ingame_ui, btn)
def build_world(): gfw.world.init(['bg', 'ui', 'player']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('lobby.png', center) gfw.world.add(gfw.layer.bg, bg) font = gfw.font.load(gobj.res('CookieRun.TTF'), 30) l, b, w, h = 700, 150, 200, 80 btn = Button(l, b, w, h, font, "게임 시작", lambda: gfw.change(game_state)) gfw.world.add(gfw.layer.ui, btn) b -= 100 btn = Button(l, b, w, h, font, "쿠키 선택", lambda: gfw.change(cookie_state)) gfw.world.add(gfw.layer.ui, btn) global player player = Player() gfw.world.add(gfw.layer.player, player)
def enter(): gfw.world.init(['bg', 'ui']) center = (canvas_width // 2, canvas_height // 2) bg = gobj.ImageObject('option.png', center) gfw.world.add(gfw.layer.bg, bg) global font font = gfw.font.load(gobj.res('Sam3KRFont.ttf'), 40) global font2 font = gfw.font.load(gobj.res('Sam3KRFont.ttf'), 35) global l, b, w, h l, b, w, h = 500, 350, 80, 80 btn = Button(l, b, w, h, font, "<", lambda: bgm_volume_down()) gfw.world.add(gfw.layer.ui, btn) l = 700 btn = Button(l, b, w, h, font, ">", lambda: bgm_volume_up()) gfw.world.add(gfw.layer.ui, btn) b -= 150 l = 500 btn = Button(l, b, w, h, font, "<", lambda: se_volume_down()) gfw.world.add(gfw.layer.ui, btn) l = 700 btn = Button(l, b, w, h, font, ">", lambda: se_volume_up()) gfw.world.add(gfw.layer.ui, btn) b -= 150 l = 500 btn = Button(l, b, w, h, font, "<", lambda: difficulty_down()) gfw.world.add(gfw.layer.ui, btn) l = 700 btn = Button(l, b, w, h, font, ">", lambda: difficulty_up()) gfw.world.add(gfw.layer.ui, btn) l = 950 w = 300 btn = Button(l, b, w, h, font, "Back to Title", lambda: back_to_title()) gfw.world.add(gfw.layer.ui, btn)
def enter(): gfw.world.init(['bg', 'note', 'ui']) gfw.world.add(gfw.layer.bg, gobj.ImageObject( '/Select_Bg.png', (get_canvas_width()//2, get_canvas_height()//2))) # --- Font global font font = gfw.font.load(gobj.res('ENCR10B.TTF'), 20) # --- BGM global bgm bgm = load_music(gobj.res('Bgm_Main.mp3')) bgm.repeat_play() # --- 음악 초기화 set_music_count() # --- 버튼 생성 # -- 페이지 이동 버튼 생성 l, b, w, h = gobj.canvas_width/2 - 160*0.5 - \ 400, gobj.canvas_height/2 - 100, 154, 160 btn = Button(l, b, w, h, font, '', lambda: page_left()) btn.normalBg = ('Left', 'Normal') btn.hoverBg = ('Left', 'Normal') btn.pressedBg = ('Left', 'Normal') btn.update_Img() gfw.world.add(gfw.layer.ui, btn) l += 800 btn = Button(l, b, w, h, font, '', lambda: None) btn.normalBg = ('Right', 'Normal') btn.hoverBg = ('Right', 'Normal') btn.pressedBg = ('Right', 'Normal') btn.update_Img() gfw.world.add(gfw.layer.ui, btn) set_page() pass
def __init__(self, index, pos, theme='.'): self.image = gobj.ImageObject(theme + '/skil1.png', pos) if pattern.skil == 9: self.image = gobj.ImageObject(theme + '/9.png', pos) elif pattern.skil == 3: self.image = gobj.ImageObject(theme + '/3.png', pos) elif pattern.skil == 2: self.image = gobj.ImageObject(theme + '/2.png', pos) elif pattern.skil == 5: self.image = gobj.ImageObject(theme + '/5.png', pos) else: self.image = gobj.ImageObject(theme + '/skil1.png', pos) fps = random.randrange(20, 30) self.index = index
def __init__(self, index, pos, theme='.'): self.bg = gobj.ImageObject(theme + '/skilicon1.png', pos) fps = random.randrange(20, 30) self.fg = gobj.ImageObject(theme + '/skilicon2.png', pos) self.image = self.bg self.index = index