20251025
# import pygame
# import pickle
#
# pygame.init()
#
# BLACK = (0, 0, 0)
# RED = (255, 0, 0)
# GREEN = (0, 255, 0)
# BLUE = (0, 0, 255)
# WHITE = (255, 255, 255)
# YELLOW = (255, 255, 0)
#
# large_font = pygame.font.SysFont(None, 72)
# small_font = pygame.font.SysFont(None, 36)
#
# screen_width = 600
# screen_height = 800
# screen = pygame.display.set_mode((screen_width, screen_height))
#
# clock = pygame.time.Clock()
#
# def save_game_state(scoreboard, file_name):
# try:
# with open(file_name, 'wb') as file:
# pickle.dump(scoreboard, file)
# print("Game state saved successfully!")
# except IOError:
# print("Error: Unable to save game state.")
# def load_game_state(file_name):
# try:
# with open(file_name, 'rb') as file:
# game_state = pickle.load(file)
# print("Game state loaded successfully!")
# return game_state
# except (IOError, pickle.UnpicklingError):
# print("Error: Unable to load game state.")
#
# def start():
# global game_start
# game_start=1
#
# def text_objects(text, font):
# textSurface = font.render(text, True, GREEN)
# return textSurface, textSurface.get_rect()
#
# def button(txt,x,y,w,h,ic,ac,action):
# mouse=pygame.mouse.get_pos()
# click=pygame.mouse.get_pressed()
# if x+w>mouse[0]>x and y+h>mouse[1]>y :
# pygame.draw.rect(screen,ac,(x,y,w,h))
#
# if click[0]==1 and action!=None:
# action()
# else :
#
# pygame.draw.rect(screen,ic,(x,y,w,h))
# smallText=pygame.font.SysFont("Arial",20)
# textSurf,textRect=text_objects(txt,smallText)
# textRect.center=((x+(w/2)), (y+(h/2)))
# screen.blit(textSurf,textRect)
#
# def runGame():
#
# score = 0
# missed = 0
# SUCCESS = 1
# FAILURE = 2
# game_over = 0
# game_start = 0
# bricks = []
# COLUMN_COUNT = 8
# scoreboard=[0,0,0,0,0]
# scoreboard=load_game_state('scoreboardfile')
#
# ROW_COUNT = 7
#
# for column_index in range(COLUMN_COUNT):
# for row_index in range(ROW_COUNT):
#
# brick = pygame.Rect(column_index * (60 + 10) + 35, row_index * (16 + 5) + 35, 60, 16)
#
# bricks.append(brick)
#
# ball = pygame.Rect(screen_width // 2 - 16 // 2, screen_height // 2 - 16 // 2, 16, 16)
# ball_dx = 5
# ball_dy = -5
#
# ball2 = pygame.Rect(screen_width // 2 - 200 // 2, screen_height // 2 - 16 // 2, 16, 16)
# ball2_dx = 5
# ball2_dy = -5
#
# paddle = pygame.Rect(screen_width // 2 - 80 // 2, screen_height - 16, 80, 16)
# paddle_dx = 0
#
# screen.fill(BLACK)
#
#
# while game_start == 0:
#
# clock.tick(30)
#
# myFont = pygame.font.SysFont("Arial", 20, True, False)
# screen.blit(myFont.render(f'press S to start', True, 'yellow'), (220, 400, 0, 0))
#
# mFont = pygame.font.SysFont("Arial", 70, True, False)
# screen.blit(mFont.render(f'BRICKSBREAK', True, 'green'), (35, 300, 0, 0))
#
#
# for event in pygame.event.get():
# if event.type == pygame.KEYDOWN:
# if event.key == pygame.K_s:
# game_start = 1
#
# pygame.display.update()
#
# while game_start == 1:
#
# clock.tick(500 + score)
#
# screen.fill(BLACK)
#
# for event in pygame.event.get():
# if event.type == pygame.QUIT:
# break
#
# elif event.type == pygame.KEYDOWN:
# if event.key == pygame.K_LEFT:
# paddle_dx = -5
# elif event.key == pygame.K_RIGHT:
# paddle_dx = 5
#
# elif event.type == pygame.KEYUP:
# if event.key == pygame.K_LEFT:
# paddle_dx = 0
# elif event.key == pygame.K_RIGHT:
# paddle_dx = 0
#
#
# paddle.left += paddle_dx
#
# ball.left += ball_dx
# ball.top += ball_dy
#
# if game_over == 0 :
# if ball.left <= 0:
#
# ball.left = 0
#
# ball_dx = -ball_dx
#
# elif ball.left >= screen_width - ball.width:
#
# ball.left = screen_width - ball.width
#
# ball_dx = -ball_dx
#
# if ball.top < 0:
#
# ball.top = 0
#
# ball_dy = -ball_dy
#
# elif ball.top >= screen_height:
#
# missed += 1
#
# ball.left = screen_width // 2 - ball.width // 2
#
# ball.top = screen_height // 2 - ball.width // 2
#
# ball_dy = -ball_dy
#
#
# if score >= 40 and game_over == 0:
#
# ball2.left += ball2_dx
#
# ball2.top += ball2_dy
#
#
# if ball2.left <= 0:
#
# ball2.left = 0
#
# ball2_dx = -ball2_dx
#
# elif ball2.left >= screen_width - ball2.width:
#
# ball2.left = screen_width - ball2.width
#
# ball2_dx = -ball2_dx
#
# if ball2.top < 0:
#
# ball2.top = 0
#
# ball2_dy = -ball2_dy
#
# elif ball2.top >= screen_height:
#
# missed += 1
#
# ball2.left = screen_width // 2 - ball2.width // 2
#
# ball2.top = screen_height // 2 - ball2.width // 2
#
# ball2_dy = -ball2_dy
#
#
# if missed >= 5:
# game_over = FAILURE
#
# if paddle.left < 0:
#
# paddle.left = 0
#
# elif paddle.left > screen_width - paddle.width:
#
# paddle.left = screen_width - paddle.width
#
#
# for brick in bricks:
# if score >= 40:
# if ball.colliderect(brick) :
#
# bricks.remove(brick)
#
# ball_dy = -ball_dy
#
# score += 1
#
# break
#
# if ball2.colliderect(brick):
#
# bricks.remove(brick)
#
# ball2_dy = -ball2_dy
#
# score += 1
#
# break
#
# else:
#
# if ball.colliderect(brick):
#
# bricks.remove(brick)
#
# ball_dy = -ball_dy
#
# score += 1
#
# break
#
# if ball.colliderect(paddle):
#
# ball_dy = -ball_dy
#
# if ball.centerx <= paddle.left or ball.centerx > paddle.right:
#
# ball_dx = ball_dx * -1
#
# if score >= 40:
# if ball2.colliderect(paddle):
#
# ball2_dy = -ball2_dy
#
# if ball2.centerx <= paddle.left or ball2.centerx > paddle.right:
#
# ball2_dx = ball2_dx * -1
#
#
# if len(bricks) == 0:
# game_over = SUCCESS
#
# # 화면 그리기
#
# for brick in bricks:
# pygame.draw.rect(screen, GREEN, brick)
#
#
# if game_over == 0:
# pygame.draw.circle(screen, WHITE, (ball.centerx, ball.centery), ball.width // 2)
#
# if score >= 40:
# pygame.draw.circle(screen, WHITE, (ball2.centerx, ball2.centery), ball2.width // 2)
#
# pygame.draw.rect(screen, BLUE, paddle)
#
# if score >= 40:
#
# score_image = small_font.render('Point {}'.format(score), True, RED)
#
# screen.blit(score_image, (10, 10))
#
# else:
#
# score_image = small_font.render('Point {}'.format(score), True, YELLOW)
#
# screen.blit(score_image, (10, 10))
#
# missed_image = small_font.render('Missed {}'.format(missed), True, YELLOW)
#
# screen.blit(missed_image, missed_image.get_rect(right=screen_width - 10, top=10))
#
# if game_over > 0:
# if game_over == SUCCESS:
#
# success_image = large_font.render('success', True, RED)
#
# screen.blit(success_image,
# success_image.get_rect(centerx=screen_width // 2, centery=screen_height // 2-150))
#
#
# elif game_over == FAILURE:
#
# failure_image = large_font.render('fail', True, RED)
#
# screen.blit(failure_image,
# failure_image.get_rect(centerx=screen_width // 2, centery=screen_height // 2-150))
#
# myFont = pygame.font.SysFont("Arial", 20, True, False)
#
#
# button("RESTART", 150, 600, 100, 50, RED, YELLOW, runGame)
# button("QUIT", 340, 600, 100, 50, RED, YELLOW, pygame.quit)
#
# for i in range(5):
# if scoreboard[i]==score :
# break
#
# elif scoreboard[i]<score :
# scoreboard.insert(i, score)
# scoreboard.pop()
# break
#
# for i in range(5):
# score_image = small_font.render('Point {}'.format(scoreboard[i]), True, YELLOW)
# screen.blit(score_image, (screen_width // 2-45, 320+i*50))
#
# save_game_state(scoreboard, 'scoreboardfile')
#
# pygame.display.update()
#
# runGame()
# pygame.quit()
import pygame
def rungame() :
game=1
# 활동
while game==1 :
#10*10의 공간
#몬스터를 만나면 game=2
#상점에 들어가면 game=3
#레벨 시스템:
#레벨 1: 체력20 공격력10 0exp
#레벨 2: 체력25 공격력15 10exp
#레벨 3: 체력 공격력 30exp
#레벨 4: 체력 공격력 50exp
#레벨 5: 체력 공격력 반격 추가 90exp
#세이브: 저장(파일3개)
#인벤토리
# 전투
while game==2 :
#플레이어:
#플레이어 체력:20
#버튼:
#공격: 공격함
#공격 방식: 창착한 무기에 따라 다름
#무기x: 바로 공격력만큼 데미지를 줌
# 아이템: 아이템 사용
# 방어: 방어 상태에 따라 지속적으로 효과를 얻음
#일반 : 아무것도 없음
#막기 상태: 받는 데미지 감소
#반격 상태: 받은 데미지의 일부만큼 공격
#회피 상태: 50%(회피 할때마다 10%감소)확률로 공격 회피
#공격 당하는 방식: 몬스터마다 다름
#몬스터 1 :
#-체력:100
#-주는 아이템: 사탕
#-주는 돈 양: 100원
#-주는 경험치: 10exp
#공격 방식: 탄막 회피
#몬스터가 2마리 이상일 경우 체력과 공격력이 평균값으로 지정됨
#상점
while game==3 :
#상점 리스트:
#-나무검: 공격력 만큼 증가 300원
#공격 방식:
#-사탕: 체력10회복 100원
#-나무갑옷: 데미지 10만큼 감소 300원
#-나무방패: 막기 상태일시 감소하는 정도가 늘어남
#마법지팡이: 공격력 20만큼 증가 300원
#공격 방식: (나무검보다 공격 방식이 어려움)
runGame()
pygame.quit()




