Tick Tock Car Race and source code – Windows

So here is what I put together for the SDLTutorials.com car contest. Its pre compiled for windows but includes the sorce code so you should be able to get it going on any other platform with SDL support. Its a bit of a mess but its functional and complete. Its looking like the deadline will likely be extended so I might go back and fix it up and add some better commenting.

Either way I’ll port it to Wii sooner or later. Probably later rather then sooner though. I want to do a quick port/remake of Don’t Get Crushed for PS3, then I want to get the demo for The Prophecy complete which I have been repeatedly intending to do and then delaying, finally I really want to finish some things in Cubicle Shooter and by the time I finally finish those three things I’ll probably have seen something shiny to spend a decade chasing. Yay procrastination.

The music used in the game is Tarmac by et_.

Download the Windows version and source code
Alternate links

20 thoughts on “Tick Tock Car Race and source code – Windows”

    1. I’ll definitely consider it. I’ve been sticking to 2D SDL stuff but there is an OpenGL port for homebrew Wii development so 3D is possible and a simple game like that would be a good place to start with it.

  1. Hi
    I want to run the code to see SDL in action but I’ve got the following error
    game_text.h
    line 12:
    Uint32 red=SDL_MapRGB(font_sprite->format,255,0,0);

    font_sprite could not be loaded (->NULL)

    media folder and files seem to me to be at their place
    How could I solve this? Thank you

    1. If you comment out everything in the font related functions does the game work or does it fail when loading the other images also?

      I’m assuming the problem must be something relating to either SDL_Image or the address that its trying to load the files from…

  2. Ok if I comment the content in Game_setuptext the next error I get is in GameSetup.h car_sprite at line 71.
    It looks like it cannot find the “Media” path even if for the font I used the full path “D:/Programming/TickTockCarRace/Source/Media/font.png”
    Any idea?

    1. try converting the image to BMP format
      then change IMG_LoadOptimizeAlpha to SDL_LoadBMP
      and obviously change the address to D:/Programming/TickTockCarRace/Source/Media/font.bmp or whatever the correct address would be for the bmp version of the image.

      That way it wont be using SDL_image so you can rule that out as a potential cause of the problem.

      It shouldn’t really matter but out of curiosity what operating system are you using?

  3. I saw you programmed it in VC++ and I decided to use win 7 (VC++2008 express) not to bother with portability issues.

    I just tried your suggestion and it seems to work. Actually substituting the font.png and the fontsmall.png with bmp let the program run up to GameSetup.h car_sprite at line 71.
    It seems like IMG_LoadOptimizeAlpha(“Media/car.png”) is not working either. I will try to change all png and update the corresponding part of code.
    In your opinion is this an SDL bug or something related to my pc?

    1. Do you have SDL_image.dll in the same folder as the executable? If not then its absence could be the problem. It seems to me like it must be something relating to SDL_image.

      1. yes it was already in your compressed file.

        Actually now I can make it run with the changes I said befor, but everything is black (only the lap time is diplaying)

      2. I wonder if I need to recompile the SDL_image.dll for 32 bit and 64 bit.
        I am currentlly compiling in 32 bit and maybe the dll is in 64bit.

        1. are you running 32bit or 64 bit windows? I’m using 32 bit Windows 7 right now (though I was running XP when I actually made the game) and all the dlls included are 32 bit.

          Here is an obvious question that i really should have asked earlier: did the included pre compiled executable crash for you also or is it only when you compile the game yourself?

          1. Indeed the pre compiled executable crash, that’s why I am thinking about a 32-64bit issue. Is this also what you have in mind?

  4. Ok maybe this is going to be boring for you but I am really trying to make it work. I compiled SDL 32bit on my system onVC++2008 Express.
    I’ve got only
    * SDL.dll
    * SDL.lib
    * SDLmain.lib
    Where is the SDL_image coming from?
    Anyway I put those file in the lib directory but nothing changed

  5. So I made it work. I fixed all the paths, I compiled my own SDL and SDL_image. I downloaded libpng and zlib.
    Now the game compile and runs properly. Thank you for your walkthrough, now I can understand better how SDL work in practice!!

Comments are closed.