/* Filename: AnimatedSprite.cpp * * Author: Br. Isidore Minerd * * Date: July 31, 2009 * * Description: This very simple 3D application moves a cube back * and forth along its default forward path, switching * direction every 90 frames (~3 seconds). * Adapted from example found at: * http://darkgdk.wikia.com/wiki/Basic_Program */ #include "DarkGDK.h" void DarkGDK ( void ) { long frameNum = 0; // Used to keep track of how long we have been running double stepValue = 0.5; // The amount to move each time int frameMultiplier = 1; // 1 => move forward; -1 => move backward // Set our maximum frame rate dbSyncOn ( ); dbSyncRate ( 30 ); dbSetWindowTitle("A Moving Cube"); // Create a cube at the origin and position the camera on the x,y,z axes // We position ourselves offset from x=0,y=0 in order to have some perspective // on the cube dbMakeObjectCube ( 1, 1); dbPositionCamera ( 5, 5, -10 ); // The main Dark GDK while ( LoopGDK ( ) ) { // Move forward / backward depending on the frame multiplier dbMoveObject( 1, frameMultiplier * stepValue ); dbSync ( ); frameNum++; // If frame / 90 yields no remainder, change direction. if(frameNum % 90 == 0) { frameMultiplier *= -1; } } return; }