Guest User

Untitled

a guest
Jun 24th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.17 KB | None | 0 0
  1. # -*- coding: cp1252 -*-
  2. import sys, pygame
  3. from pygame.locals import *
  4.  
  5. #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
  6. #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
  7. #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
  8. #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
  9. #TEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUITEXTOAQUI#
  10.  
  11. #Arcabouço onde o jogo é montado.
  12. class Framework:
  13.     width = 800
  14.     height = 600
  15.     screen = pygame.display.set_mode((width, height))
  16.    
  17.     def __init__(self):
  18.         pygame.mouse.set_visible(1)
  19.         pygame.display.set_caption("Aventura Sem Nome")
  20.         background = pygame.image.load('Background800.jpg').convert()
  21.         self.letra = pygame.font.SysFont('Arnhem', 30)
  22.         self.screen.blit(background, (0,0))
  23.        
  24.         while True:     #Loop principal do jogo
  25.             for event in pygame.event.get():
  26.                 if event.type == pygame.QUIT: pygame.quit()
  27.                 else:
  28.                     Start()
  29.                     pygame.display.flip()
  30.  
  31. # Serve de Modelo para as demais "páginas" do jogo.      
  32. class Template:
  33.     def __init__(self):
  34.         self.letra = pygame.font.SysFont('Arnhem', 30)
  35.  
  36.     def tela(self, texto):
  37.         self.fundo = pygame.Surface((Framework.width - 20, Framework.height *0.625), SRCALPHA)
  38.         self.fundo.fill((255,255,255,150))
  39.         Framework.screen.blit(self.fundo, (10, Framework.height*0.1875))
  40.         text = self.letra.render(texto, 1, (0,0,0))
  41.         Framework.screen.blit(text, (10,115))
  42.        
  43.        
  44.     def click(self, button):
  45.         pos = pygame.mouse.get_pos()
  46.         mouseRect = [[pos[0],pos[1]],[5,5]]
  47.         mouseRect = Rect(mouseRect)
  48.         m = mouseRect.colliderect(button)
  49.         return m
  50.  
  51. #Serve de Modelo para os demais "botões" do jogo.
  52. class Button:
  53.     buttonpos = 0,0
  54.     def __init__(self, texto, lugar):
  55.         self.buttonpos = self.button_pos(lugar)
  56.         frame = pygame.image.load('ButtonM.png').convert_alpha()
  57.         frame = pygame.transform.rotozoom(frame, 0, 0.1)
  58.         self.letra = pygame.font.SysFont('Arnhem', 30)
  59.         text = self.letra.render(texto, 1, (0,0,0))
  60.         self.rect = pygame.Rect((self.buttonpos),(160,40))
  61.         self.mouseover = False
  62.         Framework.screen.blit(frame, self.buttonpos)
  63.         Framework.screen.blit(text, self.buttonpos)
  64.  
  65.     def button_pos(self, lugar):
  66.         if lugar == 0: buttonpos = 10, Framework.height-100       #Q
  67.         elif lugar == 1: buttonpos = 120, Framework.height-100    #W
  68.         elif lugar == 2: buttonpos = 240, Framework.height-100    #E
  69.         elif lugar == 3: buttonpos = 360, Framework.height-100    #R
  70.         elif lugar == 4: buttonpos = 10, Framework.height-50      #A
  71.         elif lugar == 5: buttonpos = 120, Framework.height-50     #S
  72.         elif lugar == 6: buttonpos = 240, Framework.height-50     #D
  73.         elif lugar == 7: buttonpos = 360, Framework.height-50     #F
  74.         return buttonpos
  75.  
  76. #Página Inicial. Disclaimer, Start Game, Load Game.
  77. class Start(Template):
  78.     def __init__(self):
  79.         Template.__init__(self)
  80.         disclaimer = Template.tela(self, "Welcome to a still unnamed game.")
  81.         start_button = Button("Start Game", 0)
  82.         credits_button = Button("Credits", 7)
  83.         for event in pygame.event.get():
  84.             if event.type == pygame.MOUSEBUTTONDOWN:
  85.                 if self.click(start_button) == True: Teste()
  86.                 elif self.click(credits_button) == True: Credits()
  87.                    
  88. #Página de Créditos.
  89. class Credits(Template):
  90.     def __init__(self):
  91.         Template.__init__(self)
  92.         credits_screen = Template.tela(self, "He comes, ZALGO.")
  93.  
  94. #Página de Teste
  95. class Teste(Template):
  96.     def __init__(self):
  97.         Template.__init__(self)
  98.         credits_screen = Template.tela(self, "TESTESTESTESTESTE")
  99.         return_button = Button("Return", 0)
  100.         for event in pygame.event.get():
  101.             if event.type == pygame.MOUSEBUTTONDOWN:
  102.                 if self.click(return_button) == True: Start()
  103.        
  104.          
  105. #Colocando para funcionar    
  106. pygame.init()
  107. fps = pygame.time.Clock()
  108. fps.tick(90)
  109.  
  110. Framework()
Add Comment
Please, Sign In to add comment