Skip to content

Commit

Permalink
메인 레포지토리와 병합
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnamid committed Nov 29, 2023
2 parents efd249a + b17b813 commit c83ad34
Show file tree
Hide file tree
Showing 9 changed files with 444 additions and 199 deletions.
2 changes: 1 addition & 1 deletion G_avoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@
pygame.display.update()

pygame.time.delay(2000)
pygame.quit() # 게임 종료
pygame.quit() # 게임 종료
70 changes: 66 additions & 4 deletions G_baseballGame.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,71 @@
import sys
import pygame
import random
import sys, pygame, random
from pygame.locals import *
from menu import MainMenu

class baseballGame():
def __init__(self):
pygame.init()
self.running, self.playing = True, False
self.UP_KEY, self.DOWN_KEY, self.START_KEY, self.BACK_KEY = False, False, False, False
self.DISPLAY_W, self.DISPLAY_H = 1000,600
self.display = pygame.Surface((self.DISPLAY_W, self.DISPLAY_H))
self.window = pygame.display.set_mode(((self.DISPLAY_W, self.DISPLAY_H)))

#self.font_name = '8-BIT WONDER.TTF'
self.font_name = pygame.font.get_default_font()
self.BLACK, self.WHTIE = (0,0,0), (255,255,255)
self.curr_menu = MainMenu(self)

def check_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running, self.playing = False, False
self.curr_menu.run_display = False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
self.START_KEY = True
if event.key == pygame.K_BACKSPACE:
self.BACK_KEY = True
if event.key == pygame.K_DOWN:
self.DOWN_KEY = True
if event.key == pygame.K_UP:
self.UP_KEY = True


def reset_keys(self):
self.UP_KEY, self.DOWN_KEY, self.BACK_KEY, self.UP_KEY = False, False, False, False


def game_loop(self):
while self.playing:
self.check_events()
if self.START_KEY:
self.playing = False
self.display.fill(self.BLACK)
self.draw_text('Thanks for Playing',20,self.DISPLAY_W/2, self.DISPLAY_H/2)
self.window.blit(self.display, (0,0))
pygame.display.update()
self.reset_keys()

def draw_text(self, text, size, x,y):
font = pygame.font.Font(self.font_name, size)
text_surface = font.render(text, True, self.WHTIE)
text_rect = text_surface.get_rect()
text_rect.center = (x,y)
self.display.blit(text_surface, text_rect)












'''
pygame.init()
Expand Down Expand Up @@ -214,4 +276,4 @@ def append_value(self,new_value):
pygame.display.update()
pygame.quit()
pygame.quit()'''
61 changes: 59 additions & 2 deletions G_memoryGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,64 @@
from pygame.locals import *
from pygame.color import Color


class memoryGame():
def __init__(self):
pygame.init()
self.running, self.playing = True, False
self.UP_KEY, self.DOWN_KEY, self.START_KEY, self.BACK_KEY = False, False, False, False
self.DISPLAY_W, self.DISPLAY_H = 1000,600
self.display = pygame.Surface((self.DISPLAY_W, self.DISPLAY_H))
self.window = pygame.display.set_mode(((self.DISPLAY_W, self.DISPLAY_H)))

#self.font_name = '8-BIT WONDER.TTF'
self.font_name = pygame.font.get_default_font()


self.BLACK, self.WHTIE = (0,0,0), (255,255,255)

def check_events(self):
for event in pygame.event.get():
if event.type == pygame.QUIT:
self.running, self.playing = False, False
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_RETURN:
self.START_KEY = True
if event.key == pygame.K_BACKSPACE:
self.BACK_KEY = True
if event.key == pygame.K_DOWN:
self.DOWN_KEY = True
if event.key == pygame.K_UP:
self.UP_KEY = True


def reset_keys(self):
self.UP_KEY, self.DOWN_KEY, self.BACK_KEY, self.UP_KEY = False, False, False, False


def game_loop(self):
while self.playing:
self.check_events()
if self.START_KEY:
self.playing = False
self.display.fill(self.BLACK)
self.draw_text('Thanks for Playing',20,self.DISPLAY_W/2, self.DISPLAY_H/2)
self.window.blit(self.display, (0,0))
pygame.display.update()
self.reset_keys()

def draw_text(self, text, size, x,y):
font = pygame.font.Font(self.font_name, size)
text_surface = font.render(text, True, self.WHTIE)
text_rect = text_surface.get_rect()
text_rect.center = (x,y)
self.display.blit(text_surface, text_rect)






'''
# the constants
FPS = 30
SCREEN_WIDTH = 800
Expand Down Expand Up @@ -233,4 +290,4 @@ def draw_select_box(x, y):
if __name__ == '__main__':
main()
main()'''
Loading

0 comments on commit c83ad34

Please sign in to comment.