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

  1. $OBJECT=ShipClass
  2. $OBJECT=BubbleClass
  3. $OBJECT=AmmoClass
  4. $OBJECT=ExtraClass
  5.  
  6. Option Explicit
  7.  
  8. '----------------------------------------------------------------------------
  9. ' Game2.txt
  10. '----------------------------------------------------------------------------
  11. ' Use path to this file as parameter to Sprite.exe.  E.g.:
  12. '    Sprite C:\Tmp\Game2.txt
  13. ' See "Game.Pix" for list of images available, numbered 0-n.
  14. '----------------------------------------------------------------------------
  15.  
  16. Dim sShip               'Player's ship
  17.  
  18.  
  19. '----------------------------------------------------------------------------
  20. ' GAME events
  21. '
  22. Sub Game_NewGame()
  23. '   ------------
  24.     'Setup Collision possibilities.  Bit 1 is reserved for hitting same-kind objects.
  25.     ShipClass.Collide   = 2
  26.     BubbleClass.Collide = 2 + 4
  27.     AmmoClass.Collide   =     4
  28.  
  29.     'Setup Standard images for the different classes of sprites
  30.     ShipClass.Image   = 32        'Ship
  31.     BubbleClass.Image = 60        'Small bubble
  32.     AmmoClass.Image   = 35        'Ammo
  33.  
  34.     Set sShip = ShipClass.CreateSprite(Game.Width / 2, Game.Height / 2, 0)
  35.     BubbleClass.CreateSprite 0, 0, 0
  36. End Sub
  37.  
  38.  
  39. Sub Game_KeyDown(ByVal ch)
  40. '   ------------
  41.     Dim sT
  42.  
  43.     'Up
  44.     If ch = 38 Then
  45.         sShip.Image = 24
  46.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width / 2, sShip.Top, 0)
  47.         sT.Vx = 0 : sT.Vy = -5
  48.         sShip.Vy = sShip.Vy + 1
  49.     End If
  50.  
  51.     'Down
  52.     If ch = 40 Then
  53.         sShip.Image = 8
  54.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width / 2, sShip.Top + sShip.Height, 0)
  55.         sT.Vx = 0 : sT.Vy = 5
  56.         sShip.Vy = sShip.Vy - 1
  57.     End If
  58.  
  59.     'Left
  60.     If ch = 37 Then
  61.         sShip.Image = 16
  62.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top + sShip.Height / 2, 0)
  63.         sT.Vx = -5 : sT.Vy = 0
  64.         sShip.Vx = sShip.Vx + 1
  65.     End If
  66.  
  67.     'Right
  68.     If ch = 39 Then
  69.         sShip.Image = 0
  70.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width, sShip.Top + sShip.Height / 2, 0)
  71.         sT.Vx = 5 : sT.Vy = 0
  72.         sShip.Vx = sShip.Vx - 1
  73.     End If
  74. End Sub
  75.  
  76.  
  77. Sub Game_Collide(ByVal sLowId, ByVal sHighId, ByVal coll)
  78. '   ------------
  79.     Dim ship
  80.     Dim bubble
  81.     Dim ammo
  82.     Dim sT
  83.  
  84.     Select Case coll
  85.         Case 2
  86.             Set ship   = sLowId
  87.             Set bubble = sHighId
  88.             If ship.Image <> 32 Then
  89.                 'Ship Hit Bubble
  90.                 sShip.Image = 32
  91.                 Game.ShipCount = Game.ShipCount - 1
  92.                 If Game.ShipCount <= 0 Then
  93.                     Game.EndGame
  94.                 Else
  95.                     sShip.Vx = 0 : sShip.Vy = 0
  96.                     sShip.MoveTo Game.Width / 2, Game.Height / 2
  97.                 End If
  98.             End If
  99.  
  100.         Case 4
  101.             Set bubble = sLowId
  102.             Set ammo   = sHighId
  103.             ammo.Remove
  104.             If bubble.Image <= 57 Then
  105.                 Game.AddScore 50
  106.                 bubble.Remove
  107.                 Set sT = BubbleClass.CreateSprite(bubble.Left, bubble.Top, 1)
  108.                 sT.Vx  = bubble.Vx * 0.5 + 4 * Rnd() - 2
  109.                 sT.Vy  = bubble.Vy * 0.5 + 4 * Rnd() - 2
  110.                 Set sT = BubbleClass.CreateSprite(bubble.Left, bubble.Top, 1)
  111.                 sT.Vx  = bubble.Vx * 0.5 + 4 * Rnd() - 2
  112.                 sT.Vy  = bubble.Vy * 0.5 + 4 * Rnd() - 2
  113.             Else
  114.                 bubble.Image = bubble.Image - 1
  115.                 Game.AddScore 5
  116.             End If
  117.     End Select
  118. End Sub
  119.  
  120.  
  121. '----------------------------------------------------------------------------
  122. ' ShipClass events
  123. '
  124. Sub ShipClass_Border(ByVal s, ByVal brd)
  125.     Game.StdBorderBounce s, brd
  126. End Sub
  127.  
  128.  
  129. '----------------------------------------------------------------------------
  130. ' BubbleClass events
  131. '
  132. Sub BubbleClass_Init(ByVal s, ByVal u)
  133.     If s.Left = 0 Then
  134.         'New Bubble, so start it at an edge with a velocity
  135.         Game.StdInitEdge s, u
  136.         s.Vx = 6
  137.         s.Vy = 6
  138.     End If
  139. End Sub
  140.  
  141. Sub BubbleClass_Border(ByVal s, ByVal brd)
  142.     Game.StdBorderBounce s, brd
  143. End Sub
  144.  
  145.  
  146. '----------------------------------------------------------------------------
  147. ' AmmoClass events
  148. '
  149. Sub AmmoClass_Border(ByVal s, ByVal brd)
  150.     s.Remove
  151. End Sub
  152.  
  153. '--- EOF ---
  154.