Python Forum
Speed issue with sprite update
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Speed issue with sprite update
#1
This is my first attempt at the update for a sprite:
def update(self, event, dt):
               
        self.rect.y += 5
        temp_group = self.game.all_sprites.copy()
        temp_group.remove(self)
        block_hit_list = pg.sprite.spritecollide(self, temp_group, False)
        for block in block_hit_list:
 
                self.rect.bottom = block.rect.top
        temp_group.empty()
I'll add acceleration later, but the problem is with performance.

The game is one of blocks in a grid that the player mines around in. I want these particular blocks to fall if they are undermined, but having each of this kind of block try to move and perform this check each frame drags the program to a crawl.

I need to find a better way to have blocks fall if there is nothing underneath them. I'm going to work now on only doing this check when the player destroys a block, as that is the only time it would change, but I want to have a LOT of blocks in this game, so any ideas on speeding this up will help a lot.

I'm not invested in this method at all, so radical options are welcome. tnx
Reply


Messages In This Thread
Speed issue with sprite update - by michael1789 - Feb-17-2020, 12:30 AM
RE: Speed issue with sprite update - by Windspar - Feb-17-2020, 01:55 AM
RE: Speed issue with sprite update - by michael1789 - Feb-17-2020, 03:57 AM
RE: Speed issue with sprite update - by Windspar - Feb-17-2020, 09:31 AM
RE: Speed issue with sprite update - by michael1789 - Feb-19-2020, 05:08 AM
RE: Speed issue with sprite update - by michael1789 - Feb-17-2020, 08:01 PM
RE: Speed issue with sprite update - by Windspar - Feb-19-2020, 11:27 AM
RE: Speed issue with sprite update - by Windspar - Feb-23-2020, 02:46 PM
RE: Speed issue with sprite update - by michael1789 - Feb-27-2020, 03:33 AM
RE: Speed issue with sprite update - by Windspar - Feb-27-2020, 11:25 AM
RE: Speed issue with sprite update - by Windspar - Mar-01-2020, 12:19 PM
RE: Speed issue with sprite update - by michael1789 - Mar-05-2020, 08:39 AM
RE: Speed issue with sprite update - by Windspar - Mar-05-2020, 09:22 AM
RE: Speed issue with sprite update - by michael1789 - Mar-06-2020, 03:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Sprite image.get_rect() moves sprite to 0, 0 michael1789 2 4,704 Dec-13-2019, 08:37 PM
Last Post: michael1789
  Sprite not rendering Clunk_Head 2 2,268 Oct-03-2019, 11:27 AM
Last Post: Clunk_Head
  Need help making a sprite GalaxyCoyote 4 3,384 Aug-11-2019, 09:12 PM
Last Post: metulburr
  moving a sprite pfaber11 3 2,687 May-15-2019, 12:52 PM
Last Post: pfaber11
  [PyGame] Need Help With Sprite ghost0fkarma 2 3,371 Jan-09-2018, 02:14 PM
Last Post: ghost0fkarma

Forum Jump:

User Panel Messages

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