-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplay.py
More file actions
35 lines (28 loc) · 1.14 KB
/
Copy pathplay.py
File metadata and controls
35 lines (28 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Modulo que prove o jogador
import pygame, support, vector2d
from pygame.locals import *
from pygame.sprite import *
clock = pygame.time.Clock()
class Jogador(Sprite):
# Inicializacao dos atributos
def __init__(self, *grupos):
Sprite.__init__(self, *grupos)
self.image = support.carrega_imagem('climber44.png')
self.rect = Rect(152, 564, 30, 30)
#self.rect.inflate(-10, -10)
self.velocidade = 200.
self.posicao = vector2d.Vector2(152, 564)
self.pos_temp = vector2d.Vector2()
self.pontuacao = 0
self.vidas = 3
# Metodo que realiza a movimentacao do jogador
def move(self, direcao):
self.pos_temp.x, self.pos_temp.y = self.posicao.x, self.posicao.y
tempo = clock.tick(60)
tempo_segundos = tempo / 1000.0
self.posicao += direcao * self.velocidade * tempo_segundos
self.rect.center = (self.posicao.x , self.posicao.y)
# Metodo que retorna o jogador para a posicao anterior
def volta(self):
self.posicao.x, self.posicao.y = (self.pos_temp.x, self.pos_temp.y)
self.rect.center = (self.pos_temp.x, self.pos_temp.y)