#๐Ÿ”’ pygame help with timer

48 messages ยท Page 1 of 1 (latest)

serene solar
#

e

molten fjordBOT
#

@serene solar

Python help channel opened

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.

serene solar
#

!paste

molten fjordBOT
#
Pasting large amounts of code

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.

serene solar
#

I cant make it so that aliens fire after 2 seconds

#

without time implementation they fire but too fast

#

Please help

gloomy root
serene solar
#

line 213

gloomy root
#

try running the code first
is it unfinished

#

what is the result

serene solar
#

the result is aliens move but they dont fire any bullets

#

at all

gloomy root
#

well

#

i'm sorry i can't help please forgive me

#

๐Ÿ™

serene solar
#

ok

autumn finch
#

Why make AlienBullet class?

serene solar
#

for aliens

#

to fire bullets

autumn finch
#

But they're no different from Bullet class

serene solar
#

yeah but

#

i dont want same bullets

#

like the same image

autumn finch
#

Could put that as a separate parameter in the init

serene solar
#

err

#

I think its much cleaner

gloomy root
quaint bramble
serene solar
#

i just need to solve the timerissue

gloomy root
#
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

serene solar
#

too late now

#

its gonna disturb the later code

#

i will keep it like this and moveo n

autumn finch
#

never too late

#

anyways

#

You can fix the timer thing by following the logic of the fleet

serene solar
#

.

autumn finch
#

Could add more randomization at line 130

serene solar
#

fuck me

#

bro

#

i didnt initialize pygame ๐Ÿ˜ญ

#

!close

molten fjordBOT
#
Python help channel closed

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.