Main method: #include #include #include "SDL.h" #include "object.h" using namespace std; /*class Object{ int foo; public: Object(){ foo = 1024; } };*/ int main(int argc, char *argv[]){ cout <<"Initializing SDL." << endl; int quit = 0; SDL_Event event; SDL_Surface *screen; if(SDL_Init(SDL_INIT_VIDEO)< 0) { cout <<"Could not initialize SDL:" << SDL_GetError() << endl; SDL_Quit(); return 2; } else { cout << "SDL initialized."; } screen = SDL_SetVideoMode(800,600,0,SDL_SWSURFACE); if(screen == NULL){ cout <<"Error creating surface:" << SDL_GetError() << endl; SDL_Quit(); return 2; } Object ball; while(!quit){ while(SDL_PollEvent(&event)){ switch(event.type){ case SDL_QUIT : quit = 1; break; case SDLK_LEFT : break; default : break; } } } SDL_Quit(); return 0; } Object.h: #ifndef OBJECT_H #define OBJECT_H using namespace std; class Object{ public: Object(); Object(long ID); Object(long ID,int position[2]); void setXVel(int velocity); void setYVel(int velocity); void setPos(int position[2]); void updatePos(); }; #endif object.cpp: #include "SDL.h" using namespace std; class Object{ int xvel,yvel; int pos[2]; //(x,y) format - pos[0] = x, pos[1] = y long ident; public: Object(){ xvel = yvel = 0; } Object(long ID){ ident = ID; xvel = yvel = 0; } Object(long ID,int position[2]){ ident = ID; setPos(position); xvel = yvel = 0; } void setXVel(int vel){ xvel = vel; } void setYVel(int vel){ yvel = vel; } void updatePos(){ pos[0] += xvel; pos[1] += yvel; } void setPos(int position[2]){ pos[0] = position[0]; pos[1] = position[1]; } virtual ~Object(); };