produces:"Expected constructor destructor or type conversion before '.' token'.Code:SDL_Rect r;
r.x=16;//Removing this line clears errors
MinGW, WinXP
Printable View
produces:"Expected constructor destructor or type conversion before '.' token'.Code:SDL_Rect r;
r.x=16;//Removing this line clears errors
MinGW, WinXP
That code on its own looks fine. Can you show some of the surrounding code?
main.cpp:
Code:#include "includes.h"
SDL_Rect r;
r.x=16;
int main ( int argc, char** argv )
{
SDL_Init(SDL_INIT_VIDEO);
if(Init(1)==false)
{
printf(SDL_GetError());
return 2;
}
atexit(SDL_Quit);
SDL_Surface* screen =SDL_SetVideoMode(600, 480, 32,SDL_HWSURFACE|SDL_DOUBLEBUF);
if ( !screen )
{
printf("Unable to set 640x480 video: %s\n", SDL_GetError());
return 1;
}
SDL_Surface *bg=load_Image("C:\\Documents and Settings\\Make.YOUR-6JNHHU0520\\Desktop\\C++\\SDL\\Game Engine\\img\\sky.png");
SDL_Surface *sprites=load_Image("C:\\Documents and Settings\\Make.YOUR-6JNHHU0520\\Desktop\\sprite sheets\\finalfantasy.gif");
AppSurface(0,0,bg,screen,NULL);
AppSurface(250,250,sprites,screen,NULL);
//
//SDL_BlitSurface(bg,NULL,screen,&r);
bool done = false;
while (!done)
{
SDL_Flip(screen);
SDL_Event event;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
done = true;
break;
// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_ESCAPE)
done = true;
break;
}
} // end switch
} // end of message processing
}
SDL_FreeSurface(bg);
SDL_FreeSurface(kube);
printf("Exited cleanly\n");
return 0;
}
You can't put actual statements, like r.x = 16 outside of function bodies. If you move that to main, it will fix that error.
Declaring your SDL_Rect r as a global variable is a bad choice (in fact, i believe firmly that global variable should never be used except in really special case when there's no others options).
That said, CrazyNorman gave the answer (answer i didn't even thing heh).
It's one at night. I didn't really feel like going into the code too much.
Yes, that was the problem, thank ppl :D