├── .gitignore ├── 2023 Fall 2DGP Syllabus.pdf ├── 2023_2DGP_1차발표가이드.pdf ├── 2023_2DGP_2차발표가이드.pdf ├── 2023_2DGP_3차최종발표가이드.pdf ├── 2D 게임 프로그래밍 과제 윤리 서약서.pdf ├── Labs ├── Drill0506-Starter │ ├── .gitattributes │ ├── .gitignore │ ├── TUK_GROUND.png │ ├── animation_sheet.png │ ├── hand_arrow.png │ └── starter.py ├── Lecture04_2D_Rendering │ ├── .gitattributes │ ├── .gitignore │ ├── character.png │ ├── character_grass.py │ └── grass.png ├── Lecture05_Animation │ ├── .gitattributes │ ├── .gitignore │ ├── animation_sheet.png │ ├── ball21x21.png │ ├── character.png │ ├── character_moves.py │ ├── character_runs.py │ ├── grass.png │ └── run_animation.png ├── Lecture06_HandlingInputs │ ├── .gitattributes │ ├── .gitignore │ ├── TUK_GROUND.png │ ├── animation_sheet.png │ ├── character.png │ ├── character_runs_esc.py │ ├── grass.png │ ├── hand_arrow.png │ ├── move_character_with_key.py │ ├── move_character_with_mouse.py │ └── run_animation.png ├── Lecture07_Linear_Movement │ ├── .gitattributes │ ├── .gitignore │ ├── TUK_GROUND.png │ ├── TUK_GROUND_FULL.png │ ├── animation_sheet.png │ ├── hand_arrow.png │ ├── line.py │ ├── move_character_with_mouse.py │ ├── 랜덤 손 위치 추적 소년 동영상.mp4 │ └── 클릭 위치들을 따라서 소년 이동 영상.mp4 ├── Lecture09_Game_Objects │ ├── .gitattributes │ ├── .gitignore │ ├── animation_sheet.png │ ├── ball21x21.png │ ├── ball41x41.png │ ├── boy_grass_object.py │ ├── character.png │ ├── grass.png │ └── run_animation.png ├── Lecture10_Character_Controller_1 │ ├── animation_sheet.png │ ├── ball21x21.png │ ├── ball41x41.png │ ├── boys_team_10000.py │ ├── control_boy.py │ ├── grass.png │ └── run_animation.png ├── Lecture11_Character_Controller_2 │ ├── animation_sheet.png │ ├── ball21x21.png │ ├── boy.py │ ├── control_boy.py │ ├── grass.png │ └── grass.py ├── Lecture12_Game_World │ ├── .gitattributes │ ├── .gitignore │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── boy.py │ ├── control_boy.py │ ├── grass.png │ └── grass.py ├── Lecture13_Game_Framework │ ├── .gitattributes │ ├── .gitignore │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── ball41x41.png │ ├── boy.py │ ├── control_boy.py │ ├── game_framework.py │ ├── game_world.py │ ├── grass.png │ ├── grass.py │ ├── item_select.png │ ├── pannel.py │ ├── title.png │ └── tuk_credit.png ├── Lecture14_Time │ ├── .gitignore │ ├── ENCR10B.TTF │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── ball41x41.png │ ├── bird_animation.png │ ├── boy.py │ ├── game_framework.py │ ├── game_world.py │ ├── grass.png │ ├── grass.py │ ├── main.py │ ├── play_mode.py │ └── ruler.png ├── Lecture15_Collision │ ├── .gitattributes │ ├── .gitignore │ ├── ENCR10B.TTF │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── ball41x41.png │ ├── bird_animation.png │ ├── boy.py │ ├── game_framework.py │ ├── game_world.py │ ├── grass.png │ ├── grass.py │ ├── main.py │ ├── play_mode.py │ ├── zombie.py │ └── zombie │ │ ├── Walk (1).png │ │ ├── Walk (10).png │ │ ├── Walk (2).png │ │ ├── Walk (3).png │ │ ├── Walk (4).png │ │ ├── Walk (5).png │ │ ├── Walk (6).png │ │ ├── Walk (7).png │ │ ├── Walk (8).png │ │ └── Walk (9).png ├── Lecture16_AI │ ├── ENCR10B.TTF │ ├── TUK_GROUND.png │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── ball41x41.png │ ├── ball_arrow.png │ ├── behavior_tree.py │ ├── boy.py │ ├── game_framework.py │ ├── game_world.py │ ├── ground.py │ ├── hand_arrow.png │ ├── main.py │ ├── play_mode.py │ ├── zombie.py │ └── zombie │ │ ├── Attack (1).png │ │ ├── Attack (2).png │ │ ├── Attack (3).png │ │ ├── Attack (4).png │ │ ├── Attack (5).png │ │ ├── Attack (6).png │ │ ├── Attack (7).png │ │ ├── Attack (8).png │ │ ├── Dead (1).png │ │ ├── Dead (10).png │ │ ├── Dead (11).png │ │ ├── Dead (12).png │ │ ├── Dead (2).png │ │ ├── Dead (3).png │ │ ├── Dead (4).png │ │ ├── Dead (5).png │ │ ├── Dead (6).png │ │ ├── Dead (7).png │ │ ├── Dead (8).png │ │ ├── Dead (9).png │ │ ├── Idle (1).png │ │ ├── Idle (10).png │ │ ├── Idle (2).png │ │ ├── Idle (3).png │ │ ├── Idle (4).png │ │ ├── Idle (5).png │ │ ├── Idle (6).png │ │ ├── Idle (7).png │ │ ├── Idle (8).png │ │ ├── Idle (9).png │ │ ├── Walk (1).png │ │ ├── Walk (10).png │ │ ├── Walk (2).png │ │ ├── Walk (3).png │ │ ├── Walk (4).png │ │ ├── Walk (5).png │ │ ├── Walk (6).png │ │ ├── Walk (7).png │ │ ├── Walk (8).png │ │ └── Walk (9).png ├── Lecture16_AI_Drill_Solution │ ├── ENCR10B.TTF │ ├── TUK_GROUND.png │ ├── animation_sheet.png │ ├── ball.py │ ├── ball21x21.png │ ├── ball41x41.png │ ├── ball_arrow.png │ ├── behavior_tree.py │ ├── boy.py │ ├── game_framework.py │ ├── game_world.py │ ├── ground.py │ ├── hand_arrow.png │ ├── main.py │ ├── play_mode.py │ ├── zombie.py │ └── zombie │ │ ├── Attack (1).png │ │ ├── Attack (2).png │ │ ├── Attack (3).png │ │ ├── Attack (4).png │ │ ├── Attack (5).png │ │ ├── Attack (6).png │ │ ├── Attack (7).png │ │ ├── Attack (8).png │ │ ├── Dead (1).png │ │ ├── Dead (10).png │ │ ├── Dead (11).png │ │ ├── Dead (12).png │ │ ├── Dead (2).png │ │ ├── Dead (3).png │ │ ├── Dead (4).png │ │ ├── Dead (5).png │ │ ├── Dead (6).png │ │ ├── Dead (7).png │ │ ├── Dead (8).png │ │ ├── Dead (9).png │ │ ├── Idle (1).png │ │ ├── Idle (10).png │ │ ├── Idle (2).png │ │ ├── Idle (3).png │ │ ├── Idle (4).png │ │ ├── Idle (5).png │ │ ├── Idle (6).png │ │ ├── Idle (7).png │ │ ├── Idle (8).png │ │ ├── Idle (9).png │ │ ├── Walk (1).png │ │ ├── Walk (10).png │ │ ├── Walk (2).png │ │ ├── Walk (3).png │ │ ├── Walk (4).png │ │ ├── Walk (5).png │ │ ├── Walk (6).png │ │ ├── Walk (7).png │ │ ├── Walk (8).png │ │ └── Walk (9).png ├── Lecture17_Scrolling │ ├── .gitignore │ ├── ENCR10B.TTF │ ├── animation_sheet.png │ ├── background.py │ ├── ball.py │ ├── ball21x21.png │ ├── boy.py │ ├── collision.py │ ├── cube00.png │ ├── cube01.png │ ├── cube02.png │ ├── cube10.png │ ├── cube11.png │ ├── cube12.png │ ├── cube20.png │ ├── cube21.png │ ├── cube22.png │ ├── futsal_court.png │ ├── game_framework.py │ ├── game_world.py │ ├── main.py │ ├── play_mode.py │ └── server.py ├── Lecture18_Game_Data │ ├── .gitattributes │ ├── .gitignore │ ├── ENCR10B.TTF │ ├── TUK_GROUND.png │ ├── TUK_GROUND_FULL.png │ ├── animation_sheet.png │ ├── background.py │ ├── behavior_tree.py │ ├── boy.py │ ├── game.sav │ ├── game_framework.py │ ├── game_world.py │ ├── hand_arrow.png │ ├── main.py │ ├── menu.png │ ├── menu_mode.py │ ├── play_mode.py │ ├── server.py │ ├── zombie.py │ ├── zombie │ │ ├── Attack (1).png │ │ ├── Attack (2).png │ │ ├── Attack (3).png │ │ ├── Attack (4).png │ │ ├── Attack (5).png │ │ ├── Attack (6).png │ │ ├── Attack (7).png │ │ ├── Attack (8).png │ │ ├── Dead (1).png │ │ ├── Dead (10).png │ │ ├── Dead (11).png │ │ ├── Dead (12).png │ │ ├── Dead (2).png │ │ ├── Dead (3).png │ │ ├── Dead (4).png │ │ ├── Dead (5).png │ │ ├── Dead (6).png │ │ ├── Dead (7).png │ │ ├── Dead (8).png │ │ ├── Dead (9).png │ │ ├── Idle (1).png │ │ ├── Idle (10).png │ │ ├── Idle (2).png │ │ ├── Idle (3).png │ │ ├── Idle (4).png │ │ ├── Idle (5).png │ │ ├── Idle (6).png │ │ ├── Idle (7).png │ │ ├── Idle (8).png │ │ ├── Idle (9).png │ │ ├── Walk (1).png │ │ ├── Walk (10).png │ │ ├── Walk (2).png │ │ ├── Walk (3).png │ │ ├── Walk (4).png │ │ ├── Walk (5).png │ │ ├── Walk (6).png │ │ ├── Walk (7).png │ │ ├── Walk (8).png │ │ └── Walk (9).png │ ├── zombie_data.json │ └── zombie_data.toml └── Lecture19_Sound_Packaging │ ├── .gitattributes │ ├── .gitignore │ ├── ENCR10B.TTF │ ├── TUK_GROUND_FULL.png │ ├── animation_sheet.png │ ├── background.py │ ├── ball.py │ ├── ball21x21.png │ ├── behavior_tree.py │ ├── boy.py │ ├── football.mp3 │ ├── game_framework.py │ ├── game_world.py │ ├── main.py │ ├── pickup.wav │ ├── play_mode.py │ ├── pyinstaller_settings.toml │ ├── run_pyinstaller.py │ ├── server.py │ ├── zombie.py │ ├── zombie │ ├── Idle (1).png │ ├── Idle (10).png │ ├── Idle (2).png │ ├── Idle (3).png │ ├── Idle (4).png │ ├── Idle (5).png │ ├── Idle (6).png │ ├── Idle (7).png │ ├── Idle (8).png │ ├── Idle (9).png │ ├── Walk (1).png │ ├── Walk (10).png │ ├── Walk (2).png │ ├── Walk (3).png │ ├── Walk (4).png │ ├── Walk (5).png │ ├── Walk (6).png │ ├── Walk (7).png │ ├── Walk (8).png │ └── Walk (9).png │ └── zombie_pickup.wav ├── README.md ├── Slides ├── LEC00_과목소개.pdf ├── LEC01_파이썬기초(1).pdf ├── LEC02_파이썬기초(2).pdf ├── LEC03_파이썬기초(3).pdf ├── LEC04_2D렌더링.pdf ├── LEC05_애니메이션.pdf ├── LEC06_입력처리.pdf ├── LEC07_직선이동.pdf ├── LEC09_게임오브젝트.pdf ├── LEC10_캐릭터컨트롤러 (1).pdf ├── LEC11_캐릭터컨트롤러 (2).pdf ├── LEC12_게임월드.pdf ├── LEC13_게임프레임웍.pdf ├── LEC14_시간.pdf ├── LEC15_충돌처리.pdf ├── LEC16_인공지능.pdf ├── LEC17_스크롤링.pdf ├── LEC18_게임데이터.pdf ├── LEC19_사운드 및 패키징.pdf └── LEC20_정리.pdf ├── pull.bat └── push.bat /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /2023 Fall 2DGP Syllabus.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/2023 Fall 2DGP Syllabus.pdf -------------------------------------------------------------------------------- /2023_2DGP_1차발표가이드.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/2023_2DGP_1차발표가이드.pdf -------------------------------------------------------------------------------- /2023_2DGP_2차발표가이드.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/2023_2DGP_2차발표가이드.pdf -------------------------------------------------------------------------------- /2023_2DGP_3차최종발표가이드.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/2023_2DGP_3차최종발표가이드.pdf -------------------------------------------------------------------------------- /2D 게임 프로그래밍 과제 윤리 서약서.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/2D 게임 프로그래밍 과제 윤리 서약서.pdf -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Drill0506-Starter/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Drill0506-Starter/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Drill0506-Starter/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Drill0506-Starter/starter.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | TUK_WIDTH, TUK_HEIGHT = 1280, 1024 4 | open_canvas(TUK_WIDTH, TUK_HEIGHT) 5 | 6 | TUK_ground = load_image('TUK_GROUND.png') 7 | character = load_image('animation_sheet.png') 8 | 9 | 10 | def handle_events(): 11 | global running 12 | global x, y 13 | events = get_events() 14 | for event in events: 15 | if event.type == SDL_QUIT: 16 | running = False 17 | elif event.type == SDL_MOUSEMOTION: 18 | x, y = event.x, TUK_HEIGHT - 1 - event.y 19 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 20 | running = False 21 | pass 22 | 23 | 24 | 25 | running = True 26 | x, y = TUK_WIDTH // 2, TUK_HEIGHT // 2 27 | frame = 0 28 | hide_cursor() 29 | 30 | while running: 31 | clear_canvas() 32 | TUK_ground.draw(TUK_WIDTH // 2, TUK_HEIGHT // 2) 33 | character.clip_draw(frame * 100, 100 * 1, 100, 100, x, y) 34 | update_canvas() 35 | frame = (frame + 1) % 8 36 | 37 | handle_events() 38 | 39 | close_canvas() 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Labs/Lecture04_2D_Rendering/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture04_2D_Rendering/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture04_2D_Rendering/character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture04_2D_Rendering/character.png -------------------------------------------------------------------------------- /Labs/Lecture04_2D_Rendering/character_grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | open_canvas() 4 | 5 | # fill here 6 | 7 | close_canvas() 8 | -------------------------------------------------------------------------------- /Labs/Lecture04_2D_Rendering/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture04_2D_Rendering/grass.png -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture05_Animation/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture05_Animation/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture05_Animation/character.png -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/character_moves.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | open_canvas() 4 | 5 | grass = load_image('grass.png') 6 | character = load_image('character.png') 7 | 8 | # 여기를 채우세요. 9 | 10 | close_canvas() 11 | 12 | -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/character_runs.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | open_canvas() 4 | 5 | grass = load_image('grass.png') 6 | character = load_image('run_animation.png') 7 | 8 | # fill here 9 | 10 | 11 | close_canvas() 12 | 13 | -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture05_Animation/grass.png -------------------------------------------------------------------------------- /Labs/Lecture05_Animation/run_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture05_Animation/run_animation.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/character.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/character_runs_esc.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | open_canvas() 4 | grass = load_image('grass.png') 5 | character = load_image('animation_sheet.png') 6 | 7 | 8 | # fill here 9 | 10 | 11 | 12 | def handle_events(): 13 | # fill here 14 | pass 15 | 16 | 17 | frame = 0 18 | for x in range(0, 800, 5): 19 | 20 | clear_canvas() 21 | grass.draw(400, 30) 22 | character.clip_draw(frame * 100, 100, 100, 100, x, 90) 23 | update_canvas() 24 | 25 | # fill here 26 | 27 | 28 | 29 | frame = (frame + 1) % 8 30 | delay(0.05) 31 | 32 | 33 | close_canvas() 34 | -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/grass.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/move_character_with_key.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | 4 | open_canvas() 5 | grass = load_image('grass.png') 6 | character = load_image('animation_sheet.png') 7 | 8 | 9 | def handle_events(): 10 | global running 11 | 12 | # fill here 13 | 14 | events = get_events() 15 | for event in events: 16 | if event.type == SDL_QUIT: 17 | running = False 18 | # fill here 19 | 20 | 21 | running = True 22 | x = 800 // 2 23 | frame = 0 24 | 25 | # fill here 26 | 27 | 28 | close_canvas() 29 | 30 | -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/move_character_with_mouse.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | 4 | # fill here 5 | 6 | 7 | character = load_image('animation_sheet.png') 8 | 9 | 10 | def handle_events(): 11 | global running 12 | 13 | # fill here 14 | 15 | events = get_events() 16 | for event in events: 17 | if event.type == SDL_QUIT: 18 | running = False 19 | # fill here 20 | 21 | 22 | running = True 23 | frame = 0 24 | 25 | # fill here 26 | 27 | 28 | 29 | while running: 30 | clear_canvas() 31 | 32 | # fill here 33 | 34 | update_canvas() 35 | handle_events() 36 | frame = (frame + 1) % 8 37 | delay(0.05) 38 | 39 | close_canvas() 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Labs/Lecture06_HandlingInputs/run_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture06_HandlingInputs/run_animation.png -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/TUK_GROUND_FULL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/TUK_GROUND_FULL.png -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/line.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | import random 3 | 4 | 5 | def stop(): 6 | turtle.bye() 7 | 8 | 9 | def prepare_turtle_canvas(): 10 | turtle.setup(1024, 768) 11 | turtle.bgcolor(0.2, 0.2, 0.2) 12 | turtle.penup() 13 | turtle.hideturtle() 14 | turtle.shape('arrow') 15 | turtle.shapesize(2) 16 | turtle.pensize(5) 17 | turtle.color(1, 0, 0) 18 | turtle.speed(100) 19 | turtle.goto(-500, 0) 20 | turtle.pendown() 21 | turtle.goto(480, 0) 22 | turtle.stamp() 23 | turtle.penup() 24 | turtle.goto(0, -360) 25 | turtle.pendown() 26 | turtle.goto(0, 360) 27 | turtle.setheading(90) 28 | turtle.stamp() 29 | turtle.penup() 30 | turtle.home() 31 | 32 | turtle.shape('circle') 33 | turtle.pensize(1) 34 | turtle.color(0, 0, 0) 35 | turtle.speed(50) 36 | 37 | turtle.onkey(stop, 'Escape') 38 | turtle.listen() 39 | 40 | 41 | def draw_big_point(p): 42 | turtle.goto(p) 43 | turtle.color(0.8, 0.9, 0) 44 | turtle.dot(15) 45 | turtle.write(' '+str(p)) 46 | 47 | 48 | def draw_point(p): 49 | turtle.goto(p) 50 | turtle.dot(5, random.random(), random.random(), random.random()) 51 | 52 | 53 | def draw_line(p1, p2): 54 | # fill here 55 | pass 56 | 57 | 58 | prepare_turtle_canvas() 59 | 60 | 61 | # fill here 62 | 63 | 64 | turtle.done() -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/move_character_with_mouse.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | TUK_WIDTH, TUK_HEIGHT = 1280, 1024 4 | open_canvas(TUK_WIDTH, TUK_HEIGHT) 5 | 6 | TUK_ground = load_image('TUK_GROUND.png') 7 | character = load_image('animation_sheet.png') 8 | 9 | 10 | def handle_events(): 11 | global running 12 | global x, y 13 | events = get_events() 14 | for event in events: 15 | if event.type == SDL_QUIT: 16 | running = False 17 | elif event.type == SDL_MOUSEMOTION: 18 | x, y = event.x, TUK_HEIGHT - 1 - event.y 19 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 20 | running = False 21 | pass 22 | 23 | 24 | 25 | running = True 26 | x, y = TUK_WIDTH // 2, TUK_HEIGHT // 2 27 | frame = 0 28 | hide_cursor() 29 | 30 | while running: 31 | clear_canvas() 32 | TUK_ground.draw(TUK_WIDTH // 2, TUK_HEIGHT // 2) 33 | character.clip_draw(frame * 100, 100 * 1, 100, 100, x, y) 34 | update_canvas() 35 | frame = (frame + 1) % 8 36 | 37 | handle_events() 38 | 39 | close_canvas() 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/랜덤 손 위치 추적 소년 동영상.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/랜덤 손 위치 추적 소년 동영상.mp4 -------------------------------------------------------------------------------- /Labs/Lecture07_Linear_Movement/클릭 위치들을 따라서 소년 이동 영상.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture07_Linear_Movement/클릭 위치들을 따라서 소년 이동 영상.mp4 -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/boy_grass_object.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | # Game object class here 4 | 5 | def handle_events(): 6 | global running 7 | events = get_events() 8 | for event in events: 9 | if event.type == SDL_QUIT: 10 | running = False 11 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 12 | running = False 13 | 14 | open_canvas() 15 | 16 | # initialization code 17 | 18 | # game main loop code 19 | 20 | # finalization code 21 | 22 | close_canvas() 23 | -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/character.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/character.png -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/grass.png -------------------------------------------------------------------------------- /Labs/Lecture09_Game_Objects/run_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture09_Game_Objects/run_animation.png -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture10_Character_Controller_1/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture10_Character_Controller_1/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture10_Character_Controller_1/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/boys_team_10000.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import random 3 | 4 | 5 | # Game object class here 6 | 7 | class Grass: 8 | def __init__(self): 9 | self.image = load_image('grass.png') 10 | 11 | def draw(self): 12 | self.image.draw(400, 30) 13 | 14 | def update(self): 15 | pass 16 | 17 | 18 | class Boy: 19 | def __init__(self): 20 | self.x, self.y = random.randint(0, 800), 90 21 | self.frame = 0 22 | self.image = load_image('run_animation.png') 23 | 24 | def update(self): 25 | self.frame = (self.frame + 1) % 8 26 | self.x += 5 27 | 28 | def draw(self): 29 | self.image.clip_draw(self.frame * 100, 0, 100, 100, self.x, self.y) 30 | 31 | 32 | def handle_events(): 33 | global running 34 | events = get_events() 35 | for event in events: 36 | if event.type == SDL_QUIT: 37 | running = False 38 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 39 | running = False 40 | 41 | 42 | def reset_world(): 43 | global running 44 | global grass 45 | global team 46 | global world 47 | 48 | running = True 49 | world = [] 50 | 51 | grass = Grass() 52 | world.append(grass) 53 | 54 | team = [Boy() for i in range(10)] 55 | world += team 56 | 57 | 58 | def update_world(): 59 | for o in world: 60 | o.update() 61 | pass 62 | 63 | 64 | def render_world(): 65 | clear_canvas() 66 | for o in world: 67 | o.draw() 68 | update_canvas() 69 | 70 | 71 | open_canvas() 72 | reset_world() 73 | # game loop 74 | while running: 75 | handle_events() 76 | update_world() 77 | render_world() 78 | delay(0.05) 79 | # finalization code 80 | close_canvas() 81 | -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/control_boy.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import random 3 | 4 | 5 | # Game object class here 6 | 7 | class Grass: 8 | def __init__(self): 9 | self.image = load_image('grass.png') 10 | 11 | def draw(self): 12 | self.image.draw(400, 30) 13 | 14 | def update(self): 15 | pass 16 | 17 | 18 | class Boy: 19 | def __init__(self): 20 | self.x, self.y = 400, 90 21 | self.frame = 0 22 | self.dir = 0 23 | self.action = 3 24 | self.image = load_image('animation_sheet.png') 25 | 26 | def update(self): 27 | self.frame = (self.frame + 1) % 8 28 | 29 | def handle_event(self, event): 30 | pass 31 | 32 | def draw(self): 33 | self.image.clip_draw(self.frame * 100, self.action * 100, 100, 100, self.x, self.y) 34 | 35 | 36 | def handle_events(): 37 | global running 38 | 39 | events = get_events() 40 | for event in events: 41 | if event.type == SDL_QUIT: 42 | running = False 43 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 44 | running = False 45 | else: 46 | boy.handle_event(event) 47 | 48 | 49 | def reset_world(): 50 | global running 51 | global grass 52 | global team 53 | global world 54 | global boy 55 | 56 | running = True 57 | world = [] 58 | 59 | grass = Grass() 60 | world.append(grass) 61 | 62 | boy = Boy() 63 | world.append(boy) 64 | 65 | 66 | 67 | def update_world(): 68 | for o in world: 69 | o.update() 70 | pass 71 | 72 | 73 | def render_world(): 74 | clear_canvas() 75 | for o in world: 76 | o.draw() 77 | update_canvas() 78 | 79 | 80 | open_canvas() 81 | reset_world() 82 | # game loop 83 | while running: 84 | handle_events() 85 | update_world() 86 | render_world() 87 | delay(0.1) 88 | # finalization code 89 | close_canvas() 90 | -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture10_Character_Controller_1/grass.png -------------------------------------------------------------------------------- /Labs/Lecture10_Character_Controller_1/run_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture10_Character_Controller_1/run_animation.png -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture11_Character_Controller_2/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture11_Character_Controller_2/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/boy.py: -------------------------------------------------------------------------------- 1 | # 이것은 각 상태들을 객체로 구현한 것임. 2 | 3 | from pico2d import load_image 4 | 5 | 6 | 7 | class Idle: 8 | 9 | @staticmethod 10 | def enter(): 11 | print('Idle Enter') 12 | 13 | @staticmethod 14 | def exit(): 15 | print('Idle Exit') 16 | 17 | @staticmethod 18 | def do(): 19 | print('Idle Do') 20 | 21 | @staticmethod 22 | def draw(): 23 | pass 24 | 25 | 26 | 27 | class StateMachine: 28 | def __init__(self): 29 | self.cur_state = Idle 30 | 31 | def start(self): 32 | self.cur_state.enter() 33 | 34 | def update(self): 35 | self.cur_state.do() 36 | 37 | def draw(self): 38 | self.cur_state.draw() 39 | 40 | 41 | 42 | 43 | 44 | class Boy: 45 | def __init__(self): 46 | self.x, self.y = 400, 90 47 | self.frame = 0 48 | self.action = 3 49 | self.image = load_image('animation_sheet.png') 50 | self.state_machine = StateMachine() 51 | self.state_machine.start() 52 | 53 | def update(self): 54 | self.state_machine.update() 55 | 56 | def handle_event(self, event): 57 | pass 58 | 59 | def draw(self): 60 | self.state_machine.draw() 61 | -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/control_boy.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | from grass import Grass 4 | from boy import Boy 5 | 6 | 7 | # Game object class here 8 | 9 | 10 | def handle_events(): 11 | global running 12 | 13 | events = get_events() 14 | for event in events: 15 | if event.type == SDL_QUIT: 16 | running = False 17 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 18 | running = False 19 | else: 20 | boy.handle_event(event) 21 | 22 | 23 | def reset_world(): 24 | global running 25 | global grass 26 | global team 27 | global world 28 | global boy 29 | 30 | running = True 31 | world = [] 32 | 33 | grass = Grass() 34 | world.append(grass) 35 | 36 | boy = Boy() 37 | world.append(boy) 38 | 39 | 40 | 41 | def update_world(): 42 | for o in world: 43 | o.update() 44 | pass 45 | 46 | 47 | def render_world(): 48 | clear_canvas() 49 | for o in world: 50 | o.draw() 51 | update_canvas() 52 | 53 | 54 | open_canvas() 55 | reset_world() 56 | # game loop 57 | while running: 58 | handle_events() 59 | update_world() 60 | render_world() 61 | delay(0.01) 62 | # finalization code 63 | close_canvas() 64 | -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture11_Character_Controller_2/grass.png -------------------------------------------------------------------------------- /Labs/Lecture11_Character_Controller_2/grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | 4 | class Grass: 5 | def __init__(self): 6 | self.image = load_image('grass.png') 7 | 8 | def draw(self): 9 | self.image.draw(400, 30) 10 | 11 | def update(self): 12 | pass 13 | -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture12_Game_World/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | class Ball: 4 | image = None 5 | 6 | def __init__(self, x = 400, y = 300, velocity = 1): 7 | if Ball.image == None: 8 | Ball.image = load_image('ball21x21.png') 9 | self.x, self.y, self.velocity = x, y, velocity 10 | 11 | def draw(self): 12 | self.image.draw(self.x, self.y) 13 | 14 | def update(self): 15 | self.x += self.velocity 16 | -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture12_Game_World/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/control_boy.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | from grass import Grass 4 | from boy import Boy 5 | 6 | 7 | # Game object class here 8 | 9 | 10 | def handle_events(): 11 | global running 12 | 13 | events = get_events() 14 | for event in events: 15 | if event.type == SDL_QUIT: 16 | running = False 17 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 18 | running = False 19 | else: 20 | boy.handle_event(event) 21 | 22 | 23 | def reset_world(): 24 | global running 25 | global grass 26 | global team 27 | global world 28 | global boy 29 | 30 | running = True 31 | world = [] 32 | 33 | grass = Grass() 34 | world.append(grass) 35 | 36 | boy = Boy() 37 | world.append(boy) 38 | 39 | 40 | 41 | def update_world(): 42 | for o in world: 43 | o.update() 44 | pass 45 | 46 | 47 | def render_world(): 48 | clear_canvas() 49 | for o in world: 50 | o.draw() 51 | update_canvas() 52 | 53 | 54 | open_canvas() 55 | reset_world() 56 | # game loop 57 | while running: 58 | handle_events() 59 | update_world() 60 | render_world() 61 | delay(0.01) 62 | # finalization code 63 | close_canvas() 64 | -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture12_Game_World/grass.png -------------------------------------------------------------------------------- /Labs/Lecture12_Game_World/grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | 4 | class Grass: 5 | def __init__(self): 6 | self.image = load_image('grass.png') 7 | 8 | def draw(self): 9 | self.image.draw(400, 30) 10 | 11 | def update(self): 12 | pass 13 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | 4 | class Ball: 5 | image = None 6 | 7 | def __init__(self, x = 400, y = 300, velocity = 1): 8 | if Ball.image == None: 9 | Ball.image = load_image('ball21x21.png') 10 | self.x, self.y, self.velocity = x, y, velocity 11 | 12 | def draw(self): 13 | self.image.draw(self.x, self.y) 14 | 15 | def update(self): 16 | self.x += self.velocity 17 | 18 | if self.x < 25 or self.x > 800 - 25: 19 | game_world.remove_object(self) 20 | 21 | class BigBall: 22 | image = None 23 | 24 | def __init__(self, x = 400, y = 300, velocity = 1): 25 | if BigBall.image == None: 26 | BigBall.image = load_image('ball41x41.png') 27 | self.x, self.y, self.velocity = x, y, velocity 28 | 29 | def draw(self): 30 | self.image.draw(self.x, self.y) 31 | 32 | def update(self): 33 | self.x += self.velocity 34 | 35 | if self.x < 25 or self.x > 800 - 25: 36 | game_world.remove_object(self) 37 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/control_boy.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | import game_world 4 | from grass import Grass 5 | from boy import Boy 6 | 7 | 8 | # Game object class here 9 | 10 | 11 | def handle_events(): 12 | global running 13 | 14 | events = get_events() 15 | for event in events: 16 | if event.type == SDL_QUIT: 17 | running = False 18 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 19 | running = False 20 | else: 21 | boy.handle_event(event) 22 | 23 | 24 | def create_world(): 25 | global running 26 | global grass 27 | global team 28 | global boy 29 | 30 | running = True 31 | 32 | grass = Grass() 33 | game_world.add_object(grass, 0) 34 | 35 | boy = Boy() 36 | game_world.add_object(boy, 1) 37 | 38 | 39 | open_canvas() 40 | create_world() 41 | # game loop 42 | while running: 43 | handle_events() 44 | game_world.update() 45 | clear_canvas() 46 | game_world.render() 47 | update_canvas() 48 | delay(0.01) 49 | # finalization code 50 | close_canvas() 51 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/game_framework.py: -------------------------------------------------------------------------------- 1 | running = None 2 | stack = None 3 | 4 | 5 | def change_mode(mode): 6 | global stack 7 | if (len(stack) > 0): 8 | # execute the current mode's finish function 9 | stack[-1].finish() 10 | # remove the current mode 11 | stack.pop() 12 | stack.append(mode) 13 | mode.init() 14 | 15 | 16 | def push_mode(mode): 17 | global stack 18 | if (len(stack) > 0): 19 | stack[-1].pause() 20 | stack.append(mode) 21 | mode.init() 22 | 23 | 24 | def pop_mode(): 25 | global stack 26 | if (len(stack) > 0): 27 | # execute the current mode's finish function 28 | stack[-1].finish() 29 | # remove the current mode 30 | stack.pop() 31 | 32 | # execute resume function of the previous mode 33 | if (len(stack) > 0): 34 | stack[-1].resume() 35 | 36 | 37 | def quit(): 38 | global running 39 | running = False 40 | 41 | 42 | def run(start_mode): 43 | global running, stack 44 | running = True 45 | stack = [start_mode] 46 | start_mode.init() 47 | 48 | while (running): 49 | stack[-1].handle_events() 50 | stack[-1].update() 51 | stack[-1].draw() 52 | 53 | # repeatedly delete the top of the stack 54 | while (len(stack) > 0): 55 | stack[-1].finish() 56 | stack.pop() 57 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | 3 | 4 | def add_object(o, depth = 0): 5 | objects[depth].append(o) 6 | 7 | def add_objects(ol, depth = 0): 8 | objects[depth] += ol 9 | 10 | 11 | def update(): 12 | for layer in objects: 13 | for o in layer: 14 | o.update() 15 | 16 | 17 | def render(): 18 | for layer in objects: 19 | for o in layer: 20 | o.draw() 21 | 22 | 23 | def remove_object(o): 24 | for layer in objects: 25 | if o in layer: 26 | layer.remove(o) 27 | return 28 | raise ValueError('Cannot delete non existing object') 29 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/grass.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | 4 | class Grass: 5 | def __init__(self): 6 | self.image = load_image('grass.png') 7 | 8 | def draw(self): 9 | self.image.draw(400, 30) 10 | 11 | def update(self): 12 | pass 13 | -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/item_select.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/item_select.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/pannel.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | class Pannel: 4 | def __init__(self): 5 | self.image = load_image('item_select.png') 6 | 7 | def draw(self): 8 | self.image.draw(400, 300) 9 | 10 | def update(self): 11 | pass -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/title.png -------------------------------------------------------------------------------- /Labs/Lecture13_Game_Framework/tuk_credit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture13_Game_Framework/tuk_credit.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture14_Time/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture14_Time/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | 4 | class Ball: 5 | image = None 6 | 7 | def __init__(self, x = 400, y = 300, velocity = 1): 8 | if Ball.image == None: 9 | Ball.image = load_image('ball21x21.png') 10 | self.x, self.y, self.velocity = x, y, velocity 11 | 12 | def draw(self): 13 | self.image.draw(self.x, self.y) 14 | 15 | def update(self): 16 | self.x += self.velocity 17 | 18 | if self.x < 25 or self.x > 1600 - 25: 19 | game_world.remove_object(self) 20 | 21 | class BigBall: 22 | image = None 23 | 24 | def __init__(self, x = 400, y = 300, velocity = 1): 25 | if BigBall.image == None: 26 | BigBall.image = load_image('ball41x41.png') 27 | self.x, self.y, self.velocity = x, y, velocity 28 | 29 | def draw(self): 30 | self.image.draw(self.x, self.y) 31 | 32 | def update(self): 33 | self.x += self.velocity 34 | 35 | if self.x < 25 or self.x > 1600 - 25: 36 | game_world.remove_object(self) 37 | -------------------------------------------------------------------------------- /Labs/Lecture14_Time/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/bird_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/bird_animation.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/game_framework.py: -------------------------------------------------------------------------------- 1 | # fill here 2 | 3 | def change_mode(mode): 4 | global stack 5 | if (len(stack) > 0): 6 | # execute the current mode's finish function 7 | stack[-1].finish() 8 | # remove the current mode 9 | stack.pop() 10 | stack.append(mode) 11 | mode.init() 12 | 13 | 14 | def push_mode(mode): 15 | global stack 16 | if (len(stack) > 0): 17 | stack[-1].pause() 18 | stack.append(mode) 19 | mode.init() 20 | 21 | 22 | def pop_mode(): 23 | global stack 24 | if (len(stack) > 0): 25 | # execute the current mode's finish function 26 | stack[-1].finish() 27 | # remove the current mode 28 | stack.pop() 29 | 30 | # execute resume function of the previous mode 31 | if (len(stack) > 0): 32 | stack[-1].resume() 33 | 34 | 35 | def quit(): 36 | global running 37 | running = False 38 | 39 | 40 | def run(start_mode): 41 | global running, stack 42 | running = True 43 | stack = [start_mode] 44 | start_mode.init() 45 | 46 | # fill here 47 | while running: 48 | stack[-1].handle_events() 49 | stack[-1].update() 50 | stack[-1].draw() 51 | # fill here 52 | 53 | # repeatedly delete the top of the stack 54 | while (len(stack) > 0): 55 | stack[-1].finish() 56 | stack.pop() 57 | -------------------------------------------------------------------------------- /Labs/Lecture14_Time/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | 3 | 4 | def add_object(o, depth = 0): 5 | objects[depth].append(o) 6 | 7 | def add_objects(ol, depth = 0): 8 | objects[depth] += ol 9 | 10 | 11 | def update(): 12 | for layer in objects: 13 | for o in layer: 14 | o.update() 15 | 16 | 17 | def render(): 18 | for layer in objects: 19 | for o in layer: 20 | o.draw() 21 | 22 | 23 | def remove_object(o): 24 | for layer in objects: 25 | if o in layer: 26 | layer.remove(o) 27 | return 28 | raise ValueError('Cannot delete non existing object') 29 | 30 | 31 | def clear(): 32 | for layer in objects: 33 | layer.clear() -------------------------------------------------------------------------------- /Labs/Lecture14_Time/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/grass.png -------------------------------------------------------------------------------- /Labs/Lecture14_Time/grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | class Grass: 4 | def __init__(self): 5 | self.image = load_image('grass.png') 6 | self.ruler_image = load_image('ruler.png') 7 | 8 | def update(self): 9 | pass 10 | 11 | def draw(self): 12 | self.image.draw(400, 30) 13 | self.image.draw(1200, 30) 14 | self.ruler_image.draw(800, 350) 15 | 16 | 17 | -------------------------------------------------------------------------------- /Labs/Lecture14_Time/main.py: -------------------------------------------------------------------------------- 1 | from pico2d import open_canvas, delay, close_canvas 2 | import game_framework 3 | 4 | import play_mode as start_mode 5 | 6 | open_canvas(1600, 600) 7 | game_framework.run(start_mode) 8 | close_canvas() 9 | 10 | -------------------------------------------------------------------------------- /Labs/Lecture14_Time/play_mode.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_framework 3 | 4 | import game_world 5 | from grass import Grass 6 | from boy import Boy 7 | 8 | # boy = None 9 | 10 | def handle_events(): 11 | events = get_events() 12 | for event in events: 13 | if event.type == SDL_QUIT: 14 | game_framework.quit() 15 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 16 | game_framework.quit() 17 | else: 18 | boy.handle_event(event) 19 | 20 | def init(): 21 | global grass 22 | global boy 23 | 24 | running = True 25 | 26 | grass = Grass() 27 | game_world.add_object(grass, 0) 28 | 29 | boy = Boy() 30 | game_world.add_object(boy, 1) 31 | 32 | 33 | def finish(): 34 | game_world.clear() 35 | pass 36 | 37 | 38 | def update(): 39 | game_world.update() 40 | # delay(0.1) 41 | 42 | 43 | def draw(): 44 | clear_canvas() 45 | game_world.render() 46 | update_canvas() 47 | 48 | def pause(): 49 | pass 50 | 51 | def resume(): 52 | pass 53 | 54 | -------------------------------------------------------------------------------- /Labs/Lecture14_Time/ruler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture14_Time/ruler.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | import game_framework 4 | 5 | class Ball: 6 | image = None 7 | 8 | def __init__(self, x = 400, y = 300, velocity = 1): 9 | if Ball.image == None: 10 | Ball.image = load_image('ball21x21.png') 11 | self.x, self.y, self.velocity = x, y, velocity 12 | 13 | def draw(self): 14 | self.image.draw(self.x, self.y) 15 | 16 | def update(self): 17 | self.x += self.velocity * 100 * game_framework.frame_time 18 | 19 | if self.x < 25 or self.x > 1600 - 25: 20 | game_world.remove_object(self) 21 | 22 | # fill here -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/bird_animation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/bird_animation.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def change_mode(mode): 5 | global stack 6 | if (len(stack) > 0): 7 | # execute the current mode's finish function 8 | stack[-1].finish() 9 | # remove the current mode 10 | stack.pop() 11 | stack.append(mode) 12 | mode.init() 13 | 14 | 15 | def push_mode(mode): 16 | global stack 17 | if (len(stack) > 0): 18 | stack[-1].pause() 19 | stack.append(mode) 20 | mode.init() 21 | 22 | 23 | def pop_mode(): 24 | global stack 25 | if (len(stack) > 0): 26 | # execute the current mode's finish function 27 | stack[-1].finish() 28 | # remove the current mode 29 | stack.pop() 30 | 31 | # execute resume function of the previous mode 32 | if (len(stack) > 0): 33 | stack[-1].resume() 34 | 35 | 36 | def quit(): 37 | global running 38 | running = False 39 | 40 | 41 | def run(start_mode): 42 | global running, stack 43 | running = True 44 | stack = [start_mode] 45 | start_mode.init() 46 | 47 | global frame_time 48 | frame_time = 0.0 49 | current_time = time.time() 50 | while running: 51 | stack[-1].handle_events() 52 | stack[-1].update() 53 | stack[-1].draw() 54 | frame_time = time.time() - current_time 55 | frame_rate = 1.0 / frame_time 56 | current_time += frame_time 57 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 58 | 59 | # repeatedly delete the top of the stack 60 | while (len(stack) > 0): 61 | stack[-1].finish() 62 | stack.pop() 63 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | 3 | # fill here 4 | 5 | def add_object(o, depth = 0): 6 | objects[depth].append(o) 7 | 8 | def add_objects(ol, depth = 0): 9 | objects[depth] += ol 10 | 11 | 12 | def update(): 13 | for layer in objects: 14 | for o in layer: 15 | o.update() 16 | 17 | 18 | def render(): 19 | for layer in objects: 20 | for o in layer: 21 | o.draw() 22 | 23 | # fill here 24 | 25 | 26 | def remove_object(o): 27 | for layer in objects: 28 | if o in layer: 29 | layer.remove(o) 30 | return 31 | raise ValueError('Cannot delete non existing object') 32 | 33 | 34 | def clear(): 35 | for layer in objects: 36 | layer.clear() 37 | 38 | 39 | 40 | # fill here 41 | 42 | 43 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/grass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/grass.png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/grass.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | class Grass: 4 | def __init__(self): 5 | self.image = load_image('grass.png') 6 | 7 | def update(self): 8 | pass 9 | 10 | def draw(self): 11 | self.image.draw(400, 30) 12 | self.image.draw(1200, 30) 13 | 14 | 15 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/main.py: -------------------------------------------------------------------------------- 1 | from pico2d import open_canvas, delay, close_canvas 2 | import game_framework 3 | 4 | import play_mode as start_mode 5 | 6 | open_canvas(1600, 600) 7 | game_framework.run(start_mode) 8 | close_canvas() 9 | 10 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | from pico2d import * 4 | import game_framework 5 | 6 | import game_world 7 | from grass import Grass 8 | from boy import Boy 9 | from ball import Ball 10 | from zombie import Zombie 11 | 12 | # boy = None 13 | 14 | def handle_events(): 15 | events = get_events() 16 | for event in events: 17 | if event.type == SDL_QUIT: 18 | game_framework.quit() 19 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 20 | game_framework.quit() 21 | else: 22 | boy.handle_event(event) 23 | 24 | def init(): 25 | global grass 26 | global boy 27 | 28 | running = True 29 | 30 | grass = Grass() 31 | game_world.add_object(grass, 0) 32 | 33 | boy = Boy() 34 | game_world.add_object(boy, 1) 35 | 36 | # fill here 37 | 38 | 39 | 40 | def finish(): 41 | game_world.clear() 42 | pass 43 | 44 | 45 | def update(): 46 | game_world.update() 47 | # fill here 48 | 49 | def draw(): 50 | clear_canvas() 51 | game_world.render() 52 | update_canvas() 53 | 54 | def pause(): 55 | pass 56 | 57 | def resume(): 58 | pass 59 | 60 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie.py: -------------------------------------------------------------------------------- 1 | import random 2 | import math 3 | import game_framework 4 | 5 | from pico2d import * 6 | 7 | # zombie Run Speed 8 | PIXEL_PER_METER = (10.0 / 0.3) # 10 pixel 30 cm 9 | RUN_SPEED_KMPH = 10.0 # Km / Hour 10 | RUN_SPEED_MPM = (RUN_SPEED_KMPH * 1000.0 / 60.0) 11 | RUN_SPEED_MPS = (RUN_SPEED_MPM / 60.0) 12 | RUN_SPEED_PPS = (RUN_SPEED_MPS * PIXEL_PER_METER) 13 | 14 | # zombie Action Speed 15 | TIME_PER_ACTION = 0.5 16 | ACTION_PER_TIME = 1.0 / TIME_PER_ACTION 17 | FRAMES_PER_ACTION = 10.0 18 | 19 | animation_names = ['Walk'] 20 | 21 | class Zombie: 22 | images = None 23 | 24 | def load_images(self): 25 | if Zombie.images == None: 26 | Zombie.images = {} 27 | for name in animation_names: 28 | Zombie.images[name] = [load_image("./zombie/"+ name + " (%d)" % i + ".png") for i in range(1, 11)] 29 | 30 | def __init__(self): 31 | self.x, self.y = random.randint(1600-800, 1600), 150 32 | self.load_images() 33 | self.frame = random.randint(0, 9) 34 | self.dir = random.choice([-1,1]) 35 | 36 | 37 | def update(self): 38 | self.frame = (self.frame + FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % FRAMES_PER_ACTION 39 | self.x += RUN_SPEED_PPS * self.dir * game_framework.frame_time 40 | if self.x > 1600: 41 | self.dir = -1 42 | elif self.x < 800: 43 | self.dir = 1 44 | self.x = clamp(800, self.x, 1600) 45 | pass 46 | 47 | 48 | def draw(self): 49 | if self.dir < 0: 50 | Zombie.images['Walk'][int(self.frame)].composite_draw(0, 'h', self.x, self.y, 200, 200) 51 | else: 52 | Zombie.images['Walk'][int(self.frame)].draw(self.x, self.y, 200, 200) 53 | 54 | 55 | def handle_event(self, event): 56 | pass 57 | 58 | -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (1).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (10).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (2).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (3).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (4).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (5).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (6).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (7).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (8).png -------------------------------------------------------------------------------- /Labs/Lecture15_Collision/zombie/Walk (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture15_Collision/zombie/Walk (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture16_AI/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | import game_framework 4 | import random 5 | 6 | class Ball: 7 | image = None 8 | 9 | def __init__(self, x = None, y = None): 10 | if Ball.image == None: 11 | Ball.image = load_image('ball21x21.png') 12 | self.x = x if x else random.randint(100, 1180) 13 | self.y = y if y else random.randint(100, 924) 14 | 15 | def draw(self): 16 | self.image.draw(self.x, self.y) 17 | draw_rectangle(*self.get_bb()) 18 | 19 | def update(self): 20 | pass 21 | 22 | def get_bb(self): 23 | return self.x - 10, self.y - 10, self.x + 10, self.y + 10 24 | 25 | def handle_collision(self, group, other): 26 | match group: 27 | case 'boy:ball': 28 | game_world.remove_object(self) 29 | case 'zombie:ball': 30 | game_world.remove_object(self) -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ball_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/ball_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def change_mode(mode): 5 | global stack 6 | if (len(stack) > 0): 7 | # execute the current mode's finish function 8 | stack[-1].finish() 9 | # remove the current mode 10 | stack.pop() 11 | stack.append(mode) 12 | mode.init() 13 | 14 | 15 | def push_mode(mode): 16 | global stack 17 | if (len(stack) > 0): 18 | stack[-1].pause() 19 | stack.append(mode) 20 | mode.init() 21 | 22 | 23 | def pop_mode(): 24 | global stack 25 | if (len(stack) > 0): 26 | # execute the current mode's finish function 27 | stack[-1].finish() 28 | # remove the current mode 29 | stack.pop() 30 | 31 | # execute resume function of the previous mode 32 | if (len(stack) > 0): 33 | stack[-1].resume() 34 | 35 | 36 | def quit(): 37 | global running 38 | running = False 39 | 40 | 41 | def run(start_mode): 42 | global running, stack 43 | running = True 44 | stack = [start_mode] 45 | start_mode.init() 46 | 47 | global frame_time 48 | frame_time = 0.0 49 | current_time = time.time() 50 | while running: 51 | stack[-1].handle_events() 52 | stack[-1].update() 53 | stack[-1].draw() 54 | frame_time = time.time() - current_time 55 | frame_rate = 1.0 / frame_time 56 | current_time += frame_time 57 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 58 | 59 | # repeatedly delete the top of the stack 60 | while (len(stack) > 0): 61 | stack[-1].finish() 62 | stack.pop() 63 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | collision_pairs = {} 3 | 4 | def add_object(o, depth = 0): 5 | objects[depth].append(o) 6 | 7 | def add_objects(ol, depth = 0): 8 | objects[depth] += ol 9 | 10 | 11 | def update(): 12 | for layer in objects: 13 | for o in layer: 14 | o.update() 15 | 16 | 17 | def render(): 18 | for layer in objects: 19 | for o in layer: 20 | o.draw() 21 | 22 | def remove_collision_object(o): 23 | for pairs in collision_pairs.values(): 24 | if o in pairs[0]: 25 | pairs[0].remove(o) 26 | if o in pairs[1]: 27 | pairs[1].remove(o) 28 | 29 | 30 | def remove_object(o): 31 | for layer in objects: 32 | if o in layer: 33 | layer.remove(o) 34 | remove_collision_object(o) 35 | del o 36 | return 37 | raise ValueError('Cannot delete non existing object') 38 | 39 | 40 | def clear(): 41 | for layer in objects: 42 | layer.clear() 43 | 44 | 45 | def collide(a, b): 46 | left_a, bottom_a, right_a, top_a = a.get_bb() 47 | left_b, bottom_b, right_b, top_b = b.get_bb() 48 | 49 | if left_a > right_b: return False 50 | if right_a < left_b: return False 51 | if top_a < bottom_b: return False 52 | if bottom_a > top_b: return False 53 | 54 | return True 55 | 56 | 57 | def add_collision_pair(group, a, b): 58 | if group not in collision_pairs: 59 | print(f'Added new group {group}') 60 | collision_pairs[group] = [ [], [] ] 61 | if a: 62 | collision_pairs[group][0].append(a) 63 | if b: 64 | collision_pairs[group][1].append(b) 65 | 66 | 67 | def handle_collisions(): 68 | for group, pairs in collision_pairs.items(): 69 | for a in pairs[0]: 70 | for b in pairs[1]: 71 | if collide(a, b): 72 | a.handle_collision(group, b) 73 | b.handle_collision(group, a) 74 | 75 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/ground.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | class Ground: 4 | def __init__(self): 5 | self.image = load_image('TUK_GROUND.png') 6 | 7 | def update(self): 8 | pass 9 | 10 | def draw(self): 11 | self.image.draw(1280 // 2, 1024 // 2) 12 | 13 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/main.py: -------------------------------------------------------------------------------- 1 | from pico2d import open_canvas, delay, close_canvas 2 | import game_framework 3 | 4 | import play_mode as start_mode 5 | 6 | open_canvas(1280, 1024) 7 | game_framework.run(start_mode) 8 | close_canvas() 9 | 10 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | from pico2d import * 4 | import game_framework 5 | 6 | import game_world 7 | from boy import Boy 8 | from ball import Ball 9 | from zombie import Zombie 10 | from ground import Ground 11 | 12 | 13 | def handle_events(): 14 | events = get_events() 15 | for event in events: 16 | if event.type == SDL_QUIT: 17 | game_framework.quit() 18 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 19 | game_framework.quit() 20 | 21 | else: 22 | boy.handle_event(event) 23 | 24 | 25 | def init(): 26 | global boy 27 | 28 | ground = Ground() 29 | game_world.add_object(ground, 0) 30 | 31 | boy = Boy() 32 | game_world.add_object(boy, 2) 33 | game_world.add_collision_pair('boy:ball', boy, None) 34 | 35 | zombie = Zombie(300, 300) 36 | game_world.add_object(zombie, 2) 37 | game_world.add_collision_pair('zombie:ball', zombie, None) 38 | 39 | balls = [Ball() for _ in range(30)] 40 | for ball in balls: 41 | game_world.add_object(ball, 1) 42 | game_world.add_collision_pair('boy:ball', None, ball) 43 | game_world.add_collision_pair('zombie:ball', None, ball) 44 | 45 | 46 | def finish(): 47 | game_world.clear() 48 | pass 49 | 50 | 51 | def update(): 52 | game_world.update() 53 | game_world.handle_collisions() 54 | 55 | def draw(): 56 | clear_canvas() 57 | game_world.render() 58 | update_canvas() 59 | 60 | def pause(): 61 | pass 62 | 63 | def resume(): 64 | pass 65 | 66 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | import random 4 | import math 5 | import game_framework 6 | import game_world 7 | from behavior_tree import BehaviorTree, Action, Sequence, Condition, Selector 8 | import play_mode 9 | 10 | 11 | # zombie Run Speed 12 | PIXEL_PER_METER = (10.0 / 0.3) # 10 pixel 30 cm 13 | RUN_SPEED_KMPH = 10.0 # Km / Hour 14 | RUN_SPEED_MPM = (RUN_SPEED_KMPH * 1000.0 / 60.0) 15 | RUN_SPEED_MPS = (RUN_SPEED_MPM / 60.0) 16 | RUN_SPEED_PPS = (RUN_SPEED_MPS * PIXEL_PER_METER) 17 | 18 | # zombie Action Speed 19 | TIME_PER_ACTION = 0.5 20 | ACTION_PER_TIME = 1.0 / TIME_PER_ACTION 21 | FRAMES_PER_ACTION = 10.0 22 | 23 | animation_names = ['Walk', 'Idle'] 24 | 25 | 26 | class Zombie: 27 | images = None 28 | 29 | def load_images(self): 30 | if Zombie.images == None: 31 | Zombie.images = {} 32 | for name in animation_names: 33 | Zombie.images[name] = [load_image("./zombie/" + name + " (%d)" % i + ".png") for i in range(1, 11)] 34 | Zombie.font = load_font('ENCR10B.TTF', 40) 35 | Zombie.marker_image = load_image('hand_arrow.png') 36 | 37 | 38 | def __init__(self, x=None, y=None): 39 | self.x = x if x else random.randint(100, 1180) 40 | self.y = y if y else random.randint(100, 924) 41 | self.load_images() 42 | self.dir = 0.0 # radian 값으로 방향을 표시 43 | self.speed = 0.0 44 | self.frame = random.randint(0, 9) 45 | self.state = 'Idle' 46 | self.ball_count = 0 47 | 48 | self.build_behavior_tree() 49 | 50 | 51 | def get_bb(self): 52 | return self.x - 50, self.y - 50, self.x + 50, self.y + 50 53 | 54 | 55 | def update(self): 56 | self.frame = (self.frame + FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % FRAMES_PER_ACTION 57 | # fill here 58 | 59 | 60 | def draw(self): 61 | if math.cos(self.dir) < 0: 62 | Zombie.images[self.state][int(self.frame)].composite_draw(0, 'h', self.x, self.y, 100, 100) 63 | else: 64 | Zombie.images[self.state][int(self.frame)].draw(self.x, self.y, 100, 100) 65 | self.font.draw(self.x - 10, self.y + 60, f'{self.ball_count}', (0, 0, 255)) 66 | draw_rectangle(*self.get_bb()) 67 | 68 | def handle_event(self, event): 69 | pass 70 | 71 | def handle_collision(self, group, other): 72 | if group == 'zombie:ball': 73 | self.ball_count += 1 74 | 75 | 76 | def set_target_location(self, x=None, y=None): 77 | pass 78 | 79 | def distance_less_than(self, x1, y1, x2, y2, r): 80 | pass 81 | 82 | def move_slightly_to(self, tx, ty): 83 | pass 84 | 85 | def move_to(self, r=0.5): 86 | pass 87 | 88 | def set_random_location(self): 89 | pass 90 | 91 | def is_boy_nearby(self, distance): 92 | pass 93 | 94 | def move_to_boy(self, r=0.5): 95 | pass 96 | 97 | def get_patrol_location(self): 98 | pass 99 | 100 | def build_behavior_tree(self): 101 | pass 102 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Attack (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Attack (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (11).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (11).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (12).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (12).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Dead (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Dead (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Idle (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Idle (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI/zombie/Walk (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI/zombie/Walk (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | import game_framework 4 | import random 5 | 6 | class Ball: 7 | image = None 8 | 9 | def __init__(self, x = None, y = None): 10 | if Ball.image == None: 11 | Ball.image = load_image('ball21x21.png') 12 | self.x = x if x else random.randint(100, 1180) 13 | self.y = y if y else random.randint(100, 924) 14 | 15 | def draw(self): 16 | self.image.draw(self.x, self.y) 17 | draw_rectangle(*self.get_bb()) 18 | 19 | def update(self): 20 | pass 21 | 22 | def get_bb(self): 23 | return self.x - 10, self.y - 10, self.x + 10, self.y + 10 24 | 25 | def handle_collision(self, group, other): 26 | match group: 27 | case 'boy:ball': 28 | game_world.remove_object(self) 29 | case 'zombie:ball': 30 | game_world.remove_object(self) -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ball41x41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/ball41x41.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ball_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/ball_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | frame_time = 0.0 4 | 5 | def change_mode(mode): 6 | global stack 7 | if (len(stack) > 0): 8 | # execute the current mode's finish function 9 | stack[-1].finish() 10 | # remove the current mode 11 | stack.pop() 12 | stack.append(mode) 13 | mode.init() 14 | 15 | 16 | def push_mode(mode): 17 | global stack 18 | if (len(stack) > 0): 19 | stack[-1].pause() 20 | stack.append(mode) 21 | mode.init() 22 | 23 | 24 | def pop_mode(): 25 | global stack 26 | if (len(stack) > 0): 27 | # execute the current mode's finish function 28 | stack[-1].finish() 29 | # remove the current mode 30 | stack.pop() 31 | 32 | # execute resume function of the previous mode 33 | if (len(stack) > 0): 34 | stack[-1].resume() 35 | 36 | 37 | def quit(): 38 | global running 39 | running = False 40 | 41 | 42 | def run(start_mode): 43 | global running, stack 44 | running = True 45 | stack = [start_mode] 46 | start_mode.init() 47 | 48 | global frame_time 49 | frame_time = 0.0 50 | current_time = time.time() 51 | while running: 52 | stack[-1].handle_events() 53 | stack[-1].update() 54 | stack[-1].draw() 55 | frame_time = time.time() - current_time 56 | frame_rate = 1.0 / frame_time 57 | current_time += frame_time 58 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 59 | 60 | # repeatedly delete the top of the stack 61 | while (len(stack) > 0): 62 | stack[-1].finish() 63 | stack.pop() 64 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | collision_pairs = {} 3 | 4 | def add_object(o, depth = 0): 5 | objects[depth].append(o) 6 | 7 | def add_objects(ol, depth = 0): 8 | objects[depth] += ol 9 | 10 | 11 | def update(): 12 | for layer in objects: 13 | for o in layer: 14 | o.update() 15 | 16 | 17 | def render(): 18 | for layer in objects: 19 | for o in layer: 20 | o.draw() 21 | 22 | def remove_collision_object(o): 23 | for pairs in collision_pairs.values(): 24 | if o in pairs[0]: 25 | pairs[0].remove(o) 26 | if o in pairs[1]: 27 | pairs[1].remove(o) 28 | 29 | 30 | def remove_object(o): 31 | for layer in objects: 32 | if o in layer: 33 | layer.remove(o) 34 | remove_collision_object(o) 35 | del o 36 | return 37 | raise ValueError('Cannot delete non existing object') 38 | 39 | 40 | def clear(): 41 | for layer in objects: 42 | layer.clear() 43 | 44 | 45 | def collide(a, b): 46 | left_a, bottom_a, right_a, top_a = a.get_bb() 47 | left_b, bottom_b, right_b, top_b = b.get_bb() 48 | 49 | if left_a > right_b: return False 50 | if right_a < left_b: return False 51 | if top_a < bottom_b: return False 52 | if bottom_a > top_b: return False 53 | 54 | return True 55 | 56 | 57 | def add_collision_pair(group, a, b): 58 | if group not in collision_pairs: 59 | print(f'Added new group {group}') 60 | collision_pairs[group] = [ [], [] ] 61 | if a: 62 | collision_pairs[group][0].append(a) 63 | if b: 64 | collision_pairs[group][1].append(b) 65 | 66 | 67 | def handle_collisions(): 68 | for group, pairs in collision_pairs.items(): 69 | for a in pairs[0]: 70 | for b in pairs[1]: 71 | if collide(a, b): 72 | a.handle_collision(group, b) 73 | b.handle_collision(group, a) 74 | 75 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/ground.py: -------------------------------------------------------------------------------- 1 | from pico2d import load_image 2 | 3 | class Ground: 4 | def __init__(self): 5 | self.image = load_image('TUK_GROUND.png') 6 | 7 | def update(self): 8 | pass 9 | 10 | def draw(self): 11 | self.image.draw(1280 // 2, 1024 // 2) 12 | 13 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/main.py: -------------------------------------------------------------------------------- 1 | from pico2d import open_canvas, delay, close_canvas 2 | import game_framework 3 | 4 | import play_mode as start_mode 5 | 6 | open_canvas(1280, 1024) 7 | game_framework.run(start_mode) 8 | close_canvas() 9 | 10 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | from pico2d import * 4 | import game_framework 5 | 6 | import game_world 7 | from boy import Boy 8 | from ball import Ball 9 | from zombie import Zombie 10 | from ground import Ground 11 | 12 | 13 | def handle_events(): 14 | events = get_events() 15 | for event in events: 16 | if event.type == SDL_QUIT: 17 | game_framework.quit() 18 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 19 | game_framework.quit() 20 | 21 | else: 22 | boy.handle_event(event) 23 | 24 | 25 | def init(): 26 | global boy 27 | 28 | ground = Ground() 29 | game_world.add_object(ground, 0) 30 | 31 | boy = Boy() 32 | game_world.add_object(boy, 2) 33 | game_world.add_collision_pair('boy:ball', boy, None) 34 | 35 | zombie = Zombie(300, 300) 36 | game_world.add_object(zombie, 2) 37 | game_world.add_collision_pair('zombie:ball', zombie, None) 38 | 39 | balls = [Ball() for _ in range(50)] 40 | for ball in balls: 41 | game_world.add_object(ball, 1) 42 | game_world.add_collision_pair('boy:ball', None, ball) 43 | game_world.add_collision_pair('zombie:ball', None, ball) 44 | 45 | 46 | def finish(): 47 | game_world.clear() 48 | pass 49 | 50 | 51 | def update(): 52 | game_world.update() 53 | game_world.handle_collisions() 54 | 55 | def draw(): 56 | clear_canvas() 57 | game_world.render() 58 | update_canvas() 59 | 60 | def pause(): 61 | pass 62 | 63 | def resume(): 64 | pass 65 | 66 | -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Attack (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Attack (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (11).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (11).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (12).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (12).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Dead (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Dead (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Idle (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Idle (9).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (1).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (10).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (2).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (3).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (4).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (5).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (6).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (7).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (8).png -------------------------------------------------------------------------------- /Labs/Lecture16_AI_Drill_Solution/zombie/Walk (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture16_AI_Drill_Solution/zombie/Walk (9).png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/background.py: -------------------------------------------------------------------------------- 1 | import random 2 | import server 3 | 4 | from pico2d import * 5 | 6 | 7 | class FixedBackground: 8 | 9 | def __init__(self): 10 | self.image = load_image('futsal_court.png') 11 | # fill here 12 | pass 13 | 14 | def draw(self): 15 | # fill here 16 | pass 17 | 18 | def update(self): 19 | # fill here 20 | pass 21 | 22 | def handle_event(self, event): 23 | pass 24 | 25 | 26 | 27 | 28 | 29 | 30 | class TileBackground: 31 | 32 | def __init__(self): 33 | self.cw = get_canvas_width() 34 | self.ch = get_canvas_height() 35 | self.w = 800 * 3 36 | self.h = 600 * 3 37 | 38 | # fill here 39 | 40 | 41 | 42 | def update(self): 43 | pass 44 | 45 | def draw(self): 46 | self.window_left = clamp(0, int(server.boy.x) - self.cw // 2, self.w - self.cw - 1) 47 | self.window_bottom = clamp(0, int(server.boy.y) - self.ch // 2, self.h - self.ch - 1) 48 | 49 | # fill here 50 | pass 51 | 52 | 53 | cx = 900 % 800 54 | cy = 700 // 600 55 | 56 | 57 | 58 | 59 | 60 | class InfiniteBackground: 61 | 62 | def __init__(self): 63 | self.image = load_image('futsal_court.png') 64 | self.cw = get_canvas_width() 65 | self.ch = get_canvas_height() 66 | self.w = self.image.w 67 | self.h = self.image.h 68 | 69 | 70 | 71 | def draw(self): 72 | self.image.clip_draw_to_origin(self.q3l, self.q3b, self.q3w, self.q3h, 0, 0) # quadrant 3 73 | self.image.clip_draw_to_origin(self.q2l, self.q2b, self.q2w, self.q2h, 0, self.q3h) # quadrant 2 74 | self.image.clip_draw_to_origin(self.q4l, self.q4b, self.q4w, self.q4h, self.q3w, 0) # quadrant 4 75 | self.image.clip_draw_to_origin(self.q1l, self.q1b, self.q1w, self.q1h, self.q3w, self.q3h) # quadrant 1 76 | 77 | def update(self): 78 | 79 | # quadrant 3 80 | self.q3l = (int(server.boy.x) - self.cw // 2) % self.w 81 | self.q3b = (int(server.boy.y) - self.ch // 2) % self.h 82 | self.q3w = clamp(0, self.w - self.q3l, self.w) 83 | self.q3h = clamp(0, self.h - self.q3b, self.h) 84 | 85 | # quadrant 2 86 | self.q2l = 0 87 | self.q2b = 0 88 | self.q2w = 0 89 | self.q2h = 0 90 | 91 | # quadrand 4 92 | self.q4l = 0 93 | self.q4b = 0 94 | self.q4w = 0 95 | self.q4h = 0 96 | 97 | # quadrand 1 98 | self.q1l = 0 99 | self.q1b = 0 100 | self.q1w = 0 101 | self.q1h = 0 102 | 103 | 104 | def handle_event(self, event): 105 | pass 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/ball.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | import game_world 3 | import game_framework 4 | import random 5 | 6 | 7 | class Ball: 8 | image = None 9 | 10 | def __init__(self, x=None, y=None): 11 | if Ball.image == None: 12 | Ball.image = load_image('ball21x21.png') 13 | self.x = x if x else random.randint(100, 1180) 14 | self.y = y if y else random.randint(100, 924) 15 | 16 | def draw(self): 17 | self.image.draw(self.x, self.y) 18 | draw_rectangle(*self.get_bb()) 19 | 20 | def update(self): 21 | pass 22 | 23 | def get_bb(self): 24 | return self.x - 10, self.y - 10, self.x + 10, self.y + 10 25 | 26 | def handle_collision(self, group, other): 27 | pass 28 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/collision.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def collide(a, b): 4 | # fill here 5 | left_a, bottom_a, right_a, top_a = a.get_bb() 6 | left_b, bottom_b, right_b, top_b = b.get_bb() 7 | 8 | if left_a > right_b: return False 9 | if right_a < left_b: return False 10 | if top_a < bottom_b: return False 11 | if bottom_a > top_b: return False 12 | 13 | return True -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube00.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube01.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube02.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube10.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube11.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube12.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube20.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube21.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/cube22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/cube22.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/futsal_court.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture17_Scrolling/futsal_court.png -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def change_mode(mode): 5 | global stack 6 | if (len(stack) > 0): 7 | # execute the current mode's finish function 8 | stack[-1].finish() 9 | # remove the current mode 10 | stack.pop() 11 | stack.append(mode) 12 | mode.init() 13 | 14 | 15 | def push_mode(mode): 16 | global stack 17 | if (len(stack) > 0): 18 | stack[-1].pause() 19 | stack.append(mode) 20 | mode.init() 21 | 22 | 23 | def pop_mode(): 24 | global stack 25 | if (len(stack) > 0): 26 | # execute the current mode's finish function 27 | stack[-1].finish() 28 | # remove the current mode 29 | stack.pop() 30 | 31 | # execute resume function of the previous mode 32 | if (len(stack) > 0): 33 | stack[-1].resume() 34 | 35 | 36 | def quit(): 37 | global running 38 | running = False 39 | 40 | 41 | def run(start_mode): 42 | global running, stack 43 | running = True 44 | stack = [start_mode] 45 | start_mode.init() 46 | 47 | global frame_time 48 | frame_time = 0.0 49 | current_time = time.time() 50 | while running: 51 | stack[-1].handle_events() 52 | stack[-1].update() 53 | stack[-1].draw() 54 | frame_time = time.time() - current_time 55 | frame_rate = 1.0 / frame_time 56 | current_time += frame_time 57 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 58 | 59 | # repeatedly delete the top of the stack 60 | while (len(stack) > 0): 61 | stack[-1].finish() 62 | stack.pop() 63 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/game_world.py: -------------------------------------------------------------------------------- 1 | objects = [[] for _ in range(4)] 2 | collision_pairs = {} 3 | 4 | def add_object(o, depth = 0): 5 | objects[depth].append(o) 6 | 7 | def add_objects(ol, depth = 0): 8 | objects[depth] += ol 9 | 10 | 11 | def update(): 12 | for layer in objects: 13 | for o in layer: 14 | o.update() 15 | 16 | 17 | def render(): 18 | for layer in objects: 19 | for o in layer: 20 | o.draw() 21 | 22 | def remove_collision_object(o): 23 | for pairs in collision_pairs.values(): 24 | if o in pairs[0]: 25 | pairs[0].remove(o) 26 | if o in pairs[1]: 27 | pairs[1].remove(o) 28 | 29 | 30 | def remove_object(o): 31 | for layer in objects: 32 | if o in layer: 33 | layer.remove(o) 34 | remove_collision_object(o) 35 | del o 36 | return 37 | raise ValueError('Cannot delete non existing object') 38 | 39 | 40 | def clear(): 41 | for layer in objects: 42 | layer.clear() 43 | 44 | 45 | def collide(a, b): 46 | left_a, bottom_a, right_a, top_a = a.get_bb() 47 | left_b, bottom_b, right_b, top_b = b.get_bb() 48 | 49 | if left_a > right_b: return False 50 | if right_a < left_b: return False 51 | if top_a < bottom_b: return False 52 | if bottom_a > top_b: return False 53 | 54 | return True 55 | 56 | 57 | def add_collision_pair(group, a, b): 58 | if group not in collision_pairs: 59 | print(f'Added new group {group}') 60 | collision_pairs[group] = [ [], [] ] 61 | if a: 62 | collision_pairs[group][0].append(a) 63 | if b: 64 | collision_pairs[group][1].append(b) 65 | 66 | 67 | def handle_collisions(): 68 | collided_pairs = [] 69 | for group, pairs in collision_pairs.items(): 70 | for a in pairs[0]: 71 | for b in pairs[1]: 72 | if collide(a, b): 73 | collided_pairs.append((group, a, b)) 74 | for group, a, b in collided_pairs: 75 | a.handle_collision(group, b) 76 | b.handle_collision(group, a) 77 | 78 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/main.py: -------------------------------------------------------------------------------- 1 | 2 | from pico2d import open_canvas, delay, close_canvas 3 | import game_framework 4 | 5 | import play_mode as start_mode 6 | 7 | open_canvas(1000, 1000) 8 | game_framework.run(start_mode) 9 | close_canvas() 10 | 11 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | import json 3 | import os 4 | 5 | from pico2d import * 6 | import game_framework 7 | import game_world 8 | 9 | import server 10 | from boy import Boy 11 | 12 | # fill here 13 | 14 | 15 | 16 | 17 | def handle_events(): 18 | events = get_events() 19 | for event in events: 20 | if event.type == SDL_QUIT: 21 | game_framework.quit() 22 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 23 | game_framework.quit() 24 | else: 25 | server.boy.handle_event(event) 26 | 27 | 28 | 29 | def init(): 30 | # fill here 31 | pass 32 | 33 | def finish(): 34 | game_world.clear() 35 | pass 36 | 37 | 38 | def update(): 39 | game_world.update() 40 | game_world.handle_collisions() 41 | 42 | def draw(): 43 | clear_canvas() 44 | game_world.render() 45 | update_canvas() 46 | 47 | def pause(): 48 | pass 49 | 50 | def resume(): 51 | pass 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Labs/Lecture17_Scrolling/server.py: -------------------------------------------------------------------------------- 1 | # 영구 존속 객체에 대한 글로벌 공간 마련 2 | # 실행중 생성되거나, 사라지는 객체는 여기에 넣으면 안됨. 3 | 4 | boy = None 5 | background = None 6 | 7 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/TUK_GROUND.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/TUK_GROUND.png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/TUK_GROUND_FULL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/TUK_GROUND_FULL.png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/background.py: -------------------------------------------------------------------------------- 1 | import random 2 | import server 3 | 4 | from pico2d import * 5 | 6 | 7 | class FixedBackground: 8 | 9 | def __init__(self): 10 | self.image = load_image('TUK_GROUND_FULL.png') 11 | self.cw = get_canvas_width() 12 | self.ch = get_canvas_height() 13 | self.w = self.image.w 14 | self.h = self.image.h 15 | 16 | def __getstate__(self): 17 | state = dict() 18 | return state 19 | 20 | def __setstate__(self, state): 21 | self.__init__() 22 | 23 | 24 | def draw(self): 25 | self.image.clip_draw_to_origin(self.window_left, self.window_bottom, self.cw, self.ch, 0, 0) 26 | 27 | def update(self): 28 | self.window_left = clamp(0, int(server.boy.x) - self.cw // 2, self.w - self.cw - 1) 29 | self.window_bottom = clamp(0, int(server.boy.y) - self.ch // 2, self.h - self.ch - 1) 30 | 31 | def handle_event(self, event): 32 | pass 33 | 34 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/game.sav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/game.sav -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def change_mode(mode): 5 | global stack 6 | if (len(stack) > 0): 7 | # execute the current mode's finish function 8 | stack[-1].finish() 9 | # remove the current mode 10 | stack.pop() 11 | stack.append(mode) 12 | mode.init() 13 | 14 | 15 | def push_mode(mode): 16 | global stack 17 | if (len(stack) > 0): 18 | stack[-1].pause() 19 | stack.append(mode) 20 | mode.init() 21 | 22 | 23 | def pop_mode(): 24 | global stack 25 | if (len(stack) > 0): 26 | # execute the current mode's finish function 27 | stack[-1].finish() 28 | # remove the current mode 29 | stack.pop() 30 | 31 | # execute resume function of the previous mode 32 | if (len(stack) > 0): 33 | stack[-1].resume() 34 | 35 | 36 | def quit(): 37 | global running 38 | running = False 39 | 40 | 41 | def run(start_mode): 42 | global running, stack 43 | running = True 44 | stack = [start_mode] 45 | start_mode.init() 46 | 47 | global frame_time 48 | frame_time = 0.0 49 | current_time = time.time() 50 | while running: 51 | stack[-1].handle_events() 52 | stack[-1].update() 53 | stack[-1].draw() 54 | frame_time = time.time() - current_time 55 | frame_rate = 1.0 / frame_time 56 | current_time += frame_time 57 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 58 | 59 | # repeatedly delete the top of the stack 60 | while (len(stack) > 0): 61 | stack[-1].finish() 62 | stack.pop() 63 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/game_world.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | 3 | objects = [[] for _ in range(4)] 4 | collision_pairs = {} 5 | 6 | 7 | def add_object(o, depth=0): 8 | objects[depth].append(o) 9 | 10 | 11 | def add_objects(ol, depth=0): 12 | objects[depth] += ol 13 | 14 | 15 | def update(): 16 | for layer in objects: 17 | for o in layer: 18 | o.update() 19 | 20 | 21 | def render(): 22 | for layer in objects: 23 | for o in layer: 24 | o.draw() 25 | 26 | 27 | def remove_collision_object(o): 28 | for pairs in collision_pairs.values(): 29 | if o in pairs[0]: 30 | pairs[0].remove(o) 31 | if o in pairs[1]: 32 | pairs[1].remove(o) 33 | 34 | 35 | def remove_object(o): 36 | for layer in objects: 37 | if o in layer: 38 | layer.remove(o) 39 | remove_collision_object(o) 40 | del o 41 | return 42 | raise ValueError('Cannot delete non existing object') 43 | 44 | 45 | def clear(): 46 | global objects, collision_pairs 47 | 48 | objects = [[] for _ in range(4)] 49 | collision_pairs = {} 50 | 51 | 52 | def collide(a, b): 53 | left_a, bottom_a, right_a, top_a = a.get_bb() 54 | left_b, bottom_b, right_b, top_b = b.get_bb() 55 | 56 | if left_a > right_b: return False 57 | if right_a < left_b: return False 58 | if top_a < bottom_b: return False 59 | if bottom_a > top_b: return False 60 | 61 | return True 62 | 63 | 64 | def add_collision_pair(group, a, b): 65 | if group not in collision_pairs: 66 | print(f'Added new group {group}') 67 | collision_pairs[group] = [[], []] 68 | if a: 69 | collision_pairs[group][0].append(a) 70 | if b: 71 | collision_pairs[group][1].append(b) 72 | 73 | 74 | def handle_collisions(): 75 | collided_pairs = [] 76 | for group, pairs in collision_pairs.items(): 77 | for a in pairs[0]: 78 | for b in pairs[1]: 79 | if collide(a, b): 80 | collided_pairs.append((group, a, b)) 81 | for group, a, b in collided_pairs: 82 | a.handle_collision(group, b) 83 | b.handle_collision(group, a) 84 | 85 | 86 | def all_objects(): 87 | # fill here 88 | pass 89 | 90 | 91 | def save(): 92 | # fill here 93 | pass 94 | 95 | def load(): 96 | # fill here 97 | pass -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/hand_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/hand_arrow.png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/main.py: -------------------------------------------------------------------------------- 1 | 2 | from pico2d import open_canvas, delay, close_canvas 3 | import game_framework 4 | 5 | import menu_mode as start_mode 6 | 7 | open_canvas(1280, 720) 8 | game_framework.run(start_mode) 9 | close_canvas() 10 | 11 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/menu.png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/menu_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | import json 3 | import tomllib 4 | import pickle 5 | import os 6 | 7 | from pico2d import * 8 | import game_framework 9 | import game_world 10 | 11 | import server 12 | import play_mode 13 | 14 | from boy import Boy 15 | from zombie import Zombie 16 | from background import FixedBackground as Background 17 | 18 | 19 | def init(): 20 | global menu 21 | menu = load_image('menu.png') 22 | hide_cursor() 23 | hide_lattice() 24 | 25 | def finish(): 26 | global menu 27 | menu = None 28 | 29 | def pause(): 30 | pass 31 | 32 | def resume(): 33 | pass 34 | 35 | 36 | def create_new_world(): 37 | server.background = Background() 38 | game_world.add_object(server.background, 0) 39 | 40 | server.boy = Boy() 41 | game_world.add_object(server.boy, 1) 42 | 43 | # fill here 44 | 45 | 46 | def load_saved_world(): 47 | # fill here 48 | pass 49 | 50 | 51 | def handle_events(): 52 | events = get_events() 53 | for event in events: 54 | if event.type == SDL_QUIT: 55 | game_framework.quit() 56 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 57 | game_framework.quit() 58 | elif event.type == SDL_KEYDOWN and event.key == SDLK_n: 59 | create_new_world() 60 | game_framework.change_mode(play_mode) 61 | elif event.type == SDL_KEYDOWN and event.key == SDLK_l: 62 | load_saved_world() 63 | game_framework.change_mode(play_mode) 64 | 65 | def update(): 66 | pass 67 | 68 | def draw(): 69 | clear_canvas() 70 | menu.draw(get_canvas_width()//2, get_canvas_height()//2) 71 | update_canvas() 72 | 73 | 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | import json 3 | import tomllib 4 | import os 5 | 6 | from pico2d import * 7 | import game_framework 8 | import game_world 9 | 10 | import menu_mode 11 | import server 12 | from boy import Boy 13 | from zombie import Zombie 14 | 15 | from background import FixedBackground as Background 16 | 17 | import server 18 | 19 | 20 | def handle_events(): 21 | events = get_events() 22 | for event in events: 23 | if event.type == SDL_QUIT: 24 | game_framework.quit() 25 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 26 | game_framework.change_mode(menu_mode) 27 | elif event.type == SDL_KEYDOWN and event.key == SDLK_s: 28 | game_world.save() 29 | else: 30 | server.boy.handle_event(event) 31 | 32 | 33 | def init(): 34 | pass 35 | 36 | 37 | 38 | def finish(): 39 | server.background = None 40 | server.boy = None 41 | game_world.clear() 42 | pass 43 | 44 | 45 | def update(): 46 | game_world.update() 47 | game_world.handle_collisions() 48 | 49 | 50 | def draw(): 51 | clear_canvas() 52 | game_world.render() 53 | update_canvas() 54 | 55 | 56 | def pause(): 57 | pass 58 | 59 | 60 | def resume(): 61 | pass 62 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/server.py: -------------------------------------------------------------------------------- 1 | # 글로벌 변수 저장 2 | 3 | boy = None 4 | background = None -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (1).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (2).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (3).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (4).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (5).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (6).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (7).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Attack (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Attack (8).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (1).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (10).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (11).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (11).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (12).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (12).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (2).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (3).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (4).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (5).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (6).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (7).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (8).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Dead (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Dead (9).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (1).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (10).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (2).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (3).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (4).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (5).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (6).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (7).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (8).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Idle (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Idle (9).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (1).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (10).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (2).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (3).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (4).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (5).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (6).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (7).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (8).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie/Walk (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture18_Game_Data/zombie/Walk (9).png -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie_data.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"name": "Nayeon", "x": 3800, "y": 2560, "size" : 1.0}, 3 | {"name": "Momo" , "x": 4000, "y": 2560, "size" : 1.1}, 4 | {"name": "Sana" , "x": 4600, "y": 2560, "size" : 1.3}, 5 | {"name": "Mina" , "x": 4800, "y": 2560, "size" : 0.9}, 6 | {"name": "Zwi" , "x": 5000, "y": 2560, "size" : 1.4} 7 | ] 8 | 9 | -------------------------------------------------------------------------------- /Labs/Lecture18_Game_Data/zombie_data.toml: -------------------------------------------------------------------------------- 1 | zombies = [ 2 | {name= "Nayeon", x= 3800, y= 2560, size = 1.0}, 3 | {name= "Momo" , x= 4000, y= 2560, size = 1.1}, 4 | {name= "Sana" , x= 4600, y= 2560, size = 1.3}, 5 | {name= "Mina" , x= 4800, y= 2560, size = 0.9}, 6 | {name= "Zwi" , x= 5000, y= 2560, size = 1.4} 7 | ] 8 | 9 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/python,pycharm 3 | 4 | 5 | .idea/ 6 | 7 | ### Python ### 8 | # Byte-compiled / optimized / DLL files 9 | __pycache__/ 10 | *.py[cod] 11 | *$py.class 12 | 13 | # C extensions 14 | *.so 15 | 16 | # Distribution / packaging 17 | .Python 18 | env/ 19 | build/ 20 | develop-eggs/ 21 | dist/ 22 | downloads/ 23 | eggs/ 24 | .eggs/ 25 | lib/ 26 | lib64/ 27 | parts/ 28 | sdist/ 29 | var/ 30 | wheels/ 31 | *.egg-info/ 32 | .installed.cfg 33 | *.egg 34 | 35 | # PyInstaller 36 | # Usually these files are written by a python script from a template 37 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 38 | *.manifest 39 | *.spec 40 | 41 | # Installer logs 42 | pip-log.txt 43 | pip-delete-this-directory.txt 44 | 45 | # Unit test / coverage reports 46 | htmlcov/ 47 | .tox/ 48 | .coverage 49 | .coverage.* 50 | .cache 51 | nosetests.xml 52 | coverage.xml 53 | *,cover 54 | .hypothesis/ 55 | 56 | # Translations 57 | *.mo 58 | *.pot 59 | 60 | # Django stuff: 61 | *.log 62 | local_settings.py 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # pyenv 81 | .python-version 82 | 83 | # celery beat schedule file 84 | celerybeat-schedule 85 | 86 | # dotenv 87 | .env 88 | 89 | # virtualenv 90 | .venv/ 91 | venv/ 92 | ENV/ 93 | 94 | # Spyder project settings 95 | .spyderproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | 101 | ### PyCharm ### 102 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm 103 | # Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 104 | 105 | # User-specific stuff: 106 | .idea/workspace.xml 107 | .idea/tasks.xml 108 | 109 | # Sensitive or high-churn files: 110 | .idea/dataSources/ 111 | .idea/dataSources.ids 112 | .idea/dataSources.xml 113 | .idea/dataSources.local.xml 114 | .idea/sqlDataSources.xml 115 | .idea/dynamic.xml 116 | .idea/uiDesigner.xml 117 | 118 | # Gradle: 119 | .idea/gradle.xml 120 | .idea/libraries 121 | 122 | # Mongo Explorer plugin: 123 | .idea/mongoSettings.xml 124 | 125 | ## File-based project format: 126 | *.iws 127 | 128 | ## Plugin-specific files: 129 | 130 | # IntelliJ 131 | /out/ 132 | 133 | # mpeltonen/sbt-idea plugin 134 | .idea_modules/ 135 | 136 | # JIRA plugin 137 | atlassian-ide-plugin.xml 138 | 139 | # Crashlytics plugin (for Android Studio and IntelliJ) 140 | com_crashlytics_export_strings.xml 141 | crashlytics.properties 142 | crashlytics-build.properties 143 | fabric.properties 144 | 145 | ### PyCharm Patch ### 146 | # Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 147 | 148 | # *.iml 149 | # modules.xml 150 | # .idea/misc.xml 151 | # *.ipr 152 | 153 | # End of https://www.gitignore.io/api/python,pycharm -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/ENCR10B.TTF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/ENCR10B.TTF -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/TUK_GROUND_FULL.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/TUK_GROUND_FULL.png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/animation_sheet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/animation_sheet.png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/background.py: -------------------------------------------------------------------------------- 1 | import random 2 | import server 3 | 4 | from pico2d import * 5 | 6 | 7 | class FixedBackground: 8 | 9 | def __init__(self): 10 | self.image = load_image('TUK_GROUND_FULL.png') 11 | self.cw = get_canvas_width() 12 | self.ch = get_canvas_height() 13 | self.w = self.image.w 14 | self.h = self.image.h 15 | # fill here 16 | 17 | 18 | def draw(self): 19 | self.image.clip_draw_to_origin(self.window_left, self.window_bottom, self.cw, self.ch, 0, 0) 20 | 21 | def update(self): 22 | self.window_left = clamp(0, int(server.boy.x) - self.cw // 2, self.w - self.cw - 1) 23 | self.window_bottom = clamp(0, int(server.boy.y) - self.ch // 2, self.h - self.ch - 1) 24 | 25 | def handle_event(self, event): 26 | pass 27 | 28 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/ball.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | from pico2d import * 4 | import game_world 5 | 6 | import server 7 | 8 | class Ball: 9 | image = None 10 | zombie_eat_sound = None 11 | boy_eat_sound = None 12 | 13 | def __init__(self, x = None, y = None): 14 | if Ball.image == None: 15 | Ball.image = load_image('ball21x21.png') 16 | self.x = x if x else random.randint(100, server.background.w - 100) 17 | self.y = y if y else random.randint(100, server.background.h - 100) 18 | 19 | # fill here 20 | 21 | def draw(self): 22 | self.image.draw(self.x - server.background.window_left, self.y - server.background.window_bottom) 23 | 24 | def update(self): 25 | pass 26 | 27 | def get_bb(self): 28 | return self.x - 10, self.y - 10, self.x + 10, self.y + 10 29 | 30 | def handle_collision(self, group, other): 31 | match group: 32 | case 'boy:ball': 33 | # fill here 34 | game_world.remove_object(self) 35 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/ball21x21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/ball21x21.png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/football.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/football.mp3 -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/game_framework.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | 4 | def change_mode(mode): 5 | global stack 6 | if (len(stack) > 0): 7 | # execute the current mode's finish function 8 | stack[-1].finish() 9 | # remove the current mode 10 | stack.pop() 11 | stack.append(mode) 12 | mode.init() 13 | 14 | 15 | def push_mode(mode): 16 | global stack 17 | if (len(stack) > 0): 18 | stack[-1].pause() 19 | stack.append(mode) 20 | mode.init() 21 | 22 | 23 | def pop_mode(): 24 | global stack 25 | if (len(stack) > 0): 26 | # execute the current mode's finish function 27 | stack[-1].finish() 28 | # remove the current mode 29 | stack.pop() 30 | 31 | # execute resume function of the previous mode 32 | if (len(stack) > 0): 33 | stack[-1].resume() 34 | 35 | 36 | def quit(): 37 | global running 38 | running = False 39 | 40 | 41 | def run(start_mode): 42 | global running, stack 43 | running = True 44 | stack = [start_mode] 45 | start_mode.init() 46 | 47 | global frame_time 48 | frame_time = 0.0 49 | current_time = time.time() 50 | while running: 51 | stack[-1].handle_events() 52 | stack[-1].update() 53 | stack[-1].draw() 54 | frame_time = time.time() - current_time 55 | frame_rate = 1.0 / frame_time 56 | current_time += frame_time 57 | # print(f'Frame Time: {frame_time}, Frame Rate: {frame_rate}') 58 | 59 | # repeatedly delete the top of the stack 60 | while (len(stack) > 0): 61 | stack[-1].finish() 62 | stack.pop() 63 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/game_world.py: -------------------------------------------------------------------------------- 1 | import pickle 2 | 3 | objects = [[] for _ in range(4)] 4 | collision_pairs = {} 5 | 6 | 7 | def add_object(o, depth=0): 8 | objects[depth].append(o) 9 | 10 | 11 | def add_objects(ol, depth=0): 12 | objects[depth] += ol 13 | 14 | 15 | def update(): 16 | for layer in objects: 17 | for o in layer: 18 | o.update() 19 | 20 | 21 | def render(): 22 | for layer in objects: 23 | for o in layer: 24 | o.draw() 25 | 26 | 27 | def remove_collision_object(o): 28 | for pairs in collision_pairs.values(): 29 | if o in pairs[0]: 30 | pairs[0].remove(o) 31 | if o in pairs[1]: 32 | pairs[1].remove(o) 33 | 34 | 35 | def remove_object(o): 36 | for layer in objects: 37 | if o in layer: 38 | layer.remove(o) 39 | remove_collision_object(o) 40 | del o 41 | return 42 | raise ValueError('Cannot delete non existing object') 43 | 44 | 45 | def clear(): 46 | for layer in objects: 47 | layer.clear() 48 | 49 | 50 | def collide(a, b): 51 | left_a, bottom_a, right_a, top_a = a.get_bb() 52 | left_b, bottom_b, right_b, top_b = b.get_bb() 53 | 54 | if left_a > right_b: return False 55 | if right_a < left_b: return False 56 | if top_a < bottom_b: return False 57 | if bottom_a > top_b: return False 58 | 59 | return True 60 | 61 | 62 | def add_collision_pair(group, a, b): 63 | if group not in collision_pairs: 64 | # print(f'Added new group {group}') 65 | collision_pairs[group] = [[], []] 66 | if a: 67 | collision_pairs[group][0].append(a) 68 | if b: 69 | collision_pairs[group][1].append(b) 70 | 71 | 72 | def handle_collisions(): 73 | collided_pairs = [] 74 | for group, pairs in collision_pairs.items(): 75 | for a in pairs[0]: 76 | for b in pairs[1]: 77 | if collide(a, b): 78 | collided_pairs.append((group, a, b)) 79 | for group, a, b in collided_pairs: 80 | a.handle_collision(group, b) 81 | b.handle_collision(group, a) 82 | 83 | 84 | def all_objects(): 85 | for layer in objects: 86 | for o in layer: 87 | yield o 88 | 89 | 90 | def save(): 91 | game = [objects, collision_pairs] 92 | with open('game.sav', 'wb') as f: 93 | pickle.dump(game, f) 94 | 95 | 96 | def load(): 97 | global objects, collision_pairs 98 | with open('game.sav', 'rb') as f: 99 | game = pickle.load(f) 100 | objects, collision_pairs = game[0], game[1] 101 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/main.py: -------------------------------------------------------------------------------- 1 | 2 | from pico2d import open_canvas, delay, close_canvas 3 | import game_framework 4 | 5 | import play_mode as start_mode 6 | 7 | open_canvas(1280, 720) 8 | game_framework.run(start_mode) 9 | close_canvas() 10 | 11 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/pickup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/pickup.wav -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/play_mode.py: -------------------------------------------------------------------------------- 1 | import random 2 | import json 3 | import tomllib 4 | import os 5 | 6 | from pico2d import * 7 | import game_framework 8 | import game_world 9 | 10 | import server 11 | from boy import Boy 12 | from ball import Ball 13 | from zombie import Zombie 14 | 15 | # fill here 16 | from background import FixedBackground as Background 17 | # from background import TileBackground as Background 18 | # from background import InfiniteBackground as Background 19 | 20 | import server 21 | 22 | 23 | def handle_events(): 24 | events = get_events() 25 | for event in events: 26 | if event.type == SDL_QUIT: 27 | game_framework.quit() 28 | elif event.type == SDL_KEYDOWN and event.key == SDLK_ESCAPE: 29 | game_framework.quit() 30 | else: 31 | server.boy.handle_event(event) 32 | 33 | 34 | def init(): 35 | 36 | hide_cursor() 37 | 38 | server.background = Background() 39 | game_world.add_object(server.background, 0) 40 | 41 | server.boy = Boy() 42 | game_world.add_object(server.boy, 1) 43 | game_world.add_collision_pair('boy:ball', server.boy, None) 44 | 45 | for _ in range(20): 46 | zombie = Zombie() 47 | game_world.add_object(zombie) 48 | game_world.add_collision_pair('zombie:ball', zombie, None) 49 | 50 | for _ in range(200): 51 | ball = Ball() 52 | game_world.add_object(ball, 1) 53 | game_world.add_collision_pair('boy:ball', None, ball) 54 | game_world.add_collision_pair('zombie:ball', None, ball) 55 | 56 | 57 | def finish(): 58 | game_world.clear() 59 | pass 60 | 61 | 62 | def update(): 63 | game_world.update() 64 | game_world.handle_collisions() 65 | 66 | 67 | def draw(): 68 | clear_canvas() 69 | game_world.render() 70 | update_canvas() 71 | 72 | 73 | def pause(): 74 | pass 75 | 76 | 77 | def resume(): 78 | pass 79 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/pyinstaller_settings.toml: -------------------------------------------------------------------------------- 1 | # 메인 파일 이름을 지정하세요. 2 | main_file = # fill here 3 | 4 | # 데이타 파일들을 지정하세요. 5 | data_files = [ 6 | # fill here 7 | ] 8 | 9 | # 데이타가 들어있는 폴더들을 지정하세요. 10 | data_folders = [ 11 | # fill here 12 | ] 13 | 14 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/run_pyinstaller.py: -------------------------------------------------------------------------------- 1 | import os 2 | import shutil 3 | import tomllib 4 | import PyInstaller.__main__ 5 | import importlib 6 | 7 | def get_module_installation_path(module_name): 8 | try: 9 | module_spec = importlib.util.find_spec(module_name) 10 | if module_spec is not None: 11 | return os.path.dirname(os.path.abspath(module_spec.origin)) 12 | except ImportError: 13 | pass 14 | 15 | return None 16 | 17 | 18 | 19 | print(' py to exe with PyInstaller '.center(80, '=')) 20 | 21 | settings_file = 'pyinstaller_settings.toml' 22 | print(f'1. 설정 파일 {settings_file} 을 분석합니다......') 23 | try: 24 | f = open(settings_file, 'rb') 25 | config = tomllib.load(f) 26 | main_file = config['main_file'] 27 | data_files = config['data_files'] 28 | data_folders = config['data_folders'] 29 | except: 30 | print(f'설정 파일 {settings_file} 파일을 읽는 과정에서 문제가 발생했습니다. 파일 존재 및 이상 여부를 확인하세요. 변환을 중단합니다.') 31 | exit(-1) 32 | 33 | 34 | # 설정된 파일들이 실제 존재하는지 체크 35 | 36 | print(f'메인 소스 파일: {main_file}') 37 | print(f'데이터 파일: {data_files}') 38 | print(f'데이터 폴더: {data_folders}') 39 | 40 | if not os.path.exists(main_file): 41 | print(f'메인 파일 {main_file}이 존재하지 않습니다. 변환을 중단합니다.') 42 | exit(-1) 43 | 44 | for fn in data_files: 45 | if not os.path.exists(fn): 46 | print(f'데이터 파일 {fn}이 존재하지 않습니다. 변환을 중단합니다.') 47 | exit(-1) 48 | 49 | for dn in data_folders: 50 | if not os.path.exists(dn): 51 | print(f'데이터 폴더 {dn}이 존재하지 않습니다. 변환을 중단합니다.') 52 | exit(-1) 53 | 54 | print('2. 변환 중입니다......') 55 | dist_path = os.path.expanduser('~') + '/Documents/pyinstaller/dist' 56 | work_path = os.path.expanduser('~') + '/Documents/pyinstaller/build' 57 | 58 | # dist_path = dist_path.replace('\\', '/') 59 | # work_path = work_path.replace('\\', '/') 60 | 61 | 62 | PyInstaller.__main__.run([ 63 | main_file, 64 | '--clean', 65 | '--noconfirm', 66 | '--log-level=ERROR', 67 | '--python-option=O', 68 | f'--distpath={dist_path}', 69 | f'--workpath={work_path}', 70 | '--noconsole' 71 | ]) 72 | 73 | print('3. 관련 파일들을 복사합니다......') 74 | 75 | # sdl dll 파일들을 찾아서, pico2d 폴더로 복사 76 | sdl2dll_path = get_module_installation_path('sdl2dll')+'/dll' 77 | main_name = os.path.splitext(main_file)[0] 78 | dist_path += f'/{main_name}' 79 | shutil.copytree(sdl2dll_path, dist_path + '/pico2d') 80 | print(f'Pico2d 복사: {sdl2dll_path} -----> {dist_path + "/pico2d"}') 81 | for fn in data_files: 82 | shutil.copy(fn, dist_path) 83 | print(f'데이터 파일 복사: {fn} -----> {dist_path}') 84 | 85 | for dn in data_folders: 86 | shutil.copytree(dn, f'{dist_path}/{dn}') 87 | print(f'데이터 폴더 복사: {dn} -----> {dist_path}/{dn}') 88 | 89 | 90 | print('4. 변환이 완료됐습니다......') 91 | print(f'출력 폴더: File "{dist_path}", line {0}') 92 | 93 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/server.py: -------------------------------------------------------------------------------- 1 | # 글로벌 변수 저장 2 | 3 | boy = None 4 | background = None -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie.py: -------------------------------------------------------------------------------- 1 | from pico2d import * 2 | 3 | import random 4 | import math 5 | import game_framework 6 | import game_world 7 | from behavior_tree import BehaviorTree, Action, Sequence, Condition, Selector 8 | import play_mode 9 | 10 | import server 11 | 12 | # zombie Run Speed 13 | PIXEL_PER_METER = (10.0 / 0.3) # 10 pixel 30 cm 14 | RUN_SPEED_KMPH = 10.0 # Km / Hour 15 | RUN_SPEED_MPM = (RUN_SPEED_KMPH * 1000.0 / 60.0) 16 | RUN_SPEED_MPS = (RUN_SPEED_MPM / 60.0) 17 | RUN_SPEED_PPS = (RUN_SPEED_MPS * PIXEL_PER_METER) 18 | 19 | # zombie Action Speed 20 | TIME_PER_ACTION = 0.5 21 | ACTION_PER_TIME = 1.0 / TIME_PER_ACTION 22 | FRAMES_PER_ACTION = 10.0 23 | 24 | animation_names = ['Walk', 'Idle'] 25 | 26 | 27 | class Zombie: 28 | images = None 29 | 30 | def load_images(self): 31 | if Zombie.images == None: 32 | Zombie.images = {} 33 | for name in animation_names: 34 | Zombie.images[name] = [load_image("./zombie/" + name + " (%d)" % i + ".png") for i in range(1, 11)] 35 | Zombie.font = load_font('ENCR10B.TTF', 30) 36 | 37 | 38 | def __init__(self): 39 | self.x = random.randint(100, server.background.w - 100) 40 | self.y = random.randint(100, server.background.h - 100) 41 | self.size = clamp(0.7, random.random() * 2, 1.3) 42 | self.load_images() 43 | self.dir = 0.0 # radian 값으로 방향을 표시 44 | self.speed = 0.0 45 | self.frame = random.randint(0, 9) 46 | self.state = 'Idle' 47 | 48 | self.tx, self.ty = 0, 0 49 | self.build_behavior_tree() 50 | 51 | def get_bb(self): 52 | return self.x - 50*self.size, self.y - 50*self.size, self.x + 50*self.size, self.y + 50*self.size 53 | 54 | 55 | def update(self): 56 | self.frame = (self.frame + FRAMES_PER_ACTION * ACTION_PER_TIME * game_framework.frame_time) % FRAMES_PER_ACTION 57 | self.bt.run() 58 | 59 | 60 | def draw(self): 61 | sx, sy = self.x - server.background.window_left, self.y - server.background.window_bottom 62 | if math.cos(self.dir) < 0: 63 | Zombie.images[self.state][int(self.frame)].composite_draw(0, 'h', sx, sy, 100*self.size, 100*self.size) 64 | else: 65 | Zombie.images[self.state][int(self.frame)].draw(sx, sy, 100*self.size, 100*self.size) 66 | 67 | x1,y1,x2,y2 = self.get_bb() 68 | draw_rectangle(x1-server.background.window_left,y1-server.background.window_bottom, 69 | x2-server.background.window_left,y2-server.background.window_bottom) 70 | 71 | 72 | def handle_event(self, event): 73 | pass 74 | 75 | def handle_collision(self, group, other): 76 | pass 77 | 78 | def set_target_location(self, x=None, y=None): 79 | if not x or not y: 80 | raise ValueError('Location should be given') 81 | self.tx, self.ty = x, y 82 | return BehaviorTree.SUCCESS 83 | 84 | 85 | def distance_less_than(self, x1, y1, x2, y2, r): 86 | distance2 = (x1 - x2) ** 2 + (y1 - y2) ** 2 87 | return distance2 < (PIXEL_PER_METER * r) ** 2 88 | 89 | def move_slightly_to(self, tx, ty): 90 | self.dir = math.atan2(ty - self.y, tx - self.x) 91 | self.speed = RUN_SPEED_PPS 92 | self.x += self.speed * math.cos(self.dir) * game_framework.frame_time 93 | self.y += self.speed * math.sin(self.dir) * game_framework.frame_time 94 | 95 | def move_to(self, r=0.5): 96 | self.state = 'Walk' 97 | self.move_slightly_to(self.tx, self.ty) 98 | if self.distance_less_than(self.tx, self.ty, self.x, self.y, r): 99 | return BehaviorTree.SUCCESS 100 | else: 101 | return BehaviorTree.RUNNING 102 | 103 | def set_random_location(self): 104 | # select random location around boy 105 | self.tx = random.randint(int(server.boy.x) - 600, int(server.boy.x) + 600) 106 | self.ty = random.randint(int(server.boy.y) - 400, int(server.boy.y) + 400) 107 | return BehaviorTree.SUCCESS 108 | 109 | 110 | 111 | def build_behavior_tree(self): 112 | a1 = Action('Set random location', self.set_random_location) 113 | a2 = Action('Move to', self.move_to) 114 | root = SEQ_wander = Sequence('Wander', a1, a2) 115 | self.bt = BehaviorTree(root) 116 | -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (1).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (10).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (2).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (3).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (4).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (5).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (6).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (7).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (8).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Idle (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Idle (9).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (1).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (10).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (10).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (2).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (3).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (4).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (5).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (6).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (7).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (8).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie/Walk (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie/Walk (9).png -------------------------------------------------------------------------------- /Labs/Lecture19_Sound_Packaging/zombie_pickup.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Labs/Lecture19_Sound_Packaging/zombie_pickup.wav -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 2DGP 2 | 2023 2D Game Programming Course @ Tech. Univ of Korea 3 | -------------------------------------------------------------------------------- /Slides/LEC00_과목소개.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC00_과목소개.pdf -------------------------------------------------------------------------------- /Slides/LEC01_파이썬기초(1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC01_파이썬기초(1).pdf -------------------------------------------------------------------------------- /Slides/LEC02_파이썬기초(2).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC02_파이썬기초(2).pdf -------------------------------------------------------------------------------- /Slides/LEC03_파이썬기초(3).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC03_파이썬기초(3).pdf -------------------------------------------------------------------------------- /Slides/LEC04_2D렌더링.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC04_2D렌더링.pdf -------------------------------------------------------------------------------- /Slides/LEC05_애니메이션.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC05_애니메이션.pdf -------------------------------------------------------------------------------- /Slides/LEC06_입력처리.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC06_입력처리.pdf -------------------------------------------------------------------------------- /Slides/LEC07_직선이동.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC07_직선이동.pdf -------------------------------------------------------------------------------- /Slides/LEC09_게임오브젝트.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC09_게임오브젝트.pdf -------------------------------------------------------------------------------- /Slides/LEC10_캐릭터컨트롤러 (1).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC10_캐릭터컨트롤러 (1).pdf -------------------------------------------------------------------------------- /Slides/LEC11_캐릭터컨트롤러 (2).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC11_캐릭터컨트롤러 (2).pdf -------------------------------------------------------------------------------- /Slides/LEC12_게임월드.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC12_게임월드.pdf -------------------------------------------------------------------------------- /Slides/LEC13_게임프레임웍.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC13_게임프레임웍.pdf -------------------------------------------------------------------------------- /Slides/LEC14_시간.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC14_시간.pdf -------------------------------------------------------------------------------- /Slides/LEC15_충돌처리.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC15_충돌처리.pdf -------------------------------------------------------------------------------- /Slides/LEC16_인공지능.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC16_인공지능.pdf -------------------------------------------------------------------------------- /Slides/LEC17_스크롤링.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC17_스크롤링.pdf -------------------------------------------------------------------------------- /Slides/LEC18_게임데이터.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC18_게임데이터.pdf -------------------------------------------------------------------------------- /Slides/LEC19_사운드 및 패키징.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC19_사운드 및 패키징.pdf -------------------------------------------------------------------------------- /Slides/LEC20_정리.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/game-lecture/2023-2DGP/91b60145a8ab8aa0275c38ecc390bc9dc41aa646/Slides/LEC20_정리.pdf -------------------------------------------------------------------------------- /pull.bat: -------------------------------------------------------------------------------- 1 | git.exe pull --progress -v --no-rebase "origin" 2 | pause 3 | -------------------------------------------------------------------------------- /push.bat: -------------------------------------------------------------------------------- 1 | git.exe add . 2 | git.exe commit -m 'sync' 3 | git.exe push --progress "origin" main:main 4 | pause 5 | --------------------------------------------------------------------------------