Player score

Started by
7 comments, last by CannoN346 22 years, 5 months ago
In the score for my game, im trying to add 1 each time pacman moves over a square. But, all squares on the map are placed separately, and have a set position. So, when i go over 1, the score keeps going up if i stay in that position, even after the square is gone. What can i do to make it stay?? My code: for (index=0; index<MAX_SQUARES; index++) { if(Collision_BOBS(&pacman,&squares[index])) { Destroy_BOB2(&big_squares[index]); player_score+=1; } } Thanks in advance.
Advertisement
ok that first line was

for (index=0; index<MAX_SQUARES; index++)
DAMMIT! Sorry
Ill post it all on different lines
for (index=0; index<MAX_SQUARES; index++)
Just guessing that for a pacman game your levels are a big 2d array. Let the squares have a value of 1, and change them to 2 once you go over them. Then you only update the score if the current square is equal to 1.
quote:Original post by CannoN346
DAMMIT!

Yet another reason to place spaces between your code tokens. Observe:
index = 0; index < MAX_SQUARES; ++index


I wanna work for Microsoft!
yes, thank u oluseyi.
Ok, tried that and still nothing. Well, it just stays there now, instead of moving up at all. Can someone tell me whats wrong with my code...

for (index=0; index{
squares[index].state = SQUARE_ON;

if(Collision_BOBS(&pacman,&squares[index]))
{
Destroy_BOB2(&squares[index]);
squares[index].state = SQUARE_OFF;
}

if (Collision_BOBS(&pacman,&squares[index]) &&
squares[index].state == SQUARE_ON)
player_score+=1;
else
if (Collision_BOBS(&pacman,&squares[index]) &&
squares[index].state == SQUARE_OFF)
player_score+=0;
}
Try this, could be wrong though since i''m kinda new to games too but i''ll try my best

  if (Collision_BOBS(&pacman,&squares[index])){  if (squares[index].state == SQUARE_ON)  {    player_score += 1;    squares[index].state = SQUARE_OFF;  }  else    player_score += 0;}  


That else with the += 0 probably isn''t needed but I just copied it over from your code.
Didnt work.

This topic is closed to new replies.

Advertisement