Help with my timer class..

Started by
6 comments, last by willthiswork89 18 years, 4 months ago
okay i got my timer class and its been working for quite some time and all of the sudden im getting these errors 4 C:\Documents and Settings\Kevin Stowe\Desktop\SDLShit\Project\TIMERC.h expected init-declarator before "class" 4 C:\Documents and Settings\Kevin Stowe\Desktop\SDLShit\Project\TIMERC.h expected `,' or `;' before "class" heres my code that it is saying is bad

#ifndef TIMERC_H
#define TIMERC_H

class Timer
{
 private:
        int StartTicks;
        
        int PausedTicks;
        
        bool Paused;
        bool Started;      
public:
       Timer();
       
       void start();
       void stop();
       void pause();
       void unpause();
       
       int GetTicks();
       
       bool IsStarted();
       bool IsPaused();  
};

#endif

Advertisement
Can you show the file you're including the header in? You probably made a mistake in there as you header file should really compile...
Usually what I've found with problems like this is that most likely the problem is in a class including TIMERC.h

Look at another a .h file, before the #include "TIMERC.h" - to see if there's another include to another class that is missing a ; at the end of the class definition...
this is the only thing that is including the timer class..

#include "SDLENGINE.h"#include "TIMERC.h"#include "SQUARE.h"#include <SDL/SDL.h>#include <SDL/SDL_ttf.h>using namespace std;SDL_Surface* screen;SDL_Surface* background;SDL_Surface* text;Square mySquare(0,0);Square otherSquare(20,20);SDL_Rect wall;SDL_Color textColor = {255,255,255};SDL_Event event;TTF_Font* font;bool quit = false;int frame = 0;void Load_Files();void Clean_Up();int main(int argc,char* args[]){screen = init();if(screen == NULL){printf("failed to init!");return 1;}Load_Files();Timer fps;wall.x = 300;wall.y = 40;wall.w = 40;wall.h = 400;fps.start();while(quit == false){fps.start();while(SDL_PollEvent(&event)){mySquare.handle_input(event);if(event.type == SDL_QUIT){     quit = true;}}SDL_FillRect(screen,&screen->clip_rect,0xFFFFFF);SDL_FillRect(screen,&wall, 0x777777);mySquare.move(otherSquare.get_rects());mySquare.show(screen);otherSquare.show(screen);if(SDL_Flip(screen) == -1){return 1;}frame++;while (fps.GetTicks() < 1000 / FPS){      }}Clean_Up();}void Load_Files(){ background = Load_Image("bg.bmp");   font = TTF_OpenFont("2.ttf",28) ; if(background == NULL){printf("background turned out null!");return;}if(font == NULL){  printf("font turned out null!");return;}      }void Clean_Up(){SDL_FreeSurface(background);SDL_FreeSurface(text);TTF_CloseFont(font);TTF_Quit();SDL_Quit();}
Your errors imply that you forgot to put a ; in the SDLENGINE.H header. Can you post that too?
oh well i guess im going to start over with my main, i really have been just wanting to build an SDL engine for my games, i have my timer class, and my sdlengine which sets the sdl, loads images, and applies them so really the collision detection is all i need.
Just for the heck of it, try including "SDLENGINE.h" after "TIMERC.h" and see what happens there... if you start getting problems from SQUARE.h, then you know you have a syntax problem somewhere in SDLENGINE.h
okay i fixed it thanks guys

This topic is closed to new replies.

Advertisement