Hopelesss, help needed.

Started by
0 comments, last by Ozguxxx 21 years, 8 months ago
Hi everybody. I am working on a linked list class and the following code snippet is a part of it. This code is supposed to remove an element of linked list. The element is specified by its index in the list. DXBullet is the class which represents a node in the linked list. getNextBullet() function simply returns DXBullet* lpNextBullet (next bullet''s pointer in the list). firstBullet is a variable (whose type is DXBullet*) in list class. Code seems to be working alright with a console application (under windows 98, Visual C++ 6.0) however,when I try to use this code with the game(with DirectX) demo I am trying to implement, when the first bullet is removed, third bullet is also removed from the list. I mean, for instance you shoot three bullets, when the first bullet leaves teh screen, it should be removed from list and its resources should be freed. But when the first bullet leaves screen third bullet that you shot also disappeares from screen.(I don''t know why). This should mean that when first bullet is removed from list, in some way, third bullet is also removed from te list. Please tell me everything that you can think of about the problem, I am very very hopelesssss. Any idea is welcome. Thank you. void removeBullet(int index) { DXBullet* currentBullet = this->firstBullet; if(index == 0) { if(this->numberOfBullets != 1) { DXBullet* newFirst = this->firstBullet->getNextBullet(); delete(this->firstBullet); this->firstBullet = NULL; this->firstBullet = newFirst; this->numberOfBullets--; } else { delete(this->firstBullet); this->firstBullet = NULL; this->numberOfBullets--; } } else { ...
No Sign!!!
Advertisement
Cross post. Closed

____________________________________________________________
www.elf-stone.com

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

This topic is closed to new replies.

Advertisement