Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: cp1252 -*-
- import sys, pygame
- from pygame.locals import *
- #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
- #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
- #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
- #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
- #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
- #Arcabouço onde o jogo é montado.
- class Framework:
- width = 800
- height = 600
- screen = pygame.display.set_mode((width, height))
- def __init__(self):
- pygame.mouse.set_visible(1)
- pygame.display.set_caption("Aventura Sem Nome")
- background = pygame.image.load('Background800.jpg').convert()
- self.letra = pygame.font.SysFont('Arnhem', 30)
- self.screen.blit(background, (0,0))
- while True: #Loop principal do jogo
- for event in pygame.event.get():
- if event.type == pygame.QUIT: pygame.quit()
- else:
- Start()
- pygame.display.flip()
- # Serve de Modelo para as demais "páginas" do jogo.
- class Template:
- def __init__(self):
- self.letra = pygame.font.SysFont('Arnhem', 30)
- def tela(self, texto):
- self.fundo = pygame.Surface((Framework.width - 20, Framework.height *0.625), SRCALPHA)
- self.fundo.fill((255,255,255,150))
- Framework.screen.blit(self.fundo, (10, Framework.height*0.1875))
- text = self.letra.render(texto, 1, (0,0,0))
- Framework.screen.blit(text, (10,115))
- def click(self, button):
- pos = pygame.mouse.get_pos()
- mouseRect = [[pos[0],pos[1]],[5,5]]
- mouseRect = Rect(mouseRect)
- m = mouseRect.colliderect(button)
- return m
- #Serve de Modelo para os demais "botões" do jogo.
- class Button:
- buttonpos = 0,0
- def __init__(self, texto, lugar):
- self.buttonpos = self.button_pos(lugar)
- frame = pygame.image.load('ButtonM.png').convert_alpha()
- frame = pygame.transform.rotozoom(frame, 0, 0.1)
- self.letra = pygame.font.SysFont('Arnhem', 30)
- text = self.letra.render(texto, 1, (0,0,0))
- self.rect = pygame.Rect((self.buttonpos),(160,40))
- self.mouseover = False
- Framework.screen.blit(frame, self.buttonpos)
- Framework.screen.blit(text, self.buttonpos)
- def button_pos(self, lugar):
- if lugar == 0: buttonpos = 10, Framework.height-100 #Q
- elif lugar == 1: buttonpos = 120, Framework.height-100 #W
- elif lugar == 2: buttonpos = 240, Framework.height-100 #E
- elif lugar == 3: buttonpos = 360, Framework.height-100 #R
- elif lugar == 4: buttonpos = 10, Framework.height-50 #A
- elif lugar == 5: buttonpos = 120, Framework.height-50 #S
- elif lugar == 6: buttonpos = 240, Framework.height-50 #D
- elif lugar == 7: buttonpos = 360, Framework.height-50 #F
- return buttonpos
- #Página Inicial. Disclaimer, Start Game, Load Game.
- class Start(Template):
- def __init__(self):
- Template.__init__(self)
- disclaimer = Template.tela(self, "Welcome to a still unnamed game.")
- start_button = Button("Start Game", 0)
- credits_button = Button("Credits", 7)
- for event in pygame.event.get():
- if event.type == pygame.MOUSEBUTTONDOWN:
- if self.click(start_button) == True: Teste()
- elif self.click(credits_button) == True: Credits()
- #Página de Créditos.
- class Credits(Template):
- def __init__(self):
- Template.__init__(self)
- credits_screen = Template.tela(self, "He comes, ZALGO.")
- #Página de Teste
- class Teste(Template):
- def __init__(self):
- Template.__init__(self)
- credits_screen = Template.tela(self, "TESTESTESTESTESTE")
- return_button = Button("Return", 0)
- for event in pygame.event.get():
- if event.type == pygame.MOUSEBUTTONDOWN:
- if self.click(return_button) == True: Start()
- #Colocando para funcionar
- pygame.init()
- fps = pygame.time.Clock()
- fps.tick(90)
- Framework()
Add Comment
Please, Sign In to add comment