Hi, i'm programming in c++ for the first time in a long time and i receive this error message when building my project:
levelTest.cpp||In member function 'virtual int levelTest::play()':|
levelTest.cpp|80|error: 'maverickWaitForFrame' was not declared in this scope|
Here is LevelTest.cpp where the error directs me:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#include "levelTest.h"
#include <SDL/SDL.h>
#include <vector>
#include "maverickEngine.h"
using namespace std;
levelTest::levelTest(maverickControlManagerObject *manager)
{
controlObject = manager;
background = SDL_LoadBMP("startScreen.bmp");
}
void levelTest::display(SDL_Surface* surf){
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = 1280;
rect.h = 800;
SDL_BlitSurface(background, NULL, surf, &rect);
}
int levelTest::play(){
Uint32 frameTicks = 0;
for( ; ; ){
frameTicks = SDL_GetTicks();
background = SDL_GetVideoSurface();
controlObject->updateControlState();
unsigned int control = controlObject->getControlState();
int gameVectorSize = gameObjects.size();
for(int x=0; x<gameVectorSize; x++){
gameObjects[x]->setBehaviorIndex(control);
}
for(int x=0; x<gameVectorSize; x++){
gameObjects[x]->behave();
}
/*
Here will be the code that updates the screen by calling the
animation function for each animated object. These animations
will be handled inside of the objects as needed.
*/
int aniVectorSize = animatedObjects.size();
for(int x=0; x<aniVectorSize; x++){
animatedObjects[x]->display(background);
}
SDL_Flip(background);
SDL_FreeSurface(background);
maverickWaitForFrame(frameTicks); <<<<<<<<< THIS LINE <<<<<<<<<<<<<<<
}
return 0;
}
|
Here is the header file for LevelTest.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#include "maverickGameObject.h"
#include "maverickControlManagerObject.h"
#include "maverickAnimatedObject.h"
#include "maverickTextCharacterObject.h"
#include "maverickStartMenuObject.h"
#include "maverickCreditManager.h"
#include "maverickEngine.h"
#include "levelTest.h"
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[]){
//vector<maverickGameObject*> gameObjects;
//vector<maverickAnimatedObject*> animatedObjects;
maverickControlManagerObject controlObject;
//maverickStartMenuObject startMenu(&animatedObjects, &gameObjects);
//maverickCreditManager creditObject(&animatedObjects, &gameObjects);
SDL_AudioSpec audioFormat;
maverickInitialize(audioFormat, controlObject.player1, controlObject.player2);
levelTest firstLevel(&controlObject);
maverickQuit();
return 0;
}
|
And because levelTest inherits from level here is level.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
#include "level.h"
level::level()
{
}
void level::setBehaviorIndex(unsigned int index){}
void level::display(SDL_Surface* surf){
SDL_Rect rect;
rect.x = 0;
rect.y = 0;
rect.w = 1280;
rect.h = 800;
SDL_BlitSurface(background, NULL, surf, &rect);
}
void level::behave()
{
//behaviorIndex
int behavior = 0;
behavior = behaviorIndex;
switch(behavior)
{
case 1:
{
//set index 2
setBehaviorIndex(2);
}
case 2:
{
//set index 3
setBehaviorIndex(3);
}
case 3:
{
//set index 4
setBehaviorIndex(4);
}
case 4:
{
//set index 5
setBehaviorIndex(5);
}
case 5:
{
//set index 6
setBehaviorIndex(6);
}
case 6:
{
//set index 7
setBehaviorIndex(7);
}
case 7:
{
//set index 8
setBehaviorIndex(8);
}
case 8:
{
//set index 9
setBehaviorIndex(9);
}
case 9:
{
//set index 10
setBehaviorIndex(10);
}
case 10:
{
//set index 11
setBehaviorIndex(11);
}
case 11:
{
//set index 12
setBehaviorIndex(12);
}
case 12:
{
//set index 13
setBehaviorIndex(13);
}
case 13:
{
//set index 14
setBehaviorIndex(14);
}
case 14:
{
//set index 15
setBehaviorIndex(15);
}
case 15:
{
//set index 16
setBehaviorIndex(16);
}
case 16:
{
//set index 17
setBehaviorIndex(17);
}
case 17:
{
//set index 18
setBehaviorIndex(18);
}
case 18:
{
//set index 19
setBehaviorIndex(19);
}
case 19:
{
//set index 20
setBehaviorIndex(20);
}
case 20:
{
//set index 21
setBehaviorIndex(21);
}
case 21:
{
//set index 22
setBehaviorIndex(22);
}
case 22:
{
//set index 23
setBehaviorIndex(23);
}
case 23:
{
//set index 24
setBehaviorIndex(24);
}
case 24:
{
//set index 25
setBehaviorIndex(25);
}
case 25:
{
//set index 26
setBehaviorIndex(26);
}
case 26:
{
//set index 27
setBehaviorIndex(27);
}
case 27:
{
//set index 28
setBehaviorIndex(28);
}
case 28:
{
//set index 29
setBehaviorIndex(29);
}
case 29:
{
//set index 30
setBehaviorIndex(30);
}
case 30:
{
//incriment x animation index to the next step(or back to 0 if the index has reached 5)
//set behaviorIndex back to 1
int index, yindex;
index = xIndex;
yindex = yIndex;
if(index == 5)
{
//animation index goes back to 0
setAnimationIndex(0, yindex);
}
else
{
//animation index is incrimented
index++;
setAnimationIndex(index, yindex);
}
}
}
}
void level::setAnimationIndex(int x, int y){
xIndex = x;
yIndex = y;
}
|
and level.h
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#ifndef LEVEL_H
#define LEVEL_H
#include "maverickControlManagerObject.h"
#include "maverickAnimatedObject.h"
#include "maverickEngine.h"
#include <vector>
using namespace std;
class level
{
public:
int xSize;
int ySize;
int xIndex;
int yIndex;
int xPosition;
int yPosition;
int objectLayer;
int behaviorIndex;
level();
void display(SDL_Surface* surf);
void behave();
void setBehaviorIndex(unsigned int index);
void setAnimationIndex(int x, int y);
SDL_Surface* background;
vector<maverickGameObject*> gameObjects;
vector<maverickAnimatedObject*> animatedObjects;
virtual int play() = 0;
};
#endif
|
and here is maverickEngine.cpp where maverickWaitForFrame is declared
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include "maverickEngine.h"
#include <iostream>
#include <SDL/SDL.h>
using namespace std;
void maverickEngine::maverickEngine(){}
void maverickEngine::maverickInitialize(SDL_AudioSpec& spec, SDL_Joystick* stick1, SDL_Joystick* stick2){
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK);
SDL_SetVideoMode(1280, 800, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
if(SDL_NumJoysticks() == 0){
stick1 = NULL;
stick2 = NULL;
}
else if(SDL_NumJoysticks() == 1){
SDL_JoystickEventState(SDL_ENABLE);
stick1 = SDL_JoystickOpen(0);
}
else{
SDL_JoystickEventState(SDL_ENABLE);
stick1 = SDL_JoystickOpen(0);
stick2 = SDL_JoystickOpen(1);
}
}
void maverickEngine::maverickQuit(){
SDL_Quit();
}
void maverickEngine::maverickWaitForFrame(Uint32 frameTicks){
Uint32 currentTicks = SDL_GetTicks();
while(frameTicks/currentTicks > 1/30){
currentTicks = SDL_GetTicks();
}
}
|
Thanks in advance for any help or insight into what my problem could be, it's much appreciated.
also, i can include marverickEngine.h and main.cpp if necessary but at the moment i don't have any characters left for submitting