๐Ÿ“• [ TIL ] : 8์ผ์ฐจ_2022.04.27.(์ˆ˜) - ๋‘ ๋ฒˆ์งธ ํ”„๋กœ์ ํŠธ ์™„์„ฑ

๊น€๋ฐฅยท2022๋…„ 4์›” 27์ผ
3
post-thumbnail

20220427(WED)_TODAY TIL

TODAY PROJECT

- ํŒŒ์ด์ฌ์œผ๋กœ ๊ฒŒ์ž„ ๋งŒ๋“ค๊ธฐ(๊ฐœ์ธํ”„๋กœ์ ํŠธ) ์™„๋ฃŒ! : 'Juke Dino'

๊ฐœ๋ฐœํ™˜๊ฒฝ

VSCode, Python 3.x

์‚ฌ์šฉํ•œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

pygame, os, sys, datetime

โœ๏ธ REMIND : PROJECT .๋งŒ๋“ค๊ฒŒ ๋œ ๊ณ„๊ธฐ

  • ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๊ฐ€ ์‹ฌ์‹ฌํ•ด์งˆ๋•Œ ํ˜น์€ ์กฐ๊ธˆ ํœด์‹์ด ํ•„์š”ํ•  ๋•Œ ํ‰ํ™”๋กœ์šด ์Œ์•…์„ ์ž๋™์œผ๋กœ ํ‹€์–ด์ฃผ๊ณ  ๋™๋ฌผ์„ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๊ฒŒ์ž„์„ ์ œ์ž‘ํ•ด๋ณด๊ณ  ์‹ถ์—ˆ๋‹ค.
  • ๋งˆ์น˜ ๋™๋ฌผ์˜ ์ˆฒ, ์ฟ ํ‚ค๋Ÿฐ ํ‚น๋ค, ์Šคํƒ€๋“€๋ฐธ๋ฆฌ์™€ ๊ฐ™์€ ํ‰ํ™”๋กœ์šด ๋งˆ์„ ๊ฒŒ์ž„์„ ๋งŒ๋“ค์–ด๋ณด๊ณ  ์‹ถ์—ˆ๋‹ค.
  • ๊ทธ๋ž˜์„œ ๋‹ค์–‘ํ•œ ์Œ์•…๊ณผ ํ”ฝ์…€ ๋™๋ฌผ ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ์–ด์„œ ์ œ์ž‘ํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.
  • ์œ ๋ช…ํ•œ ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € ๊ณต๋ฃก๊ฒŒ์ž„(์ธํ„ฐ๋„ท ์ ‘์†์ด ๋Š๊ธฐ๋ฉด ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ €์—์„œ ๋“ฑ์žฅํ•˜๋Š” ๊ณต๋ฃก๊ฒŒ์ž„)์ธ ํฌ๋กฌ ๋ธŒ๋ผ์šฐ์ € ๊ฒŒ์ž„(Dino T-Rex)์—์„œ ์˜๊ฐ์„ ๋ฐ›์•„์„œ ์ด ๊ณต๋ฃก ์บ๋ฆญํ„ฐ๋ฅผ ์ฐจ์šฉํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค.

โœ๏ธ REMIND : PROJECT .๋ฌด์Šจ ๊ฒŒ์ž„์ธ๊ฐ€์š”?

  • ๊ณต๋ฃก์ด ์ž์œ ๋กญ๊ฒŒ ๋Œ์•„๋‹ค๋‹ˆ๋ฉด์„œ ์ฃผํฌ๋ฐ•์Šค๋ฅผ ์žฌ์ƒํ•˜๋Š” ๊ฒŒ์ž„์ž…๋‹ˆ๋‹ค. (์ž์œ ๋„ โญ๏ธโญ๏ธโญ๏ธโญ๏ธโญ๏ธ)
  • ๋‹ค๋ฅด๊ฒŒ ํ‘œํ˜„ํ•˜๋ฉด, pygame ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ๋งŒ๋“  ์Œ์•… ์žฌ์ƒ ํ”Œ๋ ˆ์ด์–ด๋ผ๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํŠน์ง•์ด๋ผ๋ฉด ๊ท€์—ฌ์šด ๋™๋ฌผ์— ๋‹ค๊ฐ€๊ฐ”์„๋•Œ ๋…ธ๋ž˜์— ๊ด€ํ•œ ํ•œ ์ค„ ์„ค๋ช…์ด ๋„์›Œ์ง€๊ณ  ์Œ์•…์ด ์žฌ์ƒ๋ฉ๋‹ˆ๋‹ค.
    (์ด๋•Œ ์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ์— ์žฌ์ƒํ•˜๊ณ  ์žˆ๋Š” ์Œ์•…์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋ฐ”๋€๋‹ˆ๋‹ค!)
  • ์™ผ์ชฝ ์ƒ๋‹จ์—๋Š” ์‹คํ–‰ ์‹œ๋งˆ๋‹ค ์—…๋ฐ์ดํŠธ ๋˜๋Š” ๋ถ€๋ถ„์œผ๋กœ ๋‚ ์งœ์™€ ์ด ์ ‘์† ์‹œ๊ฐ„์„ ๋ถ„๋‹จ์œ„๋กœ ์•Œ๋ ค์ฃผ๋Š” ํƒ€์ด๋จธ ๊ธฐ๋Šฅ์„ ๋„ฃ์—ˆ์Šต๋‹ˆ๋‹ค. (๊ฒŒ์ž„ ๋Ÿฌ๋‹ํƒ€์ž„) ์ด๋ฅผ ํ•„์š”์— ๋”ฐ๋ผ ๊ณต๋ถ€์‹œ๊ฐ„์„ ์žฌ๋Š” ์šฉ๋„๋กœ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    (๊ฒŒ์ž„ ๋‚ด์˜ ๊ณ ์–‘์ด, ๊ฐ•์•„์ง€๊ฐ€ ๊ณต๋ถ€์‹œ๊ฐ„์˜ ์ง€๋ฃจํ•จ์„ ๋œ์–ด์ค„ ๋ฟ ์•„๋‹ˆ๋ผ ๊ณต๋ถ€์‹œ๊ฐ„์ด ์žฌ๋ฏธ์žˆ์–ด์ง€๊ฒŒ ํ•˜๋Š” ์šฉ๋„์ž…๋‹ˆ๋‹ค.)

โœ๏ธ REMIND : PROJECT .์ถ”๊ฐ€ ์„ค๋ช…

  • ํ™”๋ฉด์„ ๊ธฐ์ค€์œผ๋กœ 3๋ถ„ํ•  ํ•˜์—ฌ ์ œ์ผ ์™ผ์ชฝ์€ ์•„์นจ์— ๋“ฃ๋Š” ์Œ์•…, ๊ฐ€์šด๋ฐ๋Š” ์ ์‹ฌ์— ๋“ฃ๋Š” ์Œ์•…, ์˜ค๋ฅธํŽธ์—๋Š” ์ €๋…์— ๋“ฃ๋Š” ์Œ์•…์„ ๋„ฃ์–ด๋†“์•˜์Šต๋‹ˆ๋‹ค. (๋งˆ์น˜ ์‹œ๊ฐ„์ด ํ๋ฅด๋Š” ๊ฒƒ ๊ฐ™์ด)
  • ์ด๋ฏธ์ง€ ์†Œ์ŠคํŒŒ์ผ์€ ๋„ฃ์–ด๋†“์ง€ ์•Š์•˜์ง€๋งŒ ์ข€ ๋” ๊ฒŒ์ž„๊ฐ™์€ ํ™”๋ฉด ๊ตฌ์„ฑ์„ ์œ„ํ•ด ์ถ”ํ›„ ๊ฒŒ์ž„ ์—…๋ฐ์ดํŠธ์‹œ ์ด ๋ถ€๋ถ„๋„ ๊ณ ๋ คํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.

- ์ธํŠธ๋กœ ํ™”๋ฉด(๊ธฐ๋Šฅ ์‹œ์—ฐ)


๊ณต๋ฃก์ด ์ธํŠธ๋กœํ™”๋ฉด์—์„œ๋„ ์›€์ง์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!(๋ฐฉํ–ฅํ‚ค ์‚ฌ์šฉ)
[SPACE] ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋ฉ”์ธ ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•ฉ๋‹ˆ๋‹ค!(์ด๋™์‹œ Please Wait ๋ฌธ๊ตฌ ๋„์›€)

- ๋ฉ”์ธ ํ™”๋ฉด(๊ธฐ๋Šฅ ์‹œ์—ฐ)


์ฐฝ ํ™•๋Œ€, ์ถ•์†Œ๊ฐ€ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค! (F1์œผ๋กœ ํ™•๋Œ€, F2๋กœ ์ถ•์†Œ)
๊ณต๋ฃก์ด ๋ฌผ์ฒด์— ๋‹ฟ์œผ๋ฉด ์Œ์•…์— ๋Œ€ํ•œ ์„ค๋ช…์ด ๋‚˜์˜ค๋ฉด์„œ ์Œ์•…์ด ์žฌ์ƒ๋ฉ๋‹ˆ๋‹ค! (์˜ค๋ฅธ์ชฝ ์ƒ๋‹จ ๋‚˜์˜ค๋Š” ์Œ์•…์ด ํ‘œ์‹œ๋จ, ๋‹ค๋ฅธ ์ฅฌํฌ๋ฐ•์Šค์— ๋‹ฟ์œผ๋ฉด ๊ธฐ์กด ์žฌ์ƒํ•˜๋˜ ์Œ์•… ์ข…๋ฃŒ ํ›„ ์ƒˆ๋กœ์šด ์Œ์•… ์žฌ์ƒ๋จ)
[SPACE] ํ‚ค ๋ˆ„๋ฅผ ์‹œ ์Œ์•… ์ข…๋ฃŒ๋จ
[ESC] ํ‚ค ๋ˆ„๋ฅผ ์‹œ '์ข…๋ฃŒํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?' ํ™”๋ฉด์— ์ถœ๋ ฅ

์ œ์ž‘ ์ˆœ์„œ ๋ฐ ์ฝ”๋“œ ์ฒจ๋ถ€

์ธํŠธ๋กœ ํ™”๋ฉด(๊ณต๋ฃก ์›€์ง์ž„ ๊ตฌํ˜„) -> ๋ฉ”์ธ ํ™”๋ฉด ์ œ์ž‘ ๋ฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€(ํ‚ค ์„ค์ •, ํƒ€์ด๋จธ ๋ฐ ์‹œ๊ฐ„๊ธฐ๋Šฅ ์ถ”๊ฐ€, ๊ธ€์”จ ๋„์šฐ๊ธฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€, ์ถฉ๋Œ์ฒ˜๋ฆฌ, ์ฐฝ ํ™•๋Œ€์ถ•์†Œ ๊ธฐ๋Šฅ ์ถ”๊ฐ€, ์Œ์•…์„ค์ •) -> ์ธํŠธ๋กœํ™”๋ฉด๊ณผ ๋ฉ”์ธํ™”๋ฉด ์—ฐ๊ฒฐ -> ํ…Œ์ŠคํŠธ -> ์ด๋ฏธ์ง€ ํŒŒ์ผ ์ž…ํžˆ๊ธฐ

import os
import pygame
import sys
from pygame import *
from datetime import datetime

current_path = os.path.dirname(__file__)  # ํ˜„์žฌ ํŒŒ์ผ์˜ ์œ„์น˜ ๋ฐ˜ํ™˜
image_path = os.path.join(current_path, "images")  # images ํด๋” ์œ„์น˜ ๋ฐ˜ํ™˜
music_path = os.path.join(current_path, "music")  # music ํด๋” ์œ„์น˜ ๋ฐ˜ํ™˜

# ๋ฐฐ๊ฒฝ ์ด๋ฏธ์ง€ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
background = pygame.image.load(
    os.path.join(image_path, "white.png"))

# ์บ๋ฆญํ„ฐ(์Šคํ”„๋ผ์ดํŠธ) ๋ถˆ๋Ÿฌ์˜ค๊ธฐ
character = pygame.image.load(
    os.path.join(image_path, "dino1.png"))

# ์†Œ๋ฆฌ์ดˆ๊ธฐํ™”
se_afternoon = None
se_bug = None
se_button = None
se_chill = None
se_clear = None
se_coin = None
se_fire = None
se_loading = None
se_morning = None
se_night = None
se_npc = None
se_opening = None
se_quest = None
se_sleep = None
se_sunny = None
se_woman = None


def play():
    # ์†Œ๋ฆฌ๋ฐ์ดํ„ฐ
    global se_afternoon, se_coin, se_morning, se_, se_night, se_sleep, se_chill, se_npc, se_clear, se_loading, se_fire, se_bug, se_opening, se_quest, se_sunny, se_button, se_woman
    # ์ดˆ๊ธฐํ™”

    pygame.init()
    # ํ™”๋ฉด ํƒ€์ดํ‹€ ์„ค์ •
    pygame.display.set_caption("Juke Dino")  # ๊ฒŒ์ž„ ์ด๋ฆ„

    # Font ์ •์˜
    game_font = pygame.font.Font(None, 35)
    game_result_1 = "Good Afternoon"
    game_result_2 = "There are swarm of fireflies"
    game_result_3 = "Stay Chill Hear"
    game_result_4 = "Hello, Here is office"
    game_result_5 = "I gathered some wood"
    game_result_6 = "Good Morning"
    game_result_7 = "Good Night"
    game_result_8 = "Hello, I'm Bob"
    game_result_9 = "This is opening song"
    game_result_10 = "This is quest"
    game_result_11 = "Time to Sleep"
    game_result_12 = "Sunny Day"
    sound_off = "Sound OFF"
    want_quit = "Do you Want Quit?"
    song_msg = "None"
    # ๋‚ ์งœ ์ถœ๋ ฅ
    now = datetime.now()
    game_now = "Today Date : "+str(now.year)+"."+str(now.month)+"."+str(now.day) + \
        "."

    # ํ™”๋ฉด ํฌ๊ธฐ ์„ค์ •
    screen_width = 840  # ๊ฐ€๋กœ ํฌ๊ธฐ
    screen_height = 600  # ์„ธ๋กœ ํฌ๊ธฐ
    screen = pygame.display.set_mode((screen_width, screen_height))
    # FPS
    clock = pygame.time.Clock()
    # ์†Œ๋ฆฌ
    se_afternoon = pygame.mixer.Sound(
        os.path.join(music_path, "afternoon.mp3"))
    se_bug = pygame.mixer.Sound(
        os.path.join(music_path, "bug.mp3"))
    se_button = pygame.mixer.Sound(
        os.path.join(music_path, "button.mp3"))
    se_chill = pygame.mixer.Sound(
        os.path.join(music_path, "chill.mp3"))
    se_clear = pygame.mixer.Sound(
        os.path.join(music_path, "clear.mp3"))
    se_coin = pygame.mixer.Sound(
        os.path.join(music_path, "coin.mp3"))
    se_fire = pygame.mixer.Sound(
        os.path.join(music_path, "fire.mp3"))
    se_loading = pygame.mixer.Sound(
        os.path.join(music_path, "loading.mp3"))
    se_morning = pygame.mixer.Sound(
        os.path.join(music_path, "morning.mp3"))
    se_night = pygame.mixer.Sound(
        os.path.join(music_path, "night.mp3"))
    se_npc = pygame.mixer.Sound(
        os.path.join(music_path, "npc.mp3"))
    se_opening = pygame.mixer.Sound(
        os.path.join(music_path, "opening.mp3"))
    se_quest = pygame.mixer.Sound(
        os.path.join(music_path, "quest.mp3"))
    se_sleep = pygame.mixer.Sound(
        os.path.join(music_path, "sleep.mp3"))
    se_sunny = pygame.mixer.Sound(
        os.path.join(music_path, "sunny.mp3"))
    se_woman = pygame.mixer.Sound(
        os.path.join(music_path, "woman.mp3"))

    se_clear.play()

    character_size = character.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    character_width = character_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐ
    character_height = character_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    character_x_pos = (screen_width / 2) - (character_width /
                                            2)  # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    character_y_pos = screen_height - character_height

    # ์บ๋ฆญํ„ฐ๊ฐ€ ์ด๋™ํ•  ์ขŒํ‘œ
    to_x = 0
    to_y = 0

    # ์บ๋ฆญํ„ฐ ์ด๋™ ์†๋„
    character_speed = 0.13

    # afternoon ์บ๋ฆญํ„ฐ
    afternoon = pygame.image.load(
        os.path.join(image_path, "1.png"))
    afternoon_size = afternoon.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    afternoon_width = afternoon_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    afternoon_height = afternoon_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ์™ผ์ชฝ ์ƒ๋‹จ
    afternoon_x_pos = 300
    afternoon_y_pos = 100

    # bug ์บ๋ฆญํ„ฐ
    bug = pygame.image.load(
        os.path.join(image_path, "2.png"))
    bug_size = bug.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    bug_width = bug_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    bug_height = bug_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    bug_x_pos = 540
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    bug_y_pos = 100

    # chill ์บ๋ฆญํ„ฐ
    chill = pygame.image.load(
        os.path.join(image_path, "3.png"))
    chill_size = chill.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    chill_width = chill_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    chill_height = chill_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    chill_x_pos = 420
    chill_y_pos = 200

    # clear ์บ๋ฆญํ„ฐ
    clear = pygame.image.load(
        os.path.join(image_path, "4.png"))
    clear_size = clear.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    clear_width = clear_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    clear_height = clear_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    clear_x_pos = 60
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    clear_y_pos = 400

    # fire ์บ๋ฆญํ„ฐ
    fire = pygame.image.load(
        os.path.join(image_path, "5.png"))
    fire_size = fire.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    fire_width = fire_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    fire_height = fire_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    fire_x_pos = 720
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    fire_y_pos = 100

    # morning ์บ๋ฆญํ„ฐ
    morning = pygame.image.load(
        os.path.join(image_path, "6.png"))
    morning_size = morning.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    morning_width = morning_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    morning_height = morning_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    morning_x_pos = 180
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    morning_y_pos = 200

    # night ์บ๋ฆญํ„ฐ
    night = pygame.image.load(
        os.path.join(image_path, "7.png"))
    night_size = night.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    night_width = night_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    night_height = night_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    night_x_pos = 720
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    night_y_pos = 200
    # npc ์บ๋ฆญํ„ฐ
    npc = pygame.image.load(
        os.path.join(image_path, "8.png"))
    npc_size = npc.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    npc_width = npc_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    npc_height = npc_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    npc_x_pos = 400
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    npc_y_pos = 400

    # opening ์บ๋ฆญํ„ฐ
    opening = pygame.image.load(
        os.path.join(image_path, "9.png"))
    opening_size = opening.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    opening_width = opening_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    opening_height = opening_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    opening_x_pos = 240
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    opening_y_pos = 400

    # quest ์บ๋ฆญํ„ฐ
    quest = pygame.image.load(
        os.path.join(image_path, "10.png"))
    quest_size = quest.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    quest_width = quest_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    quest_height = quest_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    quest_x_pos = 540
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    quest_y_pos = 400

    # sleep ์บ๋ฆญํ„ฐ
    sleep = pygame.image.load(
        os.path.join(image_path, "11.png"))
    sleep_size = sleep.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    sleep_width = sleep_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    sleep_height = sleep_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    sleep_x_pos = 720
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    sleep_y_pos = 400

    # sunny ์บ๋ฆญํ„ฐ
    sunny = pygame.image.load(
        os.path.join(image_path, "12.png"))
    sunny_size = sunny.get_rect().size  # ์ด๋ฏธ์ง€์˜ ํฌ๊ธฐ๋ฅผ ๊ตฌํ•ด์˜ด
    sunny_width = sunny_size[0]  # ์บ๋ฆญํ„ฐ์˜ ๊ฐ€๋กœ ํฌ๊ธฐx
    sunny_height = sunny_size[1]  # ์บ๋ฆญํ„ฐ์˜ ์„ธ๋กœ ํฌ๊ธฐ
    # ํ™”๋ฉด ๊ฐ€๋กœ์˜ ์ ˆ๋ฐ˜ ํฌ๊ธฐ์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (๊ฐ€๋กœ)
    sunny_x_pos = 60
    # ํ™”๋ฉด ์„ธ๋กœ ํฌ๊ธฐ ๊ฐ€์žฅ ์•„๋ž˜์— ํ•ด๋‹นํ•˜๋Š” ๊ณณ์— ์œ„์น˜ (์„ธ๋กœ)
    sunny_y_pos = 100

    # ์ด๋ฒคํŠธ ๋ฃจํ”„
    # ๊ฒŒ์ž„์ด ์ง„ํ–‰์ค‘์ธ๊ฐ€?
    running = True
    while running:
        dt = clock.tick(60)  # ๊ฒŒ์ž„ํ™”๋ฉด์˜ ์ดˆ๋‹น ํ”„๋ ˆ์ž„ ์ˆ˜๋ฅผ ์„ค์ •

        for event in pygame.event.get():  # ์–ด๋–ค ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋Š”๊ฐ€?
            if event.type == pygame.QUIT:  # ์ฐฝ์ด ๋‹ซํžˆ๋Š” ์ด๋ฒคํŠธ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋Š”๊ฐ€?
                pygame.quit()
                sys.exit()

            if event.type == pygame.KEYDOWN:  # ํ‚ค๊ฐ€ ๋ˆŒ๋Ÿฌ์กŒ๋Š”์ง€ ํ™•์ธ
                if event.key == pygame.K_LEFT:  # ์บ๋ฆญํ„ฐ๋ฅผ ์™ผ์ชฝ์œผ๋กœ
                    to_x -= character_speed  # to_x = to_x - 5
                elif event.key == pygame.K_RIGHT:  # ์บ๋ฆญํ„ฐ๋ฅผ ์˜ค๋ฅธ์ชฝ์œผ๋กœ
                    to_x += character_speed
                elif event.key == pygame.K_UP:  # ์บ๋ฆญํ„ฐ๋ฅผ ์œ„๋กœ
                    to_y -= character_speed
                elif event.key == pygame.K_DOWN:  # ์บ๋ฆญํ„ฐ๋ฅผ ์•„๋ž˜๋กœ
                    to_y += character_speed
                elif event.key == K_F1:  # F1ํ‚ค ๋ˆ„๋ฅด๋ฉด ์ฐฝํ™•๋Œ€
                    screen = pygame.display.set_mode(
                        (screen_width, screen_height), FULLSCREEN)
                elif event.key == K_F2:  # F2ํ‚ค ๋ˆ„๋ฅด๋ฉด ์ฐฝ ์ถ•์†Œ
                    screen = pygame.display.set_mode(
                        (screen_width, screen_height))
                elif event.key == pygame.K_SPACE:  # space ๋ˆ„๋ฅด๋ฉด ๋ชจ๋“  ์Œ์•… ๋ฉˆ์ถค
                    song_off()
                    msg = game_font.render(
                        sound_off, True, (0, 0, 0))
                    msg_rect = msg.get_rect(
                        center=(int(screen_width / 2), int(screen_height / 2)))
                    screen.blit(msg, msg_rect)
                    pygame.display.update()
                    pygame.time.delay(500)
                    song_msg = "None"

                elif event.key == pygame.K_ESCAPE:  # ESC๋ˆ„๋ฅด๋ฉด ์•„๋ฌด๊ฒƒ๋„ ๋™์ž‘ ์•ˆํ•จ
                    msg = game_font.render(
                        want_quit, True, (0, 0, 0))
                    msg_rect = msg.get_rect(
                        center=(int(screen_width / 2), int(screen_height / 2)))
                    screen.blit(msg, msg_rect)
                    pygame.display.update()
                    pygame.time.delay(1000)
                    # if event.type == pygame.KEYDOWN:  # ๋ฐฉํ–ฅํ‚ค๋ฅผ ๋–ผ๋ฉด ์ฃผ์ธ๊ณต ์บ๋ฆญํ„ฐ ๋ฉˆ์ถค
                    #     if event.key == pygame.K_a:
                    #         running = False
                    #     elif event.key == pygame.K_n:
                    #         running = True

            if event.type == pygame.KEYUP:  # ๋ฐฉํ–ฅํ‚ค๋ฅผ ๋–ผ๋ฉด ์ฃผ์ธ๊ณต ์บ๋ฆญํ„ฐ ๋ฉˆ์ถค
                if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                    to_x = 0
                elif event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                    to_y = 0

        character_x_pos += to_x * dt
        character_y_pos += to_y * dt

        # ๊ฐ€๋กœ ๊ฒฝ๊ณ„๊ฐ’ ์ฒ˜๋ฆฌ
        if character_x_pos < 0:
            character_x_pos = 0
        elif character_x_pos > screen_width - character_width:
            character_x_pos = screen_width - character_width

        # ์„ธ๋กœ ๊ฒฝ๊ณ„๊ฐ’ ์ฒ˜๋ฆฌ
        if character_y_pos < 0:
            character_y_pos = 0
        elif character_y_pos > screen_height - character_height:
            character_y_pos = screen_height - character_height

        # ์ถฉ๋Œ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ rect ์ •๋ณด ์—…๋ฐ์ดํŠธ
        character_rect = character.get_rect()
        character_rect.left = character_x_pos
        character_rect.top = character_y_pos

        afternoon_rect = afternoon.get_rect()
        afternoon_rect.left = afternoon_x_pos
        afternoon_rect.top = afternoon_y_pos

        bug_rect = bug.get_rect()
        bug_rect.left = bug_x_pos
        bug_rect.top = bug_y_pos

        chill_rect = chill.get_rect()
        chill_rect.left = chill_x_pos
        chill_rect.top = chill_y_pos

        clear_rect = clear.get_rect()
        clear_rect.left = clear_x_pos
        clear_rect.top = clear_y_pos

        fire_rect = fire.get_rect()
        fire_rect.left = fire_x_pos
        fire_rect.top = fire_y_pos

        morning_rect = morning.get_rect()
        morning_rect.left = morning_x_pos
        morning_rect.top = morning_y_pos

        night_rect = night.get_rect()
        night_rect.left = night_x_pos
        night_rect.top = night_y_pos

        npc_rect = npc.get_rect()
        npc_rect.left = npc_x_pos
        npc_rect.top = npc_y_pos

        opening_rect = opening.get_rect()
        opening_rect.left = opening_x_pos
        opening_rect.top = opening_y_pos

        quest_rect = quest.get_rect()
        quest_rect.left = quest_x_pos
        quest_rect.top = quest_y_pos

        sleep_rect = sleep.get_rect()
        sleep_rect.left = sleep_x_pos
        sleep_rect.top = sleep_y_pos

        sunny_rect = sunny.get_rect()
        sunny_rect.left = sunny_x_pos
        sunny_rect.top = sunny_y_pos

        # afternoon ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(afternoon_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = afternoon_y_pos+afternoon_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_afternoon.play()
            se_coin.play()
            msg = game_font.render(
                game_result_1, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Afternoon"

        # bug ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(bug_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = bug_y_pos+bug_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_bug.play()
            se_coin.play()
            msg = game_font.render(
                game_result_2, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Bug"

        # chill ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(chill_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = chill_y_pos+chill_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_chill.play()
            se_coin.play()
            msg = game_font.render(
                game_result_3, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Chill"

        # clear ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(clear_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = clear_y_pos+clear_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_clear.play()
            se_coin.play()
            msg = game_font.render(
                game_result_4, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Clear"

        # fire ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(fire_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = fire_y_pos+fire_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_fire.play()
            se_coin.play()
            msg = game_font.render(
                game_result_5, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Fire"

        # morning ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(morning_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = morning_y_pos+morning_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_morning.play()
            se_coin.play()
            msg = game_font.render(
                game_result_6, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Morning"

        # night ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(night_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = night_y_pos+night_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_night.play()
            se_coin.play()
            msg = game_font.render(
                game_result_7, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Night"

        # npc ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(npc_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = npc_y_pos+npc_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_npc.play()
            se_coin.play()
            msg = game_font.render(
                game_result_8, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "NPC"

        # opening ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(opening_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = opening_y_pos+opening_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_opening.play()
            se_coin.play()
            msg = game_font.render(
                game_result_9, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Opening"

        # quest ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(quest_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = quest_y_pos+quest_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_quest.play()
            se_coin.play()
            msg = game_font.render(
                game_result_10, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Quest"

        # sleep ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(sleep_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = sleep_y_pos+sleep_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_sleep.play()
            se_coin.play()
            msg = game_font.render(
                game_result_11, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Sleep"

        # sunny ์ถฉ๋Œ ์ฒดํฌ
        if character_rect.colliderect(sunny_rect):
            print("์ถฉ๋Œํ–ˆ์–ด์š”")
            character_y_pos = sunny_y_pos+sunny_height
            # ์ถฉ๋Œ์‹œ ์‚ฌ์šด๋“œ
            song_off()
            se_sunny.play()
            se_coin.play()
            msg = game_font.render(
                game_result_12, True, (0, 0, 0))
            msg_rect = msg.get_rect(
                center=(int(screen_width / 2), int(screen_height / 2)))
            screen.blit(msg, msg_rect)
            pygame.display.update()
            pygame.time.delay(500)
            song_msg = "Sunny"

        screen.blit(background, (0, 0))  # ๋ฐฐ๊ฒฝ ๊ทธ๋ฆฌ๊ธฐ
        # ์ฃผ์ธ๊ณต์บ๋ฆญํ„ฐ ๊ทธ๋ฆฌ๊ธฐ
        screen.blit(character, (character_x_pos, character_y_pos))
        # ๋‹ค๋ฅธ ์บ๋ฆญํ„ฐ ๊ทธ๋ฆฌ๊ธฐ
        screen.blit(afternoon, (afternoon_x_pos, afternoon_y_pos))
        screen.blit(bug, (bug_x_pos, bug_y_pos))
        screen.blit(chill, (chill_x_pos, chill_y_pos))
        screen.blit(clear, (clear_x_pos, clear_y_pos))
        screen.blit(fire, (fire_x_pos, fire_y_pos))
        screen.blit(morning, (morning_x_pos, morning_y_pos))
        screen.blit(night, (night_x_pos, night_y_pos))
        screen.blit(npc, (npc_x_pos, npc_y_pos))
        screen.blit(opening, (opening_x_pos, opening_y_pos))
        screen.blit(quest, (quest_x_pos, quest_y_pos))
        screen.blit(sleep, (sleep_x_pos, sleep_y_pos))
        screen.blit(sunny, (sunny_x_pos, sunny_y_pos))

        # ํƒ€์ด๋จธ:๊ฒฝ๊ณผ์‹œ๊ฐ„ ๊ณ„์‚ฐ (์˜ค๋ฒ„์‹œ๊ฐ„- ๊ฒŒ์ž„์‹œ์ž‘์‹œ๊ฐ„=0=๊ฒŒ์ž„์ข…๋ฃŒ)
        sec = int(pygame.time.get_ticks()/1000)
        timer = game_font.render("Playtime : " +
                                 str(int(pygame.time.get_ticks()/1000/60))+"m", True, (0, 0, 0))  # ์ถœ๋ ฅํ•  ๊ธ€์ž, True, ๊ธ€์ž ์ƒ‰์ƒ
        screen.blit(timer, (10, 10))
        msg = game_font.render(
            game_now, True, (0, 0, 0))
        screen.blit(msg, (10, 40))

        msg_2 = game_font.render(
            'Play Now : '+song_msg, True, (0, 0, 0))
        screen.blit(msg_2, (540, 40))
        pygame.display.update()  # ๊ฒŒ์ž„ํ™”๋ฉด์„ ๋‹ค์‹œ ๊ทธ๋ฆฌ๊ธฐ!


def intro():
    global sec, se_opening

    pygame.init()
    screen_width = 840
    screen_height = 600
    screen = pygame.display.set_mode((screen_width, screen_height))
    pygame.display.set_caption('Juke Dino')
    game_font = pygame.font.Font(None, 35)
    background = pygame.image.load(
        os.path.join(image_path, "white.png"))
    character = pygame.image.load(
        os.path.join(image_path, "dino1.png"))
    character_size = character.get_rect().size
    character_width = character_size[0]
    character_height = character_size[1]
    character_x_pos = (screen_width/2-character_width/2)
    character_y_pos = (screen_height/2)

    se_opening = pygame.mixer.Sound(
        os.path.join(music_path, "opening.mp3"))
    se_opening.play()

    to_x = 0
    to_y = 0
    loading = "Pleas Wait ..."

    running = True
    while running:

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_LEFT:
                    to_x -= 2

                elif event.key == pygame.K_RIGHT:
                    to_x += 2
                elif event.key == pygame.K_UP:
                    to_y -= 2
                elif event.key == pygame.K_DOWN:
                    to_y += 2
                elif event.key == pygame.K_SPACE:
                    sec = 0
                    msg = game_font.render(
                        loading, True, (0, 0, 0))
                    msg_rect = msg.get_rect(
                        center=(int(screen_width / 2), 400))
                    screen.blit(msg, msg_rect)
                    pygame.display.update()
                    pygame.time.delay(500)
                    se_opening.stop()
                    play()

            if event.type == pygame.KEYUP:
                if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
                    to_x = 0
                elif event.key == pygame.K_UP or event.key == pygame.K_DOWN:
                    to_y = 0

        character_x_pos += to_x
        character_y_pos += to_y

        if character_x_pos < 0:
            character_x_pos = 0
        elif character_x_pos > screen_width-character_width:
            character_x_pos = screen_width-character_width

        if character_y_pos < 0:
            character_y_pos = 0
        elif character_y_pos > screen_height-character_height:
            character_y_pos = screen_height-character_height

        screen.blit(background, (0, 0))
        screen.blit(character, (character_x_pos, character_y_pos))
        msg = game_font.render(
            'Juke Dino', True, (0, 0, 0))
        msg_rect = msg.get_rect(
            center=(int(screen_width / 2), 200))
        screen.blit(msg,  msg_rect)
        msg = game_font.render(
            'Press [SPACE] to Start', True, (0, 0, 0))
        msg_rect = msg.get_rect(
            center=(int(screen_width / 2), 500))
        screen.blit(msg,  msg_rect)
        pygame.display.update()  # ๊ฒŒ์ž„ํ™”๋ฉด์„ ๋‹ค์‹œ ๊ทธ๋ฆฌ๊ธฐ!


def main():
    intro()


def song_off():
    global se_afternoon, se_coin, se_morning, se_, se_night, se_sleep, se_chill, se_npc, se_clear, se_loading, se_fire, se_bug, se_opening, se_quest, se_sunny, se_button, se_woman
    se_afternoon.stop()
    se_bug.stop()
    se_button.stop()
    se_chill.stop()
    se_clear.stop()
    se_coin.stop()
    se_fire.stop()
    se_loading.stop()
    se_morning.stop()
    se_night.stop()
    se_npc.stop()
    se_opening.stop()
    se_quest.stop()
    se_sleep.stop()
    se_sunny.stop()
    se_woman.stop()
    se_coin.play()


if __name__ == '__main__':
    main()

์‚ฌ์šฉํ•œ ์†Œ์Šค

๊ฐ•์•„์ง€ ์ด๋ฏธ์ง€
๊ณต๋ฃก ์ด๋ฏธ์ง€
๊ณ ์–‘์ด ์ด๋ฏธ์ง€
์†Œ๋ฆฌ 1
์†Œ๋ฆฌ 2

๐ŸŒพ ์ถ”ํ›„ ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •ํ•ด๋ณด๊ณ  ์‹ถ์€ ๊ฒƒ

ํŒŒ์ด๊ฒŒ์ž„์ด ์•„๋‹ˆ๋”๋ผ๋„ ์ถ”ํ›„ ๊ฒŒ์ž„์„ ๋‹ค๋ฅธ ํˆด๋กœ ์ œ์ž‘ํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด ์ด๋ ‡๊ฒŒ ๋ฐœ์ „์‹œ์ผœ ๋ณด๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค!

  • ์ฏ”๊พธ๋ฅด๊ฒŒ์ž„(์–ธ๋”ํ…Œ์ผ ๋“ฑ ์ŠคํŒ€๊ฒŒ์ž„)๊ฐ™์ด ํ€˜์ŠคํŠธ ๊ธฐ๋Šฅ ๋„ฃ๊ณ  ํ€˜์ŠคํŠธ ํ™•๋Œ€๋˜์–ด์„œ ๋ณด์ด๋Š” ๊ธฐ๋Šฅ
  • ๋งˆ์šฐ์Šค๋กœ ์บ๋ฆญํ„ฐ ์›€์ง์—ฌ๋ณด๊ธฐ, ๋ฒ„ํŠผ ํด๋ฆญํ•ด๋ณด๊ธฐ
  • ํ…์ŠคํŠธ ๊นœ๋ฐ•์ž„
  • ์บ๋ฆญํ„ฐ ์• ๋‹ˆ๋ฉ”์ด์…˜
  • ESC ๋ˆ„๋ฅผ์‹œ ์ข…๋ฃŒ yes or no ๋กœ ๋œจ๋Š”๊ฑฐ
  • SPACE ๋‘ ๋ฒˆ ๋ˆ„๋ฅผ ์‹œ ์Œ์•… ์ค‘์ง€, ๊ทธ๋ถ€๋ถ„์—์„œ ์žฌ์ƒ
  • ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง

๐ŸŒพ ๊ฒŒ์ž„ ์‘์šฉ ๋ฐฉ์•ˆ

  • ์—ฌ๋Ÿฌ ํ™”๋ฉด์„ ์—ฐ๊ฒฐํ•ด์„œ ์ง‘, ์•„์นจ, ์ ์‹ฌ, ์ €๋… ๋“ฑ ๋งˆ์„๊ฒŒ์ž„์œผ๋กœ ๋งŒ๋“ค๊ธฐ ๊ฐ€๋Šฅ
  • ๋ฐฉํƒˆ์ถœ ๊ฒŒ์ž„์œผ๋กœ ์‘์šฉ ๊ฐ€๋Šฅ

๐ŸŒฑ ๋Š๋‚€์ 

ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค๊ธฐ ์ „ pygame์„ ์ด์šฉํ•ด ์–ด๋–ค ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š”์ง€ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ๋งŽ์ด ์ฐพ์•„๋ณด๊ณ  ๊ธฐ๋ณธ ๊ธฐ๋Šฅ์„ ์ตํžˆ๋Š” ์‹œ๊ฐ„์„ ํ•˜๋ฃจ์ •๋„ ์žก์•˜๋‹ค. ์ฒ˜์Œ์—” ์–ด๋–ค ๊ฒŒ์ž„์„ ๋งŒ๋“ค์ง€ ๊ณ ๋ฏผ์ด ๋งŽ์•˜์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ทธ ๊ฐˆํ”ผ๋ฅผ ์žก์•˜๋˜ ๊ฒƒ์€ '๋‚ด๊ฐ€ ์ข‹์•„ํ•˜๋Š” ๊ฒŒ์ž„์—์„œ ์“ฐ์ด๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด๋ณด์ž.' ์˜€๋‹ค. ์—ญ์‹œ ๋ฌด์–ธ๊ฐ€ ๋งŒ๋“ค ๋• ๋‚˜์˜ ์• ์ •์ด ๋‹ด๊ธธ์ˆ˜๋ก ๋” ์žฌ๋ฐŒ๊ณ  ์ฆ๊ฒ๋‹ค๊ณ  ๋Š๊ผˆ๋˜ ํ”„๋กœ์ ํŠธ์˜€๋‹ค.

์˜ค๋Š˜ ์ž‘์—…ํ•œ ์ž์„ธํ•œ ์ฝ”๋“œ๋Š” ๋‚˜์˜_๊นƒํ—ˆ๋ธŒ ์— ๊ฒŒ์‹œ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค ๐Ÿ’ฉ

profile
๋ธ”๋กœ๊ทธ ์˜ฎ๊ฒผ์Šต๋‹ˆ๋‹ค!

2๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2022๋…„ 4์›” 28์ผ

๊ณ ์ƒ ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค :)

๊ธ€ ์ •๋ฆฌ ์—„์ฒญ ์ž˜ํ•˜์‹œ๋„ค์š” ใ…Žใ…Žใ…Ž

์ด ๊ธฐ์„ธ๋ชฐ์•„ ํด๋ž˜์Šค์™€ ํ•จ์ˆ˜ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•œ๋ฒˆ ๋” ๋ฆฌํŽ™ํ† ๋ง์„ ๊ฐ€๋ณ๊ฒŒ ํ•ด๋ณด์‹œ๋Š” ๊ฒƒ์„ ๊ถŒ์žฅ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

๊ฐœ๋ฐœ์„ ํ•˜๋‹ค ๋ณด๋ฉด ์—๋Ÿฌ๊ฐ€ ์ข…์ข… ๋‚˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ฆ‰ ์—๋Ÿฌ ์ฝ”๋“œ๋Š” ์™„๋ฒฝํ•˜๊ฒŒ ์žก์„ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ ์ด๋ฅผ ์–ด๋–ป๊ฒŒ ๋ง‰์„ ์ˆ˜ ์žˆ์„์ง€ ๊ณ ๋ฏผํ•ด๋ณด์„ธ์š”.
(์˜ˆ์™ธ์ฒ˜๋ฆฌ ๊ฒ€์ƒ‰)

๋งˆ์ง€๋ง‰์œผ๋กœ ๊ฒŒ์ž„์ด๋‚˜ ํ”„๋กœ๊ทธ๋žจ์„ ๋งŒ๋“ค๊ฒŒ ๋˜๋ฉด ์กฐ๊ฑด๋ฌธ์„ ๊ฝค ๋งŽ์ด ์ •์˜ํ•˜๊ฒŒ ๋˜๋ฉฐ
์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ์ฝ”๋“œ๊ฐ€ ์•ฝ๊ฐ„ ์ง€์ €๋ถ„ํ•ด์ง‘๋‹ˆ๋‹ค.

์ด๋Ÿด๋•Œ ํŒŒ์ด์ฌ์—์„œ๋Š” ์–ด๋–ป๊ฒŒ ์ฝ”๋“œ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ •๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ๊ฒ€์ƒ‰ํ•ด๋ณด์„ธ์š” :)
(switch ๋ฌธ๋ฒ•)

์ด๋ ‡๊ฒŒ ๊ณต๋ถ€๋ฅผ ์—ด์‹ฌํžˆ ํ•˜์‹  ๋งŒํผ ๋‹ค์Œ ํ”„๋กœ์ ํŠธ๋„ ์ž˜ ํ•ด๋‚ด์‹ค ์ˆ˜ ์žˆ์„๊ฒƒ ์ž…๋‹ˆ๋‹ค.

๋งˆ์ง€๋ง‰์œผ๋กœ ์ธ์Šคํƒ€ ํ”„๋กœ์ ํŠธ๋„ ์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

1๊ฐœ์˜ ๋‹ต๊ธ€