#Urgent pygame help needed
33 messages · Page 1 of 1 (latest)
You're just accessing properties that don't exist? lol
i don't understand
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
Seems like the code on the second screenshot is different to the code you sent now?
If you follow the rules on formatting
@trim sonnet
For safety reasons we do not allow files with certain file extensions.
i don't clearly understand how to add the traps in the game...
You can share your code using triple backticks like this:
```
YOUR CODE
```
For longer scripts use Hastebin or GitHub Gists and share the link here
That link doesn't work 🙂
how about now
The link works
except the tutorial file other files will be in a folder called assets
Didn't check yet lol
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
I might take a look later 🙂
okkk
https://github.com/techwithtim/Python-Platformer/tree/main here is the main code from where i have taken help
Writting code in a hurry never solves anything xD
I guess you pushed your homework far away and doing it on last day now.
Which is the main file you execute?
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)
no