Devcpp: parse error before ';' token

This is a discussion on Devcpp: parse error before ';' token within the C++ Programming forums, part of the General Programming Boards category; >The old version at my website (the one that dosn't work) explains what everythings doing. ...nevermind....

  1. #16
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >The old version at my website (the one that dosn't work) explains what everythings doing.
    ...nevermind.
    My best code is written with the delete key.

  2. #17
    Registered User
    Join Date
    Dec 2003
    Posts
    101
    >...nevermind.

    Was that a sigh? Btw, I added coments to the oop version...

    EDIT: The program now keeps track of who atacks who and informs the person atacked the event happened.
    Last edited by 1veedo; 12-20-2003 at 02:40 PM.
    --

  3. #18
    Registered User
    Join Date
    Dec 2003
    Posts
    101

    SDL problem source

    I would have edited my above post, but i cant. This wouldn't be here, but I need to show some people in a chat room my source. That's not to say you can't hepl though.
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <iostream>//dont need
    
    #include <SDL/SDL.h>
    using namespace std; //yes I know
    
    class m
    {
          SDL_Surface *back;
          SDL_Surface *image;
          SDL_Surface *screen;
          
          int xpos, ypos;
          
       public:
          //void DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G
             //            , Uint8 B);
          void Slock(SDL_Surface *screen);
          void Sulock(SDL_Surface *screen);
          int mm(int);
          m(int);
          int InitImages();
          int SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst
                              , SDL_Rect *dstrect);
          void DrawIMG(SDL_Surface *img, int x, int y);
          void DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2
                       , int y2);
          void DrawBG();
          void DrawScene();
    
    };
    
    m::m(int o)
    {
       int t = 0;
       xpos = 0, ypos = 0;
       m::mm(t);
    }
    
    int m::mm(int o)
    {
       Uint8* keys;
       if ( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 )
       {
          printf("Unable to init SDL: %s\n", SDL_GetError());
          exit(1);
       }
       atexit(SDL_Quit);
    
       screen=SDL_SetVideoMode(640,480,32,SDL_HWSURFACE|SDL_DOUBLEBUF);
       if ( screen == NULL )
       {
          printf("Unable to set 640x480 video: %s\n", SDL_GetError());
          exit(1);
       }
       
       InitImages();
       DrawBG();
       
       int done=0;
    
       while(done == 0)
       {
          SDL_Event event;
    
          while ( SDL_PollEvent(&event) )
          {
             if ( event.type == SDL_QUIT )  {  done = 1;  }
    
             if ( event.type == SDL_KEYDOWN )
             {
                if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
             }
          }
          keys = SDL_GetKeyState(NULL);
          if ( keys[SDLK_UP] ) { ypos -= 1; }
          if ( keys[SDLK_DOWN] ) { ypos += 1; }
          if ( keys[SDLK_LEFT] ) { xpos -= 1; }
          if ( keys[SDLK_RIGHT] ) { xpos += 1; }
          
          DrawScene();
       }
       return 0;
    }
    
    void m::Slock(SDL_Surface *screen)
    {
       if ( SDL_MUSTLOCK(screen) )
       {
          if ( SDL_LockSurface(screen) < 0 )
          {
             return;
          }
       }
    }
    
    void m::Sulock(SDL_Surface *screen)
    {
       if ( SDL_MUSTLOCK(screen) )
       {
          SDL_UnlockSurface(screen);
       }
    }
    
    /*void m::DrawPixel(SDL_Surface *screen, int x, int y,
                                        Uint8 R, Uint8 G, Uint8 B)
    {
      Uint32 color = SDL_MapRGB(screen->format, R, G, B);
      switch (screen->format->BytesPerPixel)
      {
        case 1: // Assuming 8-bpp
          {
            Uint8 *bufp;
            bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
            *bufp = color;
          }
          break;
        case 2: // Probably 15-bpp or 16-bpp
          {
            Uint16 *bufp;
            bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;
            *bufp = color;
          }
          break;
        case 3: // Slow 24-bpp mode, usually not used
          {
            Uint8 *bufp;
            bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;
            if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
            {
              bufp[0] = color;
              bufp[1] = color >> 8;
              bufp[2] = color >> 16;
            } else {
              bufp[2] = color;
              bufp[1] = color >> 8;
              bufp[0] = color >> 16;
            }
          }
          break;
        case 4: // Probably 32-bpp
          {
            Uint32 *bufp;
            bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;
            *bufp = color;
          }
          break;
      }
    }*/
    
    int m::InitImages()
    {
       back = SDL_LoadBMP("bg.bmp");
       image = SDL_LoadBMP("image.bmp");
       return 0;
    }
    
    void m::DrawIMG(SDL_Surface *img, int x, int y)
    {
       SDL_Rect dest;
       dest.x = x;
       dest.y = y;
       SDL_BlitSurface(img, NULL, screen, &dest);
    }
    
    void m::DrawIMG(SDL_Surface *img, int x, int y, int w, int h, int x2, int y2)
    {
      SDL_Rect dest;
      dest.x = x;
      dest.y = y;
      SDL_Rect dest2;
      dest2.x = x2;
      dest2.y = y2;
      dest2.w = w;
      dest2.h = h;
      SDL_BlitSurface(img, &dest2, screen, &dest);
    }
    
    void m::DrawBG()
    {
       DrawIMG(back, 0, 0);
    }
    
    void m::DrawScene()
    {
       DrawIMG(back, xpos-2, ypos-2, 132, 132, xpos-2, ypos-2);
       DrawIMG(image, xpos, ypos);
    
       SDL_Flip(screen);
    }
    
    
    int main()
    {
       int t = 0;
       m m(t);
       return 0;
    }
    It came from here: http://cone3d.gamedev.net/cgi-bin/in...ls/gfxsdl/tut2
    I tried to make it oop, instead of structured like the tutorial has it. Anyhow, here are my linking errors
    Code:
     
    [Linker error] undefined reference to `m::SDL_UpperBlit(SDL_Surface*, SDL_Rect*, SDL_Surface*, SDL_Rect*)'
     
    [Linker error] undefined reference to `m::SDL_UpperBlit(SDL_Surface*, SDL_Rect*, SDL_Surface*, SDL_Rect*)'
    
     
    [Linker error] undefined reference to `SDL_main'
    Yes, I have '-lmingw32
    -lSDLmain
    -lSDL'
    Last edited by 1veedo; 12-22-2003 at 05:10 PM.
    --

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. C++ compilation issues
    By Rupan in forum C++ Programming
    Replies: 1
    Last Post: 08-22-2005, 06:45 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM
  5. Parsing and Tokens (strtok)
    By readerwhiz in forum C Programming
    Replies: 6
    Last Post: 04-22-2002, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21