Closed neilong31 closed 5 years ago
Thanks for the quick response!
I totally forgot to finish the function call, thank you! Also, I switched the position of the check to be in front of enemy_add in the floor.c file. It's while loop that continues to randomize the enemies x and y position until it doesn't match the players.
This is actually still not effective, as enemy placements are done during initialization. What we need to do actually is do this based on the location of the stairs, not the player - maybe we just want to re-calculate the stairs, if they pick a location with an enemy on them.
Okay, I think I understand. So before setting,
int up_y;
int up_x;
int down_y;
int down_x;
which I am assuming are the coordinates for the stairs. I should check if there is an enemy spawned at those locations. If there is an enemy, then I should recalculate the coordinates. Is that correct?
Yes, exactly
Thanks for you patience with me. Hopefully this code is what you wanted and I am using list_traverse correctly. The logic goes as follows:
Thanks!
Fix #92 : Added an if statement in enemy_add to check if the x and y position passed is the same as the player's. If it is I return 0. Is this alright or would you like me to change it?
I was also thinking of writing a while loop within floor_init() before line 82 in floor.c to check of the position we give the enemy is the same as user and randomize the position until they are not the same.