home *** CD-ROM | disk | FTP | other *** search
- #include "SpriteTools.h"
-
- // SpriteTools.h includes SpriteHandlers.h
-
-
- /*** Custom handlers - application dependent ***
-
- Edit this as necessary. It should always include the following three routines:
-
- MoveSprite: move the sprite
-
- HitSprite: handle collisions between two sprites
-
- InitSprites: Load all faces and create initial sprites
-
- ***/
-
-
- typedef struct ProgramPart
- {
- short howLong;
- short dh;
- short dv;
- };
-
- struct ProgramPart program1[] =
- {
- {60, 0,1},
- {50, 1, 0},
- {30, 0, -1},
- {20, -1, 0},
- {30, 0, -1},
- {15, -2, 0},
- {-1, -1, -1}
- };
-
-
- GrafPtr firstFace, secondFace, thirdFace;
-
-
- void MoveSprite(SpritePtr theSprite)
- {
- theSprite->position.h += program1[theSprite->currentInstruction].dh;
- theSprite->position.v += program1[theSprite->currentInstruction].dv;
- theSprite->timeOnCurrent++;
- if (theSprite->timeOnCurrent >= program1[theSprite->currentInstruction].howLong)
- {
- theSprite->timeOnCurrent = 0;
- theSprite->currentInstruction++;
- if (program1[theSprite->currentInstruction].howLong < 0)
- theSprite->currentInstruction = 0;
- }
- KeepOnScreen(theSprite);
- } /*MoveSprite*/
-
- void HitSprite(SpritePtr theSprite, SpritePtr anotherSprite)
- {
- } /*HitSprite*/
-
-
- void InitSprites()
- {
- SpritePtr theSprite;
-
- /*Load all pictures*/
- firstFace = LoadFaceFromCicn(128); /*cicn resource #128.*/
- secondFace = LoadFaceFromCicn(129); /*cicn resource #129.*/
- thirdFace = LoadFaceFromCicn(130); /*cicn resource #130.*/
-
- /*Create sprites*/
- theSprite = NewSprite();
- theSprite->face = firstFace;
- SetPt(&theSprite->position, 100, 100);
- SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
- theSprite->timeOnCurrent = 0;
- theSprite->currentInstruction = 0;
-
- theSprite = NewSprite();
- theSprite->face = secondFace;
- SetPt(&theSprite->position, 50, 50);
- SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
- theSprite->timeOnCurrent = 0;
- theSprite->currentInstruction = 0;
-
- theSprite = NewSprite();
- theSprite->face = thirdFace;
- SetPt(&theSprite->position, 150, 150);
- SetPt(&theSprite->speed, Rand(7)-3, Rand(7)-3);
- theSprite->timeOnCurrent = 0;
- theSprite->currentInstruction = 0;
- } /*InitSprites*/
-