Advertisement

About the game loop.

Started by December 27, 2020 12:35 PM
0 comments, last by eu5 3 years, 11 months ago

Hi. I'm implementing a simple game like the Galaga and this is my first game.

I implement a function that move a bullet.

And If the moved bullet's position reach in end of screen, the bullet will be deleted.

void MoveBullet()
{
  while(...)
  {  
  	if(IsCollisionBulletVsWall(...))
  	{
     	// Is it good place for a bullet's deletion?
     	// or I have to move the deletion to other function? 
     	bullet->Delete();
  	}
  	else
  	{
     	bullet->Move();
  	}
  }
}

In here, I have a question.

Is it appropriate to be located the bullet's deletion code in MoveBullet()?

I think it's also good that If the function name is ‘MoveBullet’, JUST have a code about ONLY MOVE.

What do you think?

This topic is closed to new replies.

Advertisement