Python Forum
[PyGame] explosion-animation
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] explosion-animation
#5
(Dec-01-2021, 01:10 AM)metulburr Wrote: Its been an a couple years since i have programmed at all. So take my current advice with a grain of salt as it could be off.

If i remember correctly...Sprite groups "basically" just automate the update and draw methods. So if you wanted to remove it as a Sprite Group you would first get rid of the explosion class from inheriting from pygame.sprite.Sprite. Then run update and draw methods yourself.

An explosion is just running through a list of explosion images slowing them down for you to see. This example switches a number every second. You can utilize that same concept to flip through a list of explosion images. But make them faster that 1 second (1000 milliseconds would be more like 100 milliseconds, etc).

    def update(self):
        if pygame.time.get_ticks()-self.timer > self.delay:
            self.timer = pygame.time.get_ticks()
            #flip_to_next_image()
where flip_to_next_image() would be an Explosion method flipping to next image and detecting if at the end of the list to ensure it doesnt fail. timer is initialized to 0, and delay is 100 for 100 milliseconds. Which would execute flip_to_next_image() every 10th of a second.

Sorry i couldnt help any more, i just havent been programming during the pandemic as i have been busy doing other things.


Dear metulburr, thank you very much for your answer and your suggestions, I will try them out.
But most of all I want to thank you for your pygame tutorial. I think it's one of the clearest pygame tutorials I know (and therefore also one of the best). Especially when it comes to getting rid of redundant code and organising code.
Greetings hespa
metulburr likes this post
Reply


Messages In This Thread
explosion-animation - by hespa - Nov-30-2021, 07:07 PM
RE: explosion-animation - by BashBedlam - Nov-30-2021, 08:12 PM
RE: explosion-animation - by hespa - Nov-30-2021, 11:00 PM
RE: explosion-animation - by metulburr - Dec-01-2021, 01:10 AM
RE: explosion-animation - by hespa - Dec-01-2021, 08:43 AM
RE: explosion-animation - by metulburr - Dec-01-2021, 11:19 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Explosion hits enemies, they explode as well flash77 4 230 Jun-08-2024, 02:18 PM
Last Post: flash77
  [PyGame] Sprite Animation to create an explosion Russ_CW 2 4,100 Oct-23-2020, 04:57 PM
Last Post: Russ_CW

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020