#Urgent pygame help needed

33 messages · Page 1 of 1 (latest)

trim sonnet
#

Can anyone please help me to solve this error...basically it is platform game using python...i am strugling while implementing the traps (fan).

patent ferry
#

You're just accessing properties that don't exist? lol

trim sonnet
#

i don't understand

patent ferry
#

You're accessing self.fan

#

Where is the value of self.fan set to anything?

trim sonnet
#

class Fan(Object):
ANIMATION_DELAY = 3

def __init__(self, x, y, width, height):
    super().__init__(x, y, width, height, "fan")
    self.fan = load_sprite_sheets("Traps", "Fan", width, height)
    self.image = self.fan["off"][0]
    self.mask = pygame.mask.from_surface(self.image)
    self.animation_count = 0
    self.animation_name = "off"
        
def on(self):
    self.animation_name = "on"
    
def off(self):
    self.animation_name = "off"
    
def loop(self):
    
    sprites = self.fan[self.animation_name]
    sprite_index = (self.animation_count // 
                    self.ANIMATION_DELAY) %len(sprites)
    self.image = sprites[sprite_index]
    self.animation_count += 1
    self.rect = self.image.get_rect(topleft =(self.rect.x,self.rect.y))    
    self.mask = pygame.mask.from_surface(self.image) 
    
    if self.animation_count // self.ANIMATION_DELAY > len(sprites):
        self.animation_count = 0
patent ferry
trim sonnet
#

a bit diffrent yeah

#

can i send u the full code ?

patent ferry
#

If you follow the rules on formatting

hardy kernelBOT
#

@trim sonnet

File Attachments Not Allowed

For safety reasons we do not allow files with certain file extensions.

dororo_4813 Said

i don't clearly understand how to add the traps in the game...

Code Formatting

You can share your code using triple backticks like this:
```
YOUR CODE
```

Large Portions of Code

For longer scripts use Hastebin or GitHub Gists and share the link here

Ignored these files due to them having disallowed file extensions
trim sonnet
#

wait i am send u the github link

patent ferry
#

That link doesn't work 🙂

trim sonnet
#

how about now

patent ferry
#

The link works

trim sonnet
#

except the tutorial file other files will be in a folder called assets

trim sonnet
#

????

#

did you find the error

patent ferry
#

Didn't check yet lol

trim sonnet
#

help me out bro i am in hurry

#

i don't hv much knowledge about python and pygame...i gotta show it to my lecturer

patent ferry
#

I might take a look later 🙂

trim sonnet
#

okkk

trim sonnet
last umbra
#

Which is the main file you execute?

trim sonnet
last umbra
#

Main file...

#

a file is smth like a test.txt or anything. in this case it should end like myfile.py

#

have you tested that this function is doing what it should?
self.fan = load_sprite_sheets("Traps", "Fan", width, height)

trim sonnet
#

no