home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.bin / SourceCode / GameKit / Examples / NX_Invaders / NXIBullet.m < prev    next >
Encoding:
Text File  |  1994-06-07  |  881 b   |  41 lines

  1.  
  2. #import <libc.h>
  3. #import "NXIBullet.h"
  4. #import "NXIGameBrain.h"
  5. #import "NXIPlayer.h"
  6.  
  7.  
  8. @implementation NXIBullet
  9.  
  10. - init
  11. {
  12.     id ret = [super init];
  13.     renderedImage = [NXImage findImageNamed:"Bullet.tiff"];
  14.     NX_HEIGHT(&boundingBox) = BULLET_WIDTH;
  15.     NX_WIDTH(&boundingBox) = BULLET_HEIGHT;
  16.     maxFrames[0] = BULLET_FRAMES;
  17.     return ret;
  18. }
  19.  
  20. - collidedWith:anActor    // called when it is detected that we hit something
  21. {
  22.     // ***** need to remove us from the stage if hit Player, base,
  23.     // or one of the player's bullets
  24.     return self;
  25. }
  26.  
  27. - move:sender        // move one frame
  28. {
  29.     if (state == BULLET_INACTIVE) return self;
  30.     GK_VECTOR_Y(&nextLocation) -= BULLET_DROP_SPEED;
  31.     // all collisions are handles by collision detection machinery
  32.     if (GK_VECTOR_Y(&nextLocation) <= -BULLET_HEIGHT) {
  33.         // take bullet off of screen
  34.         state = BULLET_INACTIVE;
  35.         [self leaveTheStage];
  36.     }
  37.     return self;
  38. }
  39.  
  40. @end
  41.