0

How to create objects which is counted by time? e.g 1 health pack spawns every 15 seconds.

I have considered using array, but it means that i have only have a limited amounts of health packs even when there is a prolonged gameplay.

Currently i am only able to draw the first healthpack when the game runs.

On a side note, how do you delete the object?

  • You need to set up a clock and check the time you want in the game loop, then restart it. – hlscalon Nov 28 '16 at 12:07
  • Have you considered reusing the healtpacks on the array? If you continually are creating you will eventually end out of memory, and creating many tiny elements will lead to fragmentation. Reusing then in an array is a better option. – rlam12 Nov 28 '16 at 15:30

1 Answers1

1

Think this is what you're looking for: need to call a function at periodic time intervals in c++

As for how you create and delete an object, that depends entirely on the object itself and where it's allocated.

Community
  • 1
  • 1