Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Gamestates - in which order?  (Read 2075 times)

0 Members and 1 Guest are viewing this topic.

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Gamestates - in which order?
« on: February 18, 2018, 04:39:25 pm »
Hello!

Ive got 4 states of my game.

1. update
2. check collision
3. spawn enemies
4. draw

And I wonder in which order I should put these.
I am sorry If something like this post has been written already 100 times.
What can I say, Im a nab  :)

Best regards,
Bizarreofnature

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Gamestates - in which order?
« Reply #1 on: February 18, 2018, 04:51:36 pm »
Oh i see.

1. update
2. collision
3. draw

but where to put spawn enemies?

Paul

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: Gamestates - in which order?
« Reply #2 on: February 19, 2018, 01:12:00 am »
It depends on your game loop. The basis is not to have any complex code in the draw procedure. So you can put spawning into update phase or make some event queue.

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Gamestates - in which order?
« Reply #3 on: February 20, 2018, 07:16:50 am »
You probably want to update your spawned enemies before drawing them. I don't know what how you coded the game but I can imagine a few instances where your enemies are drawn incorrectly for the first frame they are spawned.

 

anything