Hi I'm new to this forum so if anything I do is a problem I'm quite sorry.
I am programming a game at the moment to consolidate my c++ skills, improve and have something to extend when I decide to learn graphical programming. However I have come across a brick wall and although i could come up with a work-around I would like to solve my problem rather than run away from it.
On to the problem!
I'm trying to create a function that can check if any sprite classes in a list are located at the position passed into the function and then return the address of the class so that it can be edited.
If I have found a 'sprite' which has the position desired I will return true and return the address of the 'sprite' class by using the pointer.
My problem is assigning the address of the 'sprite' class to the pointer sent in the parameters.
I'm am not sure what code needs to go there. My ideas have just caused compile errors.Code:bool sprite::checkSpritePos(std::list<sprite*> spriteList, int xpos, int ypos, sprite *spriteAddress) { std::list<sprite *>::iterator Iter; for (Iter = spriteList.begin(); Iter != spriteList.end(); Iter++) { if ((int)((*Iter)->getX()) == xpos && (int)((*Iter)->getY()) == ypos) { // need to copy the address of the desired class to a pointer return true; } } return false; }
Any help would be very appreciated and for any time spent trying to help me.