EMX Postado Fevereiro 3, 2008 Denunciar Share Postado Fevereiro 3, 2008 eu queria saber como fazer a animação de andar de um personagemse alguém uma alma caridosa puder me ajudar com um modelo de scriptficarei grato Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 EMX Postado Fevereiro 5, 2008 Autor Denunciar Share Postado Fevereiro 5, 2008 eu fiz uma gambiarra aqui e o bicho faz o movimento só que ele ta meio rapidohttp://www.wikifortio.com/587717/teste.rareu tentei colocar a função pygame.time.Clock().tick(15)para diminuir a velocidade de troca de subsurface, mas não fica legal Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 Fabio Curtis Postado Fevereiro 16, 2008 Denunciar Share Postado Fevereiro 16, 2008 eu queria saber como fazer a animação de andar de um personagemse alguém uma alma caridosa puder me ajudar com um modelo de scriptficarei gratobeleza?? Segue abaixo o script:import pygame, sys,osfrom pygame.locals import *# initializing pygamepygame.init()# setting up the screenpygame.display.set_caption('Cenario')size = width, height = 600, 400screen = pygame.display.set_mode(size)black = 0, 0, 0window = pygame.display.set_mode(max(pygame.display.list_modes())) # fliping the displaypygame.display.flip() # ############################################################################# def load_image ## 02/09/2008 ## ## function that loads the images into memory ## ############################################################################def load_image(name): fullname = os.path.join('imagens', name) try: image = pygame.image.load(fullname) except pygame.error, message: print 'Cannot load image:', fullname raise SystemExit, message return image, image.get_rect()# end load_image# ############################################################################# class Avatar ## 02/09/2008 ## ## class responsible for designing and move the sprite of avatar ## ############################################################################class Avatar(pygame.sprite.Sprite): def __init__(self, startpos): pygame.sprite.Sprite.__init__(self) self.direction = 1 self.image, self.rect = load_image('firts.bmp') self.rect.centerx = startpos[0] self.rect.centery = startpos[1] # move the sprite def move(self,x,y): self.rect.move_ip(x,y) # detection of edges - não esta funcionando if self.rect.left < 0: self.direction = 1 elif self.rect.right > width: self.direction = -1 # end Avatar# ############################################################################# class Maps ## 02/10/2008 ## ## class responsible for designing the map ## ############################################################################class Maps(pygame.sprite.Sprite): def __init__(self, startpos): pygame.sprite.Sprite.__init__(self) self.image, self.rect = load_image('maps.bmp') self.rect.centerx = startpos[0] self.rect.centery = startpos[1]# end Maps# ############################################################################# class Game ## 02/09/2008 ## ## class main ## ############################################################################class Game(): avatar = Avatar([500,500]) maps = Maps([300,300]) clock = pygame.time.Clock() while 1: # ensures that the program will not run more than 120fps clock.tick(120) # events of keyboard for event in pygame.event.get(): if event.type == QUIT: sys.exit(0) elif event.type == pygame.KEYDOWN: if event.key == pygame.K_LEFT: avatar.move(-10,0) if event.key == pygame.K_RIGHT: avatar.move(10,0) if event.key == pygame.K_UP: avatar.move(0,-10) if event.key == pygame.K_DOWN: avatar.move(0,10) # detection between objects #if avatar.rect.colliderect(maps.rect): screen.fill(black) screen.blit(avatar.image, avatar.rect) screen.blit(maps.image, maps.rect) pygame.display.flip()# end Game Espero que te ajude :rolleyes: Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
EMX
eu queria saber como fazer a animação de andar de um personagem
se alguém uma alma caridosa puder me ajudar com um modelo de script
ficarei grato
Link para o comentário
Compartilhar em outros sites
2 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.