Archived

This topic is now archived and is closed to further replies.

CannoN346

Timer Question

Recommended Posts

CannoN346    122
Ok, in my pacman game everytime a big square is hit a timer goes off and for the duration of that timer pacman chases the ghosts. But each time another big square is hit, the timer is shorter. Whats the problem? Heres my code...
  
for (int index=0; index < MAX_BIG_SQUARES; index++)
{
	if (big_squares[index].state == SQUARE_OFF)
	{
		if (++chase_timer < MAX_CHASE_TIMER)
		{ 
			if (pacman.x > ghost_1.x)
			dir = DIR_LEFT;
			else
			if (pacman.x < ghost_1.x)
			dir = DIR_RIGHT;
			else
			if (pacman.y > ghost_1.y)
			dir = DIR_UP;
			else
			if (pacman.y < ghost_1.y)
			dir = DIR_DOWN;

			if (pacman.x > ghost_2.x)
			opcode = DIR_LEFT;
			else
			if (pacman.x < ghost_2.x)
			opcode = DIR_RIGHT;
			else
			if (pacman.y > ghost_2.y)
			opcode = DIR_UP;
			else
			if (pacman.y < ghost_2.y)
			opcode = DIR_DOWN;

			if (pacman.x > ghost_3.x)
			blue = DIR_LEFT;
			else
			if (pacman.x < ghost_3.x)
			blue = DIR_RIGHT;
			else
			if (pacman.y > ghost_3.y)
			blue = DIR_UP;
			else
			if (pacman.y < ghost_3.y)
			blue = DIR_DOWN;

			if (pacman.x > ghost_4.x)
			orange = DIR_LEFT;
			else
			if (pacman.x < ghost_4.x)
			orange = DIR_RIGHT;
			else
			if (pacman.y > ghost_4.y)
			orange = DIR_UP;
			else
			if (pacman.y < ghost_4.y)
			orange = DIR_DOWN;
		}

	}
}
  
And i make sure to reset the timer...
  
for (index=0; index<MAX_BIG_SQUARES; index++)
{

	if(Collision_BOBS(&pacman,&big_squares[index]))
	{
		if(big_squares[index].state == SQUARE_ON)
		{
			Destroy_BOB2(&big_squares[index]); 
			player_score+=50;
			big_squares[index].state = SQUARE_OFF;
			total_squares-=1;
			chase_timer=0;

		}
		if (big_squares[index].state == SQUARE_OFF)
			player_score+=0;
		
	}
	
}
  

Share this post


Link to post
Share on other sites