Retired Document
Important: This sample code may not represent best practices for current development. The project may use deprecated symbols and illustrate technologies and techniques that are no longer recommended.
Start Code/animsprite.c
#ifndef _MAININCLUDES_ |
#include "main.h" |
#endif |
void MyMoveSprites (void) |
{ |
short nIndex; |
MatrixRecord matrix; |
SetIdentityMatrix(&matrix); |
// for each sprite |
for (nIndex = 0; nIndex < kNumSprites; nIndex++) { |
// modify the spriteÕs matrix |
OffsetRect(&gDestRects[nIndex], gDeltas[nIndex].h, |
gDeltas[nIndex].v); |
if ((gDestRects[nIndex].right >= gBounceBox.right) || |
(gDestRects[nIndex].left <= gBounceBox.left)) |
gDeltas[nIndex].h = -gDeltas[nIndex].h; |
if ((gDestRects[nIndex].bottom >= gBounceBox.bottom) || |
(gDestRects[nIndex].top <= gBounceBox.top)) |
gDeltas[nIndex].v = -gDeltas[nIndex].v; |
matrix.matrix[2][0] = ((long)gDestRects[nIndex].left << 16); |
matrix.matrix[2][1] = ((long)gDestRects[nIndex].top << 16); |
// Step 4. |
// Insert "SetSpriteMatrix.clp" here |
// change the spriteÕs image |
gCurrentImages[nIndex]++; |
if (gCurrentImages[nIndex] >= (kNumSpaceShipImages * |
(nIndex+1))) |
{ |
gCurrentImages[nIndex] = 0; |
} |
// Step 5. |
// Insert "SetSpriteImage.clp" here |
} |
} |
Copyright © 2003 Apple Computer, Inc. All Rights Reserved. Terms of Use | Privacy Policy | Updated: 2003-01-14