diff --git a/README-ko.md b/README-ko.md new file mode 100644 index 0000000..6db287c --- /dev/null +++ b/README-ko.md @@ -0,0 +1,29 @@ +# PythonPlantsVsZombies + 간단한 Plants Vs Zombies 게임입니다.
+ `이 게임은 개인적인 학습과 비상업적인 사용을 위한 것입니다. 만약 이 게임이 저작권을 침해한다면 저에게 알려주세요.` +* 구현된 식물: 해바라기, 콩슈터, 호두, 얼음 완두콩, 체리 폭탄, 삼발슈터, 먹개비, 퍼프 버섯, 감자 지뢰, 스파이크 위드, 겁쟁이 버섯, 스쿼시, 겁쟁이 버섯, 할라페뇨, 태양 버섯, 얼음 버섯, 최면 버섯. +* 구현된 좀비: 좀비, 깃발 좀비, 콘헤드 좀비, 양동이 좀비, 신문 좀비. +* json 파일을 사용하여 레벨 데이터(예: 좀비들의 위치 및 시간, 배경 정보 등)를 저장합니다. +* 맨 처음 스테이지 시작 전 식물 카드를 선택할 수 있게 지원합니다. +* 낮 스테이지, 밤 스테이지, 움직이는 카드 선택 스테이지, 호두 볼링 스테이지를 지원합니다. + +# 요구 사항 +* Python 3.7 +* 참고: Python 3.7이 권장되지만, 필수는 아닙니다. Linux의 경우, 이미 Python 3 이상이 설치되어 있다면 이 게임을 실행해도 좋습니다. Python 3.7로 직접 업데이트를 하면 Linux Mint가 손상될 수 있습니다. +* Python-Pygame 1.9 + +# 게임 시작 방법 +$ python main.py + +# 게임 방법 +* 마우스를 사용하여 태양을 모으고, 식물 카드를 선택한 후 식물을 심습니다. +* source/constant.py 파일의 START_LEVEL_NUM 값을 변경하여 시작 스테이지를 설정할 수 있습니다. + * 스테이지 1과 2: 낮 스테이지 + * 스테이지 3: 밤 스테이지 + * 스테이지 4: 움직이는 카드 선택 스테이지 + * 스테이지 5: 호두 볼링 스테이지 + +# 데모 +![demo1](https://raw.githubusercontent.com/marblexu/PythonPlantsVsZombies/master/demo/demo1.jpg) +![demo2](https://raw.githubusercontent.com/marblexu/PythonPlantsVsZombies/master/demo/demo2.jpg) + diff --git a/resources/graphics/Screen/Adventure_0.png b/resources/graphics/Screen/Adventure_0.png index 78c12fc..afc4779 100644 Binary files a/resources/graphics/Screen/Adventure_0.png and b/resources/graphics/Screen/Adventure_0.png differ diff --git a/resources/graphics/Screen/Adventure_1.png b/resources/graphics/Screen/Adventure_1.png index f2825cb..03ee4c2 100644 Binary files a/resources/graphics/Screen/Adventure_1.png and b/resources/graphics/Screen/Adventure_1.png differ diff --git a/resources/graphics/Screen/Boom.png b/resources/graphics/Screen/Boom.png index 5ac54a4..e572f89 100644 Binary files a/resources/graphics/Screen/Boom.png and b/resources/graphics/Screen/Boom.png differ diff --git a/resources/graphics/Screen/GameLoose.png b/resources/graphics/Screen/GameLoose.png index 2ed83f1..e317f99 100644 Binary files a/resources/graphics/Screen/GameLoose.png and b/resources/graphics/Screen/GameLoose.png differ diff --git a/resources/graphics/Screen/GameVictory.png b/resources/graphics/Screen/GameVictory.png index 978d292..ee3a2a2 100644 Binary files a/resources/graphics/Screen/GameVictory.png and b/resources/graphics/Screen/GameVictory.png differ diff --git a/resources/graphics/Screen/PanelBackground.png b/resources/graphics/Screen/PanelBackground.png index 56fbb93..ee82e7c 100644 Binary files a/resources/graphics/Screen/PanelBackground.png and b/resources/graphics/Screen/PanelBackground.png differ diff --git a/resources/graphics/Screen/StartButton.png b/resources/graphics/Screen/StartButton.png index 29268ca..be9f587 100644 Binary files a/resources/graphics/Screen/StartButton.png and b/resources/graphics/Screen/StartButton.png differ diff --git a/resources/sound effects/Cherry bomb.wav b/resources/sound effects/Cherry bomb.wav new file mode 100644 index 0000000..ca399e3 Binary files /dev/null and b/resources/sound effects/Cherry bomb.wav differ diff --git a/resources/sound effects/opening.wav b/resources/sound effects/opening.wav new file mode 100644 index 0000000..b149836 Binary files /dev/null and b/resources/sound effects/opening.wav differ diff --git a/resources/sound effects/peashooter.wav b/resources/sound effects/peashooter.wav new file mode 100644 index 0000000..b9fae21 Binary files /dev/null and b/resources/sound effects/peashooter.wav differ diff --git a/resources/sound effects/sun.wav b/resources/sound effects/sun.wav new file mode 100644 index 0000000..c0250fb Binary files /dev/null and b/resources/sound effects/sun.wav differ diff --git a/source/__pycache__/__init__.cpython-37.pyc b/source/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..a008655 Binary files /dev/null and b/source/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/__pycache__/constants.cpython-37.pyc b/source/__pycache__/constants.cpython-37.pyc new file mode 100644 index 0000000..f829c8d Binary files /dev/null and b/source/__pycache__/constants.cpython-37.pyc differ diff --git a/source/__pycache__/main.cpython-37.pyc b/source/__pycache__/main.cpython-37.pyc new file mode 100644 index 0000000..4c79bb3 Binary files /dev/null and b/source/__pycache__/main.cpython-37.pyc differ diff --git a/source/__pycache__/tool.cpython-37.pyc b/source/__pycache__/tool.cpython-37.pyc new file mode 100644 index 0000000..4805836 Binary files /dev/null and b/source/__pycache__/tool.cpython-37.pyc differ diff --git a/source/component/__pycache__/__init__.cpython-37.pyc b/source/component/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..3cbe5d2 Binary files /dev/null and b/source/component/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/component/__pycache__/map.cpython-37.pyc b/source/component/__pycache__/map.cpython-37.pyc new file mode 100644 index 0000000..dc718ed Binary files /dev/null and b/source/component/__pycache__/map.cpython-37.pyc differ diff --git a/source/component/__pycache__/menubar.cpython-37.pyc b/source/component/__pycache__/menubar.cpython-37.pyc new file mode 100644 index 0000000..343e2cf Binary files /dev/null and b/source/component/__pycache__/menubar.cpython-37.pyc differ diff --git a/source/component/__pycache__/plant.cpython-37.pyc b/source/component/__pycache__/plant.cpython-37.pyc new file mode 100644 index 0000000..a2292ce Binary files /dev/null and b/source/component/__pycache__/plant.cpython-37.pyc differ diff --git a/source/component/__pycache__/zombie.cpython-37.pyc b/source/component/__pycache__/zombie.cpython-37.pyc new file mode 100644 index 0000000..fbf3f67 Binary files /dev/null and b/source/component/__pycache__/zombie.cpython-37.pyc differ diff --git a/source/component/plant.py b/source/component/plant.py index 684065b..5af14a9 100644 --- a/source/component/plant.py +++ b/source/component/plant.py @@ -49,7 +49,7 @@ def __init__(self, x, start_y, dest_y, name, damage, ice): self.rect.y = start_y self.dest_y = dest_y self.y_vel = 4 if (dest_y > start_y) else -4 - self.x_vel = 4 + self.x_vel = 4 # 총알 날라가는 속도 self.damage = damage self.ice = ice self.state = c.FLY @@ -272,12 +272,15 @@ class PeaShooter(Plant): def __init__(self, x, y, bullet_group): Plant.__init__(self, x, y, c.PEASHOOTER, c.PLANT_HEALTH, bullet_group) self.shoot_timer = 0 + self.shoot_sound = pg.mixer.Sound("./resources/sound effects/peashooter.wav") # 음향 객체 정의 def attacking(self): + # 총알 날라가는 간격 (텀) if (self.current_time - self.shoot_timer) > 2000: self.bullet_group.add(Bullet(self.rect.right, self.rect.y, self.rect.y, c.BULLET_PEA, c.BULLET_DAMAGE_NORMAL, False)) self.shoot_timer = self.current_time + self.shoot_sound.play() class RepeaterPea(Plant): def __init__(self, x, y, bullet_group): diff --git a/source/main.py b/source/main.py index 92fcdc1..c2eceb2 100644 --- a/source/main.py +++ b/source/main.py @@ -4,6 +4,7 @@ from . import constants as c from .state import mainmenu, screen, level +# 처음 시작할 때 호출 def main(): game = tool.Control() state_dict = {c.MAIN_MENU: mainmenu.Menu(), @@ -11,4 +12,4 @@ def main(): c.GAME_LOSE: screen.GameLoseScreen(), c.LEVEL: level.Level()} game.setup_states(state_dict, c.MAIN_MENU) - game.main() \ No newline at end of file + game.main() # pygame 화면 재생 부분 (루프) \ No newline at end of file diff --git a/source/state/__pycache__/__init__.cpython-37.pyc b/source/state/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000..a4caf03 Binary files /dev/null and b/source/state/__pycache__/__init__.cpython-37.pyc differ diff --git a/source/state/__pycache__/level.cpython-37.pyc b/source/state/__pycache__/level.cpython-37.pyc new file mode 100644 index 0000000..77fbbaa Binary files /dev/null and b/source/state/__pycache__/level.cpython-37.pyc differ diff --git a/source/state/__pycache__/mainmenu.cpython-37.pyc b/source/state/__pycache__/mainmenu.cpython-37.pyc new file mode 100644 index 0000000..a14f1af Binary files /dev/null and b/source/state/__pycache__/mainmenu.cpython-37.pyc differ diff --git a/source/state/__pycache__/screen.cpython-37.pyc b/source/state/__pycache__/screen.cpython-37.pyc new file mode 100644 index 0000000..20e36eb Binary files /dev/null and b/source/state/__pycache__/screen.cpython-37.pyc differ diff --git a/source/state/mainmenu.py b/source/state/mainmenu.py index 6ac345f..213adc5 100644 --- a/source/state/mainmenu.py +++ b/source/state/mainmenu.py @@ -4,6 +4,9 @@ from .. import tool from .. import constants as c + +# 게임 처음 들어가고 난 뒤에 나오는 메뉴 +# 각종 이미지, 스프라이트 정의 class Menu(tool.State): def __init__(self): tool.State.__init__(self) @@ -13,11 +16,14 @@ def startup(self, current_time, persist): self.persist = persist self.game_info = persist + # 뒷배경과 설정 표시 self.setupBackground() self.setupOption() def setupBackground(self): frame_rect = [80, 0, 800, 600] + # 메뉴 이미지 + # 상수 MAIN_MENU_IMAGE self.bg_image = tool.get_image(tool.GFX[c.MAIN_MENU_IMAGE], *frame_rect) self.bg_rect = self.bg_image.get_rect() self.bg_rect.x = 0 diff --git a/source/tool.py b/source/tool.py index 1a319c8..02915bb 100644 --- a/source/tool.py +++ b/source/tool.py @@ -26,7 +26,9 @@ def cleanup(self): def update(self, surface, keys, current_time): '''abstract method''' +# pygame 관련 기능, 속성들이 정의됨 (화면재생률, 클릭 상태, 게임 정보 등) class Control(): + # 객체 생성 시 초기화되는 부분 def __init__(self): self.screen = pg.display.get_surface() self.done = False @@ -167,6 +169,8 @@ def loadPlantImageRect(): f.close() return data[c.PLANT_IMAGE_RECT] +# source/main.py에서 import하면서 바로 초기화, 실행됨 +# pygame 라이브러리의 윈도우 폼 생성되는 곳 pg.init() pg.display.set_caption(c.ORIGINAL_CAPTION) SCREEN = pg.display.set_mode(c.SCREEN_SIZE)