Python Forum
Randomly selecting sprite from group?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomly selecting sprite from group?
#1
I want to add items to my random dungeon. I'm thinking to select a sprite at random from my group of floor tiles and use it's location as a spawn location for a key, a treasure, and some enemies.

Is it possible to select a sprite (and it's location) from a group? My searches have revealed nothing about this.

I want to do something like:

key1 = Key(random_floor_tile.x, random_floor_tile.y)


Then to stop the same floor tile from being used twice, adding the selected tile to a group to check before spawning?

Thanks.


PS. Is there are more Pythonese word to use instead of "spawn"? lol
Reply


Messages In This Thread
Randomly selecting sprite from group? - by michael1789 - Nov-13-2019, 09:37 PM

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,651 Dec-13-2019, 08:37 PM
Last Post: michael1789
  Sprite not rendering Clunk_Head 2 2,208 Oct-03-2019, 11:27 AM
Last Post: Clunk_Head
  Need help making a sprite GalaxyCoyote 4 3,320 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,320 Jan-09-2018, 02:14 PM
Last Post: ghost0fkarma
  [PyGame] move randomly sprites reutB 4 8,298 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