0
I would be creating a game for a college job, but I’m having some difficulties, among them, one in which I can’t get the character to move up or down, just sideways, accusing me of this mistake:
File "C:/Users/estima/Desktop/jogo python/RPG.py", line 48, in rpg player.rect.down += player.speed Attributeerror: 'pygame. Rect' Object has no attribute 'down'`
in which I am not managing to heal, some idea ?
import pygame, sys
from pygame.locals import *
largura = 670
altura = 690
class Guerreiro (pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.guerreiro = pygame.image.load('imagem/solo.png')
self.rect = self.guerreiro.get_rect()
self.rect.centerx = largura / 2
self.rect.centery = altura / 2
self.vida = True
self.velocidade = 20
def colocar (self, superficie):
superficie.blit(self.guerreiro, self.rect)
def rpg():
pygame.init()
tela = pygame.display.set_mode((largura,altura))
pygame.display.set_caption("RPG do SI")
jogador = Guerreiro()
imagemFundo = pygame.image.load('imagem/mapa.png')
jogando = True
while True:
for evento in pygame.event.get():
if evento.type == QUIT:
pygame.quit()
sys.exit()
if evento.type == pygame.KEYDOWN:
if evento.key == K_LEFT:
jogador.rect.left -= jogador.velocidade
if evento.key == K_RIGHT:
jogador.rect.right += jogador.velocidade
if evento.key == K_DOWN:
jogador.rect.down += jogador.velocidade
tela.blit(imagemFundo,(0,0))
jogador.colocar(tela)
pygame.display.update()
rpg()