Python Forum
Randomly selecting sprite from group?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomly selecting sprite from group?
#4
Having a problem with data types. The process below gives me a list of tuples, but I need to input the x and y as separate arguments. "Split" doesn't work on tuples, apparently. Maybe how I add them to the list can change? I can use 2 separate lists (one for x and one for y) but then I don't know how to make sure to use x's and y's that are actual pairs.

floor_locations = []

### then  I move my digger sprite with a random walk and add each step to list here:

floor_locations.append(digger.rect.x, digger.rect.y)


### Then... 

key_location = random.choice(floor_locations)
key1 = Key(key_location)
Reply


Messages In This Thread
RE: Randomly selecting sprite from group? - by michael1789 - Nov-14-2019, 04:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] Sprites just randomly appear and dissapear in my pygame.sprite.GoupeSingle trueShadoWrr 2 2,044 Feb-13-2023, 09:34 AM
Last Post: Vadanane
  player just randomly teleporting to the edge of a platform in pygame BliepMonster 5 2,405 Jan-26-2023, 10:12 PM
Last Post: deanhystad
  [PyGame] Sprite image.get_rect() moves sprite to 0, 0 michael1789 2 4,652 Dec-13-2019, 08:37 PM
Last Post: michael1789
  Sprite not rendering Clunk_Head 2 2,210 Oct-03-2019, 11:27 AM
Last Post: Clunk_Head
  Need help making a sprite GalaxyCoyote 4 3,325 Aug-11-2019, 09:12 PM
Last Post: metulburr
  moving a sprite pfaber11 3 2,650 May-15-2019, 12:52 PM
Last Post: pfaber11
  [PyGame] Need Help With Sprite ghost0fkarma 2 3,321 Jan-09-2018, 02:14 PM
Last Post: ghost0fkarma
  [PyGame] move randomly sprites reutB 4 8,300 Mar-29-2017, 01:12 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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