import pygame
WIDTH = 640
HEIGHT = 360
FPS = 30
RBG = (255, 255, 255)
BLACK = (0, 0, 0)
LightGray = (215, 215, 215)
pygame.init()
screen = pygame.display.set_mode((WIDTH, HEIGHT))
screen.fill(RBG)
B = pygame.image.load('Background.jpg')
NL = pygame.image.load('NinjaLeft.png')
NR = pygame.image.load('NinjaRight.png')
KL = pygame.image.load('KunaiLeft.png')
KR = pygame.image.load('KunaiRight.png')
SL = pygame.image.load('SurikenLeft.png')
SR = pygame.image.load('SurikenRight.png')
SB = pygame.image.load('StartButton.png')
IB = pygame.image.load('InstructionButton.png')
B = pygame.transform.scale(B, (640, 360))
NL = pygame.transform.scale(NL, (120, 120))
NR = pygame.transform.scale(NR, (120, 120))
KL = pygame.transform.scale(KL, (45, 23.1))
KR = pygame.transform.scale(KR, (45, 23.1))
SL = pygame.transform.scale(SL, (22.5, 22.5))
SR = pygame.transform.scale(SR, (22.5, 22.5))
SB = pygame.transform.scale(SB, (320, 187))
IB = pygame.transform.scale(IB, (320, 187))
screenForm = 1
IBw = 320
IBh = 187
SBw = 320
SBh = 187
def menu():
screen.blit(B, (0,0))
screen.blit(IB, (WIDTH/2-IBw/2,HEIGHT/2-30))
screen.blit(SB, (WIDTH/2-SBw/2,HEIGHT/2-130))
def instruction():
screen.fill(BLACK)
pygame.draw.rect \
(screen, LightGray, pygame.Rect(10, 10, 20, 2))
pygame.draw.rect \
(screen, LightGray, pygame.Rect(10, 15, 20, 2))
pygame.draw.rect \
(screen, LightGray, pygame.Rect(10, 20, 20, 2))
menu()
clock = pygame.time.Clock()
running = True
pygame.display.update()
while running :
clock.tick(FPS)
mouseX = pygame.mouse.get_pos()[0]
mouseY = pygame.mouse.get_pos()[1]
if screenForm == 1:
menu()
if (mouseX >= WIDTH/2-123) \
and (mouseY <= HEIGHT/2+97.5) \
and (mouseX <= WIDTH/2+123) \
and (mouseY >= HEIGHT/2+30):
IBw = 336
IBh = 196.35
elif (mouseX >= WIDTH/2-123) \
and (mouseY <= 178) \
and (mouseX <= WIDTH/2+123) \
and (mouseY >= 108):
SBw = 336
SBh = 196.35
else:
IBw = 320
IBh = 187
SBw = 320
SBh = 187
SB = pygame.transform.scale(SB, (320, 187))
IB = pygame.transform.scale(IB, (IBw, IBh))
if screenForm == 2:
instruction()
events = pygame.event.get()
for event in events:
if event.type == pygame.QUIT:
running = False
pygame.quit()
exit()
if event.type == pygame.MOUSEBUTTONDOWN:
if screenForm == 1:
if (mouseX >= WIDTH/2-123) \
and (mouseY <= HEIGHT/2+97.5) \
and (mouseX <= WIDTH/2+123) \
and (mouseY >= HEIGHT/2+30):
screenForm = 2
if screenForm == 2:
if (mouseX >= 10) and (mouseY <= 22) \
and (mouseX <= 30) and (mouseY >= 10):
screenForm = 1
pygame.display.update()