I have searched here and the C++/SDL forums/help pages, but I haven't found any similar cases. However in Visual Studio 2012, it compiles, with no warnings and runs successfully. In Xcode it compiles, but throws some warnings up (although it still builds), but nothing happens when it's run. My code compiles in both Xcode 4.5 and Visual Studio 2010. I completely understand how this site works, so I'm not asking you to check my code. SDL_Delay((1000 / FRAMES_PER_SECOND) - fps.get_ticks()) If (fps.get_ticks() < 1000 / FRAMES_PER_SECOND) SDL_FillRect (screen, &wall, SDL_MapRGB(screen->format, 0x77, 0x77, 0x77)) SDL_FillRect(screen, &screen->clip_rect, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF)) Return the current time minus the start time Return the number of ticks when the timer was paused StartTicks = SDL_GetTicks() - pausedTicks PausedTicks = SDL_GetTicks() - startTicks If the timer is running and isn't already paused If (( box.y SCREEN_HEIGHT) || (check_collision(box, wall)))Īpply_surface(box.x, box.y, square, screen) If the square went too far up or down or has collided with the wall If (( box.x SCREEN_WIDTH ) || ( check_collision(box, wall))) If the square went too far to the left or right or has collided with the wall ![]() If there was a problem in loading the squareĬase SDLK_UP: yVel -= SQUARE_HEIGHT / 2 break Ĭase SDLK_DOWN: yVel += SQUARE_HEIGHT / 2 break Ĭase SDLK_LEFT: xVel -= SQUARE_WIDTH / 2 break Ĭase SDLK_RIGHT: xVel += SQUARE_WIDTH / 2 break Ĭase SDLK_UP: yVel += SQUARE_HEIGHT / 2 break Ĭase SDLK_DOWN: yVel -= SQUARE_HEIGHT / 2 break Ĭase SDLK_LEFT: xVel += SQUARE_WIDTH / 2 break Ĭase SDLK_RIGHT: xVel -= SQUARE_WIDTH / 2 break SDL_WM_SetCaption("Move the Square", NULL) If there was an error in setting up the screen Screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE) If (SDL_Init( SDL_INIT_EVERYTHING ) = -1) If none of the sides from A are outside B If any of the sides from A are outside of B SDL_BlitSurface(source, clip, destination, &offset) īool check_collision(SDL_Rect A, SDL_Rect B) Void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination, SDL_Rect* clip = NULL) SDL_SetColorKey(optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF)) OptimizedImage = SDL_DisplayFormat(loadedImage) LoadedImage = IMG_Load(filename.c_str()) The optimized surface that will be used ![]() SDL_Surface *load_image(std::string filename) The ticks stored when the timer was paused Takes key presses and adjusts the square's velocity
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |