home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1996 December / PCWKCD1296.iso / vjplusb / activex / inetsdk / samples / axscript / spruuids / game1.txt next >
Encoding:
Text File  |  1996-07-15  |  2.7 KB  |  99 lines

  1. $OBJECT=ShipClass
  2. $OBJECT=BubbleClass
  3. $OBJECT=AmmoClass
  4.  
  5. Option Explicit
  6.  
  7. '----------------------------------------------------------------------------
  8. ' Game1.txt
  9. '----------------------------------------------------------------------------
  10. ' Use path to this file as parameter to Sprite.exe.  E.g.:
  11. '    Sprite C:\Tmp\Game2.txt
  12. ' See "Game.Pix" for list of images available, numbered 0-n.
  13. '----------------------------------------------------------------------------
  14.  
  15. Dim sShip               'Player's ship
  16.  
  17.  
  18. '----------------------------------------------------------------------------
  19. ' GAME events
  20. '
  21. Sub Game_NewGame()
  22. '   ------------
  23.     'Bullets and ammo can collide (note: bit 1 is reserved)
  24.     BubbleClass.Collide = 2
  25.     AmmoClass.Collide   = 2
  26.  
  27.     ShipClass.Image   = 32    'Ship
  28.     BubbleClass.Image = 60    'Small bubble
  29.     AmmoClass.Image   = 34    'Bullet
  30.  
  31.     'Create player's ship centered on screen:
  32.     Set sShip = ShipClass.CreateSprite(Game.Width / 2, Game.Height / 2, 0)
  33.  
  34.     'Create a bubble for player to fire at
  35.     BubbleClass.CreateSprite 0, 0, 0
  36. End Sub
  37.  
  38.  
  39. Sub Game_KeyPress(ByVal ch)
  40. '   ------------
  41.     Dim sT
  42.  
  43.     'Fire if Space hit
  44.     If ch = 32 Then
  45.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top, 0)
  46.         sT.Vx = 0 : sT.Vy = -5
  47.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top, 0)
  48.         sT.Vx = 0 : sT.Vy = 5
  49.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top, 0)
  50.         sT.Vx = -5 : sT.Vy = 0
  51.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top, 0)
  52.         sT.Vx = 5 : sT.Vy = 0
  53.     End If
  54. End Sub
  55.  
  56.  
  57. Sub Game_Collide(ByVal sLowId, ByVal sHighId, ByVal coll)
  58. '   ------------
  59.     Dim bubble
  60.     Dim ammo
  61.  
  62.     If coll = 2 Then
  63.         Set bubble = sLowId
  64.         Set ammo   = sHighId
  65.         ammo.Remove
  66.         If bubble.Image <= 57 Then
  67.             Game.AddScore 50
  68.             bubble.Remove
  69.             BubbleClass.CreateSprite bubble.Left, bubble.Top, 0
  70.         Else
  71.             bubble.Image = bubble.Image - 1
  72.             Game.AddScore 5
  73.         End If
  74.     End If
  75. End Sub
  76.  
  77.  
  78. '----------------------------------------------------------------------------
  79. ' BubbleClass events
  80. '
  81. Sub BubbleClass_Init(ByVal s, ByVal u)
  82.     Game.StdInitEdge s, u
  83.     s.Vx = 6 : s.Vy = 6
  84. End Sub
  85.  
  86. Sub BubbleClass_Border(ByVal s, ByVal brd)
  87.     Game.StdBorderBounce s, brd             'Bubbles bounce on edge of screen
  88. End Sub
  89.  
  90.  
  91. '----------------------------------------------------------------------------
  92. ' AmmoClass events
  93. '
  94. Sub AmmoClass_Border(ByVal s, ByVal brd)
  95.     s.Remove                                'Ammo destroys itself on edge of screen
  96. End Sub
  97.  
  98. '--- EOF ---
  99.