Harry the Debugger

eeeclipse·2020년 5월 10일
0

개요

천재개발자 Harry님께 존경을 표시하기 위하여 python을 이용한 작은 게임을 만들어보도록 하자

Harry the Debugger

해리는 천재 개발자이다. 그는 온갖 종류의 버그와 맞서 싸우며, 최고의 풀스택개발자를 꿈꾸며 모험을 떠난다. 해리는 과연 모험을 성공적으로 끝낼 수 있을까 ?

Requirements

  • python 3.X
    • virtualenv
    • pygame
  • resources : 이미지, 오디오 등등

Step01 : Setup

python virtualenv를 실행하고, pygame을 pip로 설치해준다

Step02 : 안녕 해리 !

# 1 - 라이브러리를 불러온다 
import pygame
from pygame.locals import *

# 2 - 게임초기화, 콘솔화면을 컨트롤 한다 
pygame.init()
width, height = 640, 480
screen=pygame.display.set_mode((width, height))

# 3 - 게임에서 사용할 이미지를 불러온다 
player = pygame.image.load('resources/images/harry.png')

# 4 - 
while 1:
    # 5 - clear the screen before drawing it again
    screen.fill(0)
    # 6 - draw the screen elements
    screen.blit(player, (100,100))
    # 7 - update the screen
    pygame.display.flip()
    # 8 - loop through the events
    for event in pygame.event.get():
        # check if the event is the X button
        if event.type==pygame.QUIT:
            # if it is quit the game
            pygame.quit()
            exit(0)

실행하면 다음과 같은 화면이 나온다.

이제 사용자로부터 동작을 입력받아 움직이도록 하자.

Step03 : 배경을 만들자 !

검은 창에 해리가 혼자 있는 것은 너무 외로워 보인다. 천재개발자답게 멋진 배경을 만들어주자

  • background
  • objects
    - ms : 지켜야할 마이크로 서비스들
    • bugs : 우리의 서비스를 공격하는 버그들

Step04 : 해리를 움직이게 하자

천재 개발자는 한 번 컴퓨터 앞에 앉으면 3-4시간은 꿈쩍도 하지 않는다. 버그를 잡기 위해서는 활발하게 움직여야하므로, 해리가 움직일 수 있도록 도와주자

Reference

Beginning Game Programming for Teens with Python
pygame

profile
mathematician, researcher, Data Scientist ⊗ Engineer ⊗ Architect, DBA

1개의 댓글

comment-user-thumbnail
2020년 6월 16일

잘못했습니다 ㅠㅠ 살려주세요 ㅠㅠ

답글 달기