SAMPLE: Animation in Windows

Last reviewed: February 15, 1996
Article ID: Q103215
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1

Animation in Windows

Herman Rodent Starring: Nell and Olivia, the Wonder Dog

Created: April 28, 1993

Abstract

This article is aimed at people who would like to create a Microsoft Windows-based application that does some form of animation, or who would like to understand how to improve the performance of an existing animated application, or who are considering porting an MS-DOS--based application to Windows. The main focus of the article is on using device-independent bitmaps (DIBs) for the images and the DIB driver (DIB.DRV) for the off-screen image buffer. The article is written around a sample application, Sprites, which is included with the article. Some knowledge of animation techniques is assumed. If you're looking for a "How to Do Animation" article, this isn't it. The following points are covered:

  • Using the DIB driver
  • Palettes
  • Measuring and improving performance
  • Lots of useful little tips and hints

SPRITES demonstrates sprite (cast-based) animation in a Microsoft Windows-based application using device-independent bitmaps (DIBs) for the images and the DIB driver (DIB.DRV) for the off-screen image buffer.

The SPRITES application uses a DIB for a background scene, and allows you to load multiple sprites on top of the background scene. Each sprite has x, y, and z coordinates, optional x and y velocity, and a flag that indicates whether it can be dragged by the mouse.

A background and a set of sprites can be combined into a scene described in a simple INI file. You can load the entire scene by choosing the Load Scene command from the File menu.

The application updates the positions of all sprites that have a non-zero velocity as fast as it can, using a PeekMessage() loop. Sprites that have the selectable attribute set can be dragged with the mouse. Double-clicking a sprite brings up a dialog box for setting sprite attributes.

Download SPRITES.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download SPRITES.EXE (size: 127102 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get SPRITES.EXE (size: 127102 bytes) 
    


Additional reference words: 3.10 softlib SPRITES.EXE
KBCategory: kbprg kbfile
KBSubcategory: GdiMisc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.