// Better animation using a "back buffer" #include "GraphicsMagician.h" int main() { // We'll try full screen this time Machine.Start(gmFULLSCREEN); // starting x,y position int x = 20, y = 300; // this time we'll change both x and y int dx = 10, dy = 8; // draw the initial circle Machine.Circle(x,y,10,RGB(255,255,0),1); getch(); // all drawing goes to an offscreen buffer, // which is faster and gets rid of the flicker Machine.DrawToBackBuffer(); // loop until the user gets bored while (Machine.Active()) { // clear the drawing screen (now the back buffer) Machine.ClearScreen(); // change x and bounce if needed x=x+dx; if (x > 796 || x < 5) { dx = -dx; Machine.PlayWave("bounce.wav"); } // change y and bounce if needed y=y+dy; if (y > 596 || y < 5) { dy = -dy; Machine.PlayWave("bounce.wav"); } // this one instruction adds "gravity"! else dy++; // draw the circle in its new location Machine.Circle(x,y,10,RGB(255,255,0),1); // use Flip or FlipTimed to display the back buffer // FlipTimed defaults to 30 frames per second Machine.FlipTimed(); } return 0; }