A Simple SDL Sprite library
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
sprites
.gitignore Updated .gitignore Mar 21, 2013
Main.h
README.md
SDL.dll
Sprite.cpp
Sprite.h
cb.bmp
main.cpp
sdl_sprite.cbp
sdl_sprite.layout
sshot.PNG Initial Commit Mar 21, 2013

README.md

sdl_sprite

This is a simple(and old) Sprite class that I used for game development in C++ using SDL (www.libsdl.org). Features include sprite animation, rotation, stretching, transparencies, and other commonly used sprite functions.

I hope this is somewhat useful. The source is available and should be fairly simple to work with. Feel free to modify it however you want. please create an issue about any bugs are suggestions that you have. Thanks. Original blog post: http://kennycason.com/posts/2009-01-02-sprite-class-in-c-using-sdl.html

Compile & Run

g++ *.cpp -lSDL
./a.out

Usage

    // Initialize SDL, etc
   ...
   ...
   Sprite* s1 = new Sprite("sprites/samus_normal_run.bmp",10,60); // load a BMP that contains 10 frames
                                                // set the animation speed to 60 milliseconds
      // set RGB(255,0,255) as transparent, rotate 180 degrees, flip horizontal and reverse animation
  s1->setTransparency(255,0,255)->rotate180()->flipHorizontal()->reverseAnimation();
   // etc
    ...
    ...
 
    // Main loop
    // clear background to black, RGB(0,0,0)
    SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
    // animate and draw the sprite
    s1->animate()->draw(screen,0,0);
    SDL_Flip(screen);