I'm trying to make a vertical scrolling shooter, and ive made quite alot of progress, I've got the lasers to work alright and the background to scroll properly. Although I'm having real trouble getting aliens to work properly.

Problems I'm having:
1) Getting the aliens to move properly - They move onto the screen, scrolling with the background and then just get to a point where they don't move.
2) Getting the lasers to damage the alien ship properly - The lasers do damage to the ship before they reach it. It looks a little weird when the ship blows up when u shoot it and it blows up before the shot reaches it.
3) Sometimes when you shoot lasers at the alien ship, it doesnt register the damage no matter how many times you hit it
4) If a ship does come onto the screen, another one isnt made - I cant get it to form a loop. Eventually I want to turn it into a series of levels.

Anyway, I havent started on anything to do with the aliens shooting back just yet. As with the lasers from my previous posts, I'm using linked lists for the alien ships.

Theres the code:
Code:
// This is the declaration of alien_root etc at the beginning of int main.
/* Set up the Alien Structure */
    AlienStruct *alien_root=NULL;
    AlienStruct *current_alien = NULL;
    AlienStruct *previous_alien = NULL;
    AlienStruct *temp_alien = NULL;
    
    alien_root = new AlienStruct;
    alien_root->next_alien = NULL;
    alien_root->alien_type = 1;

// Inside the main game loop - This is the main alien logic sequence.
// I broke the main game loop into logic and graphics to make things more organised.
/* Alien Movements */
                               
                               /* Generate New Aliens if too few on screen */
                               // current_alien = alien_root;
                               
                               if( alien_counter < 1 )
                               {
                                   caliens.AddNewAlien( rand()%SCREEN_DIMX, -(cgraphics.GetAlienBitmapDimension(1, 1)), 1, alien_root);
                                   alien_counter++;
                               }
                               
                               /* Check if Aliens have been destroyed */
                               current_alien = alien_root;
                               
                               while( current_alien->next_alien != NULL )
                               {
                                      posx = cgraphics.GetAlienBitmapDimension(current_alien->alien_type, 0);
                                      posy = cgraphics.GetAlienBitmapDimension(current_alien->alien_type, 0);
                                      
                                      /* Test if alien has been hit by laser */
                                      while( current_node->next_laser != NULL )
                                      {
                                             if( ((current_node->laser_position[0] > current_alien->alien_position[0])&&
                                                 (current_node->laser_position[0] < current_alien->alien_position[0] + posx))&&
                                                 ((current_node->laser_position[1] < current_alien->alien_position[1])&&
                                                 (current_node->laser_position[1] > current_alien->alien_position[1] + posy)) )
                                             {
                                                                                  /* Take Damage of Laser away from Alien number of hit points */
                                                                                  current_alien->alien_hitpoints -= LASER_DAMAGE;
                                                                                  allegro_message("Damage");
                                                                                  
                                                                                  if( current_alien->alien_hitpoints <= 0 )
                                                                                  {
                                                                                      /* 'Tag' Alien Ship so that it will be exploded in the graphical section of the code */
                                                                                      current_alien->alien_destroy = true;
                                                                                  }
                                                                                  
                                                                                  /* Delete laser beams which hit the aliens */
                                             }
                                             
                                             current_node = current_node->next_laser;
                                      }
                                      
                                      /* Test if alien has been hit by rocket launcher */
                                      
                                      current_alien = current_alien->next_alien;
                               }
                               
                               /* Change the positions of the Aliens */
                               current_alien = alien_root;
                               
                               if( acounter > 50 )
                               {
                                   while( current_alien->next_alien != NULL )
                                   {
                                          current_alien->alien_position[0] = current_alien->alien_position[0] + current_alien->alien_velocity[0];
                                          current_alien->alien_position[1] = current_alien->alien_position[1] + current_alien->alien_velocity[1];
                                          
                                          current_alien = current_alien->next_alien;
                                          
                                          acounter = 0;
                                   }
                               }
                               
                               /* Take into account the scrolling of the background */
                               caliens.IncrementYRemoveAlienPosition(alien_root);
                               
                               /* Change the velocities of the Aliens */
                               current_alien = alien_root;
                               
                               while( current_alien->next_alien != NULL )
                               {
                                      caliens.ChangeAlienVelocity(current_alien);
                                      
                                      current_alien = current_alien->next_alien;
                               }
This next lot of code is from the header file "aliens.h" - It has all the methods called above.
Code:
void CGameAliens::AddNewAlien( int position_x, int position_y, unsigned int type, AlienStruct *alien_root)
{
     AlienStruct *current_node=NULL;
     
     current_node = alien_root;
     
     /* Save the place in the linked list */
     while(current_node->next_alien != 0)
     {
                                    current_node = current_node->next_alien;
     }
     
     current_node->next_alien = new AlienStruct;
     
     /* Set the position of the alien */
     current_node->alien_position[0] = position_x;
     current_node->alien_position[1] = position_y;
     current_node->alien_type = type;
     current_node->alien_destroy = false;
     
     switch(type)
     {
                 case 1:
                      current_node->alien_hitpoints = ALIEN_TYPE_I_LIFE;
                      break;
                 case 2:
                      current_node->alien_hitpoints = ALIEN_TYPE_II_LIFE;
                      break;
                 case 3:
                      current_node->alien_hitpoints = ALIEN_TYPE_III_LIFE;
                      break;
                 case 4:
                      current_node->alien_hitpoints = ALIEN_TYPE_IV_LIFE;
                      break;
                 case 5:
                      current_node->alien_hitpoints = ALIEN_TYPE_V_LIFE;
                      break;
     }
     
     current_node = current_node->next_alien;
     current_node->next_alien = NULL;
     
     return;
}

void CGameAliens::DeleteAllAliens(AlienStruct *alien_root)
{
     AlienStruct *current_node1;
     AlienStruct *current_node2;
     
     current_node1 = alien_root->next_alien;
     
     while(current_node1->next_alien != NULL)
     {
                                    current_node2 = current_node1->next_alien;
                                    delete current_node1;
                                    current_node1 = current_node2;
     }
     
     delete current_node1;
     
     delete alien_root;
     
     return;
}

void CGameAliens::IncrementYRemoveAlienPosition(AlienStruct *alien_root)
{
     /* This Method increases Y position and removes any old Aliens */
     AlienStruct *current_node=NULL;
     AlienStruct *previous_node=NULL;
     
     current_node = alien_root;
     
     while(current_node->next_alien != NULL)
     {
                                    current_node->alien_position[1] = (unsigned int)(current_node->alien_position[1] + SCROLL_RATE);
                                    
                                    current_node = current_node->next_alien;
     }
     
     current_node = alien_root;
     
     while(current_node->next_alien != NULL)
     {
                                    if( current_node->alien_position[1] >= SCREEN_DIMY )
                                    {
                                                                       /* Get rid of Alien */
                                                                       previous_node = current_node;
                                                                       current_node = current_node->next_alien;
                                                                       previous_node->next_alien = current_node->next_alien;
                                                                       delete current_node;
                                                                       current_node = previous_node;
                                    }
                                    
                                    current_node = current_node->next_alien;
     }
     
     return;
}

void CGameAliens::ChangeAlienVelocity(AlienStruct *current_node)
{
     unsigned int max_velocity=0;
     
     switch(current_node->alien_type)
     {
                                     case 1:
                                          max_velocity = ALIEN_TYPE_I_SPEED;
                                          break;
                                     case 2:
                                          max_velocity = ALIEN_TYPE_II_SPEED;
                                          break;
                                     case 3:
                                          max_velocity = ALIEN_TYPE_III_SPEED;
                                          break;
                                     case 4:
                                          max_velocity = ALIEN_TYPE_IV_SPEED;
                                          break;
                                     case 5:
                                          max_velocity = ALIEN_TYPE_V_SPEED;
                                          break;
     }
     
     /* Change X position, making sure the picture stays on the screen */
     if( (current_node->alien_position[0] < (SCREEN_DIMX - 300))&&(current_node->alien_position[0] > 0) )
     {
         current_node->alien_velocity[0] = -(current_node->alien_velocity[0]);
     }
     else
     {
         current_node->alien_velocity[0] = (rand()%max_velocity) - (max_velocity/2);
     }
     
     /* Change Y position */
     if( current_node->alien_position[1] > 0 )
     {
         current_node->alien_velocity[1] = -(current_node->alien_velocity[1]);
     }
     else
     {
         current_node->alien_velocity[1] = (rand()%max_velocity) - (max_velocity/2);
     }
     
     return;
}
This is the graphical aspect of the main game loop, w.r.t. drawing the aliens.
Code:
/* Draw the aliens */
                               current_alien = alien_root;
                               
                               while(current_alien->next_alien != NULL)
                               {
                                                               if( current_alien->alien_destroy == false)
                                                               {
                                                                   masked_blit(cgraphics.p_alien01, cgraphics.p_screen_buffer1, 0, 0, current_alien->alien_position[0], current_alien->alien_position[1] + cgraphics.p_alien01->h,
                                                                                                cgraphics.p_alien01->w, cgraphics.p_alien01->h);
                                                               }
                                                               else
                                                               {
                                                                   /* Draw Alien Ship Explosion */
                                                                   
                                                                   /* Get rid of this part of the linked list */
                                                                   temp_alien = current_alien;
                                                                   previous_alien->next_alien = current_alien->next_alien;
                                                                   delete temp_alien;
                                                                   temp_alien = NULL;
                                                                   allegro_message("Damage2");
                                                                   
                                                                   alien_counter--;
                                                               }
                                                               
                                                               if(current_alien->next_alien != NULL)
                                                               {
                                                                   previous_alien = current_alien;
                                                                   current_alien = current_alien->next_alien;
                                                               }
                                                               else
                                                               {
                                                                   previous_alien = NULL;
                                                                   current_alien = NULL;
                                                                   break;
                                                               }
                               }