Python Forum

Full Version: Walking Figure in pygame
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey Guys, I make a walking figure with pygame like this:

 
win = pygame.display.set_mode((852,480)) 
def __init__(self, x, y, width, height, end):
        self.x = x#
        self.y = y
        self.width = width
        self.height = height
        self.path = [x, end]  
        self.vel = 3

def draw(self,win): # almost same with player(object)
        self.move()
        if self.walkCount + 1 >= 33:
            self.walkCount = 0

        if self.vel > 0: # If we are moving to the right we will display our walkRight images
            win.blit(self.walkRight[self.walkCount//3], (self.x,self.y))
            self.walkCount += 1
        else:  # Otherwise we will display the walkLeft images
            win.blit(self.walkLeft[self.walkCount//3], (self.x,self.y))
            self.walkCount += 1
But it walks just in half of the screen. I want it to walk a whole screen. Can you help me? Thank you very much
Uh, shouldn't this be in the game development section?
There isn't enough info here to help. The def __init__ is a class constructor, but what is the class and where do you create the instance?

What is self.move()? That seems important and would likely be where it is told only to walk half the screen.

All I could suggest now is to make an actual pygame sprite.