#๐ pygame help with timer
48 messages ยท Page 1 of 1 (latest)
@serene solar
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
I cant make it so that aliens fire after 2 seconds
without time implementation they fire but too fast
Please help
where is the fire function
line 213
ok
Why make AlienBullet class?
But they're no different from Bullet class
Could put that as a separate parameter in the init
nah
Depends.
i just need to solve the timerissue
class Bullet(Sprite):
def __init__(self, ai_game, bullet_type):
super().__init__()
self.screen = ai_game.screen
self.screen_rect = self.screen.get_rect()
self.settings = ai_game.settings
if bullet_type == "player":
self.image = pygame.image.load('bullet.jpg')
elif bullet_type == "alien":
self.image = pygame.image.load('LaserBeam.jpg')
self.rect = self.image.get_rect()
if bullet_type == "player":
self.rect.midtop = ai_game.player_ship.rect.midtop
elif bullet_type == "alien":
self.rect.midtop = alien.rect.midtop
self.y = float(self.rect.y)
def update(self):
self.y -= self.settings.bullet_speed
self.rect.y = self.y
def draw_bullet(self):
self.screen.blit(self.image,self.rect)
thank me if you want
realized it's a waste of time
too late now
its gonna disturb the later code
i will keep it like this and moveo n
never too late
anyways
You can fix the timer thing by following the logic of the fleet
.
Could add more randomization at line 130
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.