well I am trying to solve it. Heres what Im doing now. I scrapped the swordbeam and all projectiles from my game. Now im reimplementing the octorock class with better incapsulated code:
class OCTOROCK
{
private:
SPRITE sprite;
public:
//Constructor
OCTOROCK()
{
}
//Destructor
~OCTOROCK()
{
}
//Set the position of the octorock
void setPosition(int x, int y)
{
sprite.x = x;
sprite.y = y;
}
//Set the dimensions
void setDimensions(int width, int height)
{
sprite.width = width;
sprite.height = height;
}
//Set the frames
void setFrames(int curframe, int maxframe, int framecount, int framedelay)
{
sprite.curframe = curframe;
sprite.maxframe = maxframe;
sprite.framecount = framecount;
sprite.framedelay = framedelay;
}
//Set the speed of the octorock
void setSpeed(int speed)
{
sprite.xspeed = speed;
sprite.yspeed = speed;
}
//set the direction of the octorock
void setDirection(int dir)
{
sprite.dir = dir;
}
//is it alive?
void isAlive(int alive)
{
sprite.alive = alive;
}
//moves the octorock
void moveOctorock()
{
if(sprite.dir == RIGHT)
{
sprite.x += sprite.xspeed;
sprite.y += 0;
sprite.curframe = 4;
}
else if(sprite.dir == LEFT)
{
sprite.x -= sprite.xspeed;
sprite.y += 0;
sprite.curframe = 6;
}
else if(sprite.dir == UP)
{
sprite.x += 0;
sprite.y -= sprite.yspeed;
sprite.curframe = 2;
}
else if(sprite.dir == DOWN)
{
sprite.x += 0;
sprite.y += sprite.yspeed;
sprite.curframe = 0;
}
}
//Draw the octorock
void drawOctorock()
{
al_draw_bitmap(octorock_images[sprite.curframe],
sprite.x - mapxoff, sprite.y - mapyoff, NULL);
}
};