• Create Account

### #Actualstitchs

Posted 20 July 2012 - 12:46 PM

Also, quick question, what Graphics library are you using, because when you delete your enemy you never seem to free the memory associated with it's image. I know this may not be causing the issue with you crash, but it could lead to a number of memory leaks if not cleaned up properly. I'll make use of Allegro for this example as it is the one I'm most familiar with:

Delete_Function(Enemy*& enemy_to_be_deleted){
destroy_bitmap(enemy_to_be_deleted->image);
delete enemy_to_be_deleted;
enemy_to_be_deleted = NULL;
}


This is the order in which the image attribute of said enemy should be deleted. The pointer should then be set to Null so that no undesired results occur.

### #2stitchs

Posted 20 July 2012 - 12:45 PM

Also, quick question, what Graphics library are you using, because when you delete your enemy you never seem to free the memory associated with it's image. I know this may not be causing the issue with you crash, but it could lead to a number of memory leaks if not cleaned up properly. I'll make use of Allegro for this example as it is the one I'm most familiar with:

Delete_Function(Enemy*& enemy_to_be_deleted){
destroy_bitmap(enemy_to_be_deleted->image);
delete enemy_to_be_deleted;
}


This is the order in which the image attribute of said enemy should be deleted.

### #1stitchs

Posted 20 July 2012 - 12:43 PM

Also, quick question, what Graphics library are you using, because when you delete your enemy you never seem to free the memory associated with it's image. I know this may not be causing the issue with you crash, but it could lead to a number of memory leaks if not cleaned up properly. I'll make use of Allegro for this example as it is the one I'm most familiar with:

Delete_Function(Enemy* enemy_to_be_deleted){
destroy_bitmap(enemy_to_be_deleted->image);
delete enemy_to_be_deleted;
}


This is the order in which the image attribute of said enemy should be deleted.

PARTNERS