Hmm, now I have an elementary question... I made a loop for the two drawimage calls:
Code:
for (int i=0; i<=1; i++) {
drawimage(block, 0, 0, MonsterList.at(i).spritew, MonsterList.at(i).spriteh, screen, MonsterList.at(i).xpos-screenx, MonsterList.at(i).ypos-screeny, 255);
}
Which works, so then I generalised to the size of the vector:
Code:
for (int i=0; i<=MonsterList.size()-1; i++) {
drawimage(block, 0, 0, MonsterList.at(i).spritew, MonsterList.at(i).spriteh, screen, MonsterList.at(i).xpos-screenx, MonsterList.at(i).ypos-screeny, 255);
}
And my compiler gave me a warning about comparison of signed and unsigned integer expressions. Which I thought was weird because I assumed the size method would return an int. Maybe I'm not really understanding what I'm doing. I tried:
Code:
int x = MonsterList.size() - 1;
for (int i=0; i<=x; i++) {
drawimage(block, 0, 0, MonsterList.at(i).spritew, MonsterList.at(i).spriteh, screen, MonsterList.at(i).xpos-screenx, MonsterList.at(i).ypos-screeny, 255);
}
And that also works fine. Am I doing something wrong?
I took a look into virtual functions, sounds interesting, I'm already kind of doing something similar because I have an Avatar class that's also derived from Creature. Both Avatar and Monster have a movement method but they aren't defined through Creature, I just created a moveavatar() in Avatar and a movemonster() in Monster. What's the difference between doing that and creating a virtual move() in Creature and then defining it differently in Monster and Avatar? I mean, the names were just what I happened to pick, if I renamed both moveavatar() and movemonster() to move() what would the difference be then?
Thanks for all your help.