I havetaken time to change over from using an array of bullets to a linked list of bullets. Now I have two problems.
When the first bullet is deleted the program crashes. This code works with the first element in the list.
Code:
else if(current->x == x && current->y == y)
{
temp = current;
*headRef = current->next;
free(temp);
}
As a result of switching over to linked lists my bullet checking code no longer works. Maybe, I'm not comparing my variables correctly?
Code:
void checkBullets(struct bulletList* head)
{
int i,k;
struct bulletList* current = head;
for(i = 0; i < MAX_ROW; i++)
{
for(k = 0; k < MAX_COL; k++)
{
while(current != NULL)
{
if((current->x > alien[i][k].x &&
current->x < alien[i][k].x+alien[i][k].width &&
current->y > alien[i][k].y &&
current->y < alien[i][k].y+alien[i][k].height) &&
alien[i][k].alive == 1)
{
switch(alien[i][k].type)
{
case 1: player.score += 5; break;
case 2: player.score += 1000; break;
case 3: player.score += 75; break;
}
alien[i][k].alive = 0;
}
current = current->next;
}
}
}
}