Oookay... well here is the Call Stack I have been getting:
> msvcp110d.dll!std::_Debug_message(const wchar_t * message, const wchar_t * file, unsigned int line) Line 15 C++
SFML Test 2.exe!std::vector<sf::Sprite,std::allocator<sf::Sprite> >::operator[](unsigned int _Pos) Line 1140 C++
SFML Test 2.exe!Animation::getCurrentSprite() Line 167 C++
SFML Test 2.exe!Chao::getCurrentSprite() Line 170 C++
SFML Test 2.exe!main() Line 113 C++
SFML Test 2.exe!__tmainCRTStartup() Line 536 C
SFML Test 2.exe!mainCRTStartup() Line 377 C
kernel32.dll!7602338a() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!77669f72() Unknown
ntdll.dll!77669f45() Unknown
As for the methods that would apply, this is the update methods for
Animation:
void Animation::update(clock_t currentTime) {
if(running == true) {
if( (long)(currentTime - lastChanged) >= frameSpeedDelay) {
currentFrame++;
lastChanged = currentTime;
}
if((size_t)currentFrame >= sprites.size() && loop == true) {
currentFrame = 0;
} else if((size_t)currentFrame >= sprites.size() && loop == false) {
currentFrame = sprites.size()-1;
stop();
}
} else {
lastChanged = currentTime;
}
}
and Chao:
void Chao::update(clock_t currentTime) {
if( (currentTime - lastMoveDecision) >= 5000) {
int random = rand() % animations.size();
animations[currentAnimation].stop();
animations[currentAnimation].hide();
switch(random) {
case 0: //stand still
currentAnimation = 0;
xSpeed = 0;
ySpeed = 0;
break;
case 1: //mostly leftward movement
currentAnimation = 1;
setTwoSpeedsOneLesser(xSpeed, ySpeed, false, randBool());
break;
case 2: //mostly rightward movement
currentAnimation = 2;
setTwoSpeedsOneLesser(xSpeed, ySpeed, true, randBool());
break;
case 3: //mostly upward movement
setTwoSpeedsOneLesser(ySpeed, xSpeed, false, randBool());
currentAnimation = 3;
break;
case 4: //mostly downward movement
setTwoSpeedsOneLesser(ySpeed, xSpeed, true, randBool());
currentAnimation = 4;
break;
default: //stand still
currentAnimation = 0;
xSpeed = 0;
ySpeed = 0;
break;
}
animations[currentAnimation].start(currentTime);
animations[currentAnimation].show();
lastMoveDecision = currentTime;
} else {
float newX = xCor + xSpeed;
float newY = yCor + ySpeed;
animations[currentAnimation].update(currentTime);
if(newX + (22 * xScale) >= endXWall) {
newX = endXWall - (22 * xScale);
} else if(newX < 0) {
newX = 0;
}
if(newY + (25 *yScale) >= endYWall) {
newY = endYWall - (25*yScale);
} else if(newY < 0) {
newY = 0;
}
xCor = newX;
yCor = newY;
keepImagesSamePosScale();
}
cout << "Current Animation: " << currentAnimation << "\n";
}
I have since originally posting fixed a small part of the problem, the error is now a "vector subscript out of range" and still breaks into SFML.
But still, it either A) shows white boxes from the images drawn out of the chao class... or B) crashes and gives me the as mentioned error.
as for the code I've left out in chao and main classes, as your "minimal complete" guide, I was attempting to minimalize how much code was shown, as much of it could be considered repeat with slightly different parameters; and thus could be overwhelming.
If you would like me to include the initilization in it's complete form, I can.
The two methods that the chao update class calls within itself are:
keepImageSamePosScale():
void Chao::keepImagesSamePosScale() {
for(size_t i = 0; i < animations.size(); i++) {
animations.setPosition(xCor, yCor);
animations.setScale(xScale, yScale);
animations.setDelay(frameSpeed);
}
}
This method is intended to keep all the animations with the same position, scale and delay speed.
setTwoSpeedsOneLesser:
void Chao::setTwoSpeedsOneLesser(float& greater, float& lesser, bool greaterPos, bool lesserPos) {
greater = (float)(1 + (rand() % 2));
if(greater > 0) {
lesser = (float)(rand() % (int)greater);
} else {
lesser = 0;
}
if(greaterPos == false) {
greater = greater * -1;
} if(lesserPos == false) {
lesser = lesser * -1;
}
}
which is suppose to generate a random value for both the x and y speeds.
and then randBool() is just suppose to generate one of two numbers and create a true false value.