Python Forum
[PyGame] Timing the spawning enemies
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Timing the spawning enemies
#3
Outside the while loop create an index variable which starts at 0. Also create another variable which will store a time and set its value to inline]pygame.time.get_ticks()[/inline]. Now in the while loop create an if statement something like this:
timeStamp = pygame.time.get_ticks()
if timeStamp - lastTimeStamp >= 500: # lastTimeStamp is the variable storing time and replace 500 with another integer that works well
    # get the enemy with the number value from the index variable
    lastTimeStamp = timeStamp # resets the time stamp
    index += 1 # The index variable
I think this will work
Reply


Messages In This Thread
Timing the spawning enemies - by MichaelEssey - Aug-18-2020, 03:40 PM
RE: Timing the spawning enemies - by michael1789 - Aug-18-2020, 07:49 PM
RE: Timing the spawning enemies - by SheeppOSU - Aug-22-2020, 05:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  spawning enemies in pygame Elberg 2 5,635 Mar-05-2020, 09:45 AM
Last Post: Windspar
  [PyGame] Spawning platforms that don't touch michael1789 15 6,112 Jan-26-2020, 04:02 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

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