Animated Frames by infinite people19th May 2009 22:32
|
---|
Summary An example of animated frames. Another alternative to using animated sprites Description This example uses a sequence of images to play a custom animation. It is an alternative to creating animated sprites. the function dbLoadImage(imageName, imageIndex) is used to load the images and assign them an index that can be called in the main loop to produce a play back effect. Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com // Dark GDK - The Game Creators - www.thegamecreators.com // the wizard has created a very simple project that uses Dark GDK // it contains the basic code for a GDK application // whenever using Dark GDK you must ensure you include the header file #include "DarkGDK.h" // the main entry point for the application is this function void DarkGDK ( void ) { // turn on sync rate and set maximum rate to 60 fps dbSyncOn ( ); dbSyncRate ( 60 ); //load some images and we go hello world dbLoadImage("Animation0000.tga", 1); dbLoadImage("Animation0010.tga", 2); dbLoadImage("Animation0020.tga", 3); dbLoadImage("Animation0030.tga", 4); dbLoadImage("Animation0040.tga", 5); dbLoadImage("Animation0050.tga", 6); dbLoadImage("Animation0060.tga", 7); dbLoadImage("Animation0070.tga", 8); dbLoadImage("Animation0080.tga", 9); dbLoadImage("Animation0090.tga", 10); dbLoadImage("Animation0100.tga", 11); dbSprite(1,0,0,1); dbOffsetSprite(1,50,100); int i = 1; float interval = 25.0f; float timer = 0.0f; // our main loop while ( LoopGDK ( ) ) { // update the screen dbSprite(1,0,0,i); timer += dbTimer()%10; if(timer > interval) { (i < 12)? i++ : i = 1; timer = 0.0f; } dbSync ( ); } // return back to windows return; } |