[edit: never mind]
For heaven's sake - get a decent editor!
Your run() function misses the closing '}'.
Also why are you spreading completely useless semicolons all over your code?
#ifdef WIN32#pragma comment(lib, "SDL.lib")#pragma comment(lib, "SDLmain.lib")#endif#include "SDL.h"#include <stdlib.h>; // <--- what is this semicolon for???void run(){ float start_time; start_time = SDL_GetTicks(); // loop while(true) // <--- ???? { float dtime; float end_time; float elapsed_time; float vvlosity; vvlosity = 5; SDL_Rect dest; dest.x = 2; dest.y = 2; end_time = SDL_GetTicks(); // now we have how much time passed in the last loop elapsed_time = end_time - start_time; // here's the new code, dtime must be a floating point number dtime = elapsed_time / 1000; // Get new start time start_time = SDL_GetTicks(); dest=dest + dtime *vvlosity; // end loop }} // <--- end run() function int main( int argc, char* argv[] ) { ; // <--- ???? // AFAIK you need to call SDL_Init() first... SDL_Surface * screen = SDL_SetVideoMode( 800,600, 24, SDL_ANYFORMAT|SDL_DOUBLEBUF ); SDL_Surface * img = SDL_LoadBMP( "filename.bmp" ); SDL_Rect dest; dest.x = 2; dest.y = 2; SDL_Event event; SDL_Event a; SDL_Event b; SDL_Event Event; SDL_Rect coord; coord.x = 200; coord.y = 500; // I didn't use SDL for years, but this is certainly wrong! // Why do you chenge the video mode again? SDL_Surface * tdisplay = SDL_SetVideoMode( 800,600,24,SDL_ANYFORMAT|SDL_DOUBLEBUF ); SDL_Surface * imi = SDL_LoadBMP( "ad.bmp" ); SDL_Surface * bckg = SDL_LoadBMP ( "bg.bmp" ); SDL_Flip( screen ); Uint32 now; ; // <--- ???? while(true) // <--- ???? { SDL_BlitSurface(img,NULL,screen, &dest); SDL_PollEvent(&event); if(event.type == SDL_MOUSEBUTTONDOWN) { if(event.button.button == SDL_BUTTON_LEFT) { SDL_BlitSurface(imi,NULL,tdisplay,&coord); SDL_Flip(tdisplay); ; // <--- ???? } } } if(event.type == SDL_QUIT) // <--- ???? { return 0; } SDL_Event up; while(true) // <--- ???? { if(up.type == SDL_KEYDOWN) { if(up.key.keysym.sym == SDLK_SPACE) { run(); } } } } atexit(SDL_Quit); // <--- ???? you already did that... return run(); ; // <--- ????}
No offense, but do you even have the slightest idea of what your code does? You have so many infinitive loops that just make no sense at all (marked by ????). And the program doesn't have any reasonable structure (ie. init SDL -> load surfaces -> event-loop -> exit).
Sorry to say that, but it seems you have absolutely no clue of what you are doing. Try to start from scratch by just writing a clean event loop.
[Edited by - darookie on October 1, 2004 11:59:43 AM]