Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taeyoung #43

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions README-ko.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# PythonPlantsVsZombies
간단한 Plants Vs Zombies 게임입니다. <br>
`이 게임은 개인적인 학습과 비상업적인 사용을 위한 것입니다. 만약 이 게임이 저작권을 침해한다면 저에게 알려주세요.`
* 구현된 식물: 해바라기, 콩슈터, 호두, 얼음 완두콩, 체리 폭탄, 삼발슈터, 먹개비, 퍼프 버섯, 감자 지뢰, 스파이크 위드, 겁쟁이 버섯, 스쿼시, 겁쟁이 버섯, 할라페뇨, 태양 버섯, 얼음 버섯, 최면 버섯.
* 구현된 좀비: 좀비, 깃발 좀비, 콘헤드 좀비, 양동이 좀비, 신문 좀비.
* 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)

Binary file modified resources/graphics/Screen/Adventure_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/Adventure_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/Boom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/GameLoose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/GameVictory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/PanelBackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/graphics/Screen/StartButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/sound effects/Cherry bomb.wav
Binary file not shown.
Binary file added resources/sound effects/opening.wav
Binary file not shown.
Binary file added resources/sound effects/peashooter.wav
Binary file not shown.
Binary file added resources/sound effects/sun.wav
Binary file not shown.
Binary file added source/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added source/__pycache__/constants.cpython-37.pyc
Binary file not shown.
Binary file added source/__pycache__/main.cpython-37.pyc
Binary file not shown.
Binary file added source/__pycache__/tool.cpython-37.pyc
Binary file not shown.
Binary file added source/component/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added source/component/__pycache__/map.cpython-37.pyc
Binary file not shown.
Binary file not shown.
Binary file added source/component/__pycache__/plant.cpython-37.pyc
Binary file not shown.
Binary file not shown.
5 changes: 4 additions & 1 deletion source/component/plant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion source/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from . import constants as c
from .state import mainmenu, screen, level

# 처음 시작할 때 호출
def main():
game = tool.Control()
state_dict = {c.MAIN_MENU: mainmenu.Menu(),
c.GAME_VICTORY: screen.GameVictoryScreen(),
c.GAME_LOSE: screen.GameLoseScreen(),
c.LEVEL: level.Level()}
game.setup_states(state_dict, c.MAIN_MENU)
game.main()
game.main() # pygame 화면 재생 부분 (루프)
Binary file added source/state/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file added source/state/__pycache__/level.cpython-37.pyc
Binary file not shown.
Binary file added source/state/__pycache__/mainmenu.cpython-37.pyc
Binary file not shown.
Binary file added source/state/__pycache__/screen.cpython-37.pyc
Binary file not shown.
6 changes: 6 additions & 0 deletions source/state/mainmenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
from .. import tool
from .. import constants as c


# 게임 처음 들어가고 난 뒤에 나오는 메뉴
# 각종 이미지, 스프라이트 정의
class Menu(tool.State):
def __init__(self):
tool.State.__init__(self)
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions source/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down