-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
desenvolvimento das fases e alteração de design
- adicionado contorno à fonte em algumas telas (melhor visibilidade) - adicionado lógica de vidas e imagens - colisão do cursor com os objetos faz o objeto aumentar levemente - feito a fase 2 - pequena alteração no design das fases - mudança na lógica de seleção e confirmação dos objetos (melhoria) - alteração na posição de alguns objetos (como configuração, instruções, voltar, etc)
- Loading branch information
Showing
10 changed files
with
422 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,40 @@ | ||
import pygame | ||
|
||
class Botao(): # objeto | ||
def __init__(self, x, y, imagem, imagemAlterada): # self = ele mesmo; x, y = coordenadas; image = imagem para o botão (função init: método construtor) | ||
class Botao(): | ||
def __init__(self, x, y, imagem, imagemAlterada): | ||
self.imagemOriginal = imagem | ||
self.imagemAlterada = imagemAlterada # imagem com highlight | ||
self.imagem = self.imagemOriginal # define a imagem do objeto original | ||
self.imagemAlterada = imagemAlterada | ||
self.imagem = self.imagemOriginal | ||
|
||
self.rect = self.imagem.get_rect() # cria um retângulo para o objeto do tamanho da imagem, por isso get_rect | ||
self.rect.topleft = (x, y) # coordenadas para a posição que queremos o botão/imagem | ||
self.clicked = False # define o estado atual do botão como falso (não clicado) | ||
self.rect = self.imagem.get_rect() | ||
self.rect.topleft = (x, y) | ||
self.clicked = False | ||
|
||
def desenharBotao(self, tela): | ||
tela.blit(self.imagem, (self.rect.x, self.rect.y)) | ||
|
||
def clicarBotao(self, tela): | ||
acao = False # variável para rastrear as ações dos cliques | ||
posicaoMouse = pygame.mouse.get_pos() # variável recebe a posição do mouse | ||
acao = False | ||
posicaoMouse = pygame.mouse.get_pos() | ||
|
||
# Verifica se o mouse está dentro da área do botão | ||
if self.rect.collidepoint(posicaoMouse): | ||
for event in pygame.event.get(): | ||
if event.type == pygame.MOUSEBUTTONDOWN and event.button == 1: | ||
if not self.clicked: # Detecta o clique apenas uma vez | ||
if not self.clicked: | ||
self.clicked = True | ||
acao = True | ||
if event.type == pygame.MOUSEBUTTONUP and event.button == 1: | ||
self.clicked = False # Reseta a flag ao liberar o mouse | ||
self.clicked = False | ||
|
||
return acao | ||
|
||
|
||
def atualizarImagem(self, posicaoMouse): # caso o mouse do usuário passar em cima troca a imagem | ||
def atualizarImagem(self, posicaoMouse): | ||
if self.rect.collidepoint(posicaoMouse): | ||
self.imagem = self.imagemAlterada | ||
else: # imagem volta ao original ao tirar o mouse de cima | ||
self.imagem = self.imagemOriginal | ||
# Aumenta a imagem (zoom) quando o mouse passa por cima | ||
largura, altura = self.imagem.get_size() | ||
self.imagem = pygame.transform.scale(self.imagem, (int(largura * 1.05), int(altura * 1.05))) # Aumenta 20% do tamanho | ||
else: | ||
self.imagem = self.imagemOriginal | ||
largura, altura = self.imagem.get_size() | ||
self.imagem = pygame.transform.scale(self.imagem, (int(largura), int(altura))) # Volta ao tamanho original |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.