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

  1. $ENGINE={B54F3741-5B07-11cf-A4B0-00AA004A55E8}
  2. $OBJECT=ShipClass
  3. $OBJECT=BubbleClass
  4. $OBJECT=AmmoClass
  5. $OBJECT=ExtraClass
  6.  
  7. Option Explicit
  8.  
  9. '---------------------------------------------------------------
  10. ' GameFull.txt
  11. '---------------------------------------------------------------
  12. ' Use path to this file as parameter to Sprite.exe.  E.g.:
  13. '    Sprite C:\Tmp\FameFull.txt
  14. ' See "SpruuidP.Pix" for list of images available, numbered 0-n.
  15. '---------------------------------------------------------------
  16.  
  17. Dim sShip               'Player's ship
  18.  
  19.  
  20. '------------
  21. ' GAME events
  22. '
  23. Sub Game_NewGame()
  24. '   ------------
  25.     'Sprites Bounce on inner border:
  26.     ShipClass.Border   = 15
  27.     BubbleClass.Border = 15
  28.     AmmoClass.Border   = 15
  29.     ExtraClass.Border  = 15 * 16   'Outer border for this class
  30.  
  31.     'Setup Collision possibilities.  Bit 1 is reserved for hitting same-kind objects.
  32.     ShipClass.Collide   = 2
  33.     BubbleClass.Collide = 2 + 4
  34.     AmmoClass.Collide   =     4
  35.  
  36.     'Setup Standard images for the different classes of sprites
  37.     ShipClass.Image   = 32        'Ship
  38.     BubbleClass.Image = 60        'Small bubble
  39.     AmmoClass.Image   = 35        'Ammo
  40.     ExtraClass.Image  = 53        '200
  41.  
  42.     'Extra Ship Info
  43.     ScoreFirst1Up  = 250
  44.     ScoreSecond1Up = 500
  45.     DScoreNext1Up  = 500
  46.  
  47.     'Set up main window
  48.     Caption = "Bubbles - Microsoft Spruuids"
  49.     Width  = 372
  50.     Height = 282
  51.  
  52.     ShipClass.Friction = 0.981
  53.     Set sShip = ShipClass.CreateSprite(Game.Width / 2, Game.Height / 2, 0)
  54.     BubbleClass.CreateSprite 0, 0, 0
  55.     Level = 0   'Use Level marker to count # of bubbles destroyed
  56.     StatusText = "Press Any Key To Start"
  57. End Sub
  58.  
  59.  
  60. Sub Game_KeyDown(ByVal ch)
  61. '   ------------
  62.     Dim sT
  63.  
  64.     'Too many shots on screen already?
  65.     If AmmoClass.SpriteCount > 5 Then StatusText = "Only Get 6 Shots At A Time" : Exit Sub
  66.  
  67.     'Game Over?
  68.     If ShipCount <= 0 Then Exit Sub
  69.  
  70.     'Don't allow Player to start until all shots are off screen
  71.     If sShip.Image = 32 and AmmoClass.SpriteCount <> 0 Then  StatusText = "Press Any Key *After* All Bullets Disappear" : Exit Sub
  72.  
  73.     'Give simple help if wrong key pressed
  74.     If ch < 37 or ch > 40 Then StatusText = "Press Arrow Keys To Fire And Move" : Exit Sub
  75.  
  76.     StatusText = "Blow-Up Bubbles By Shooting Them Many Times"
  77.  
  78.     'Up
  79.     If ch = 38 Then
  80.         sShip.Image = 24
  81.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width / 2, sShip.Top, 0)
  82.         sT.Vx = 0 : sT.Vy = -5
  83.         sShip.Vy = sShip.Vy + 1
  84.     End If
  85.  
  86.     'Down
  87.     If ch = 40 Then
  88.         sShip.Image = 8
  89.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width / 2, sShip.Top + sShip.Height, 0)
  90.         sT.Vx = 0 : sT.Vy = 5
  91.         sShip.Vy = sShip.Vy - 1
  92.     End If
  93.  
  94.     'Left
  95.     If ch = 37 Then
  96.         sShip.Image = 16
  97.         Set sT = AmmoClass.CreateSprite(sShip.Left, sShip.Top + sShip.Height / 2, 0)
  98.         sT.Vx = -5 : sT.Vy = 0
  99.         sShip.Vx = sShip.Vx + 1
  100.     End If
  101.  
  102.     'Right
  103.     If ch = 39 Then
  104.         sShip.Image = 0
  105.         Set sT = AmmoClass.CreateSprite(sShip.Left + sShip.Width, sShip.Top + sShip.Height / 2, 0)
  106.         sT.Vx = 5 : sT.Vy = 0
  107.         sShip.Vx = sShip.Vx - 1
  108.     End If
  109. End Sub
  110.  
  111.  
  112. Sub DoShipHit()      'Decrease # ships, end game if none left
  113. '   ---------
  114.     sShip.Image = 32
  115.     ShipCount = ShipCount - 1
  116.     If ShipCount <= 0 Then
  117.         EndGame
  118.     Else
  119.         sShip.Vx = 0
  120.         sShip.Vy = 0
  121.         sShip.MoveTo Game.Width / 2, Game.Height / 2
  122.         StatusText = "Press Any Key To Start"
  123.     End If
  124. End Sub
  125.  
  126.  
  127. Sub DoNewBubble(ByVal left, ByVal top, ByVal vx, ByVal vy, ByVal fAllowGold)
  128. '   -----------
  129.     Dim sT
  130.  
  131.     Set sT = BubbleClass.CreateSprite(left, top, 1)
  132.     sT.Vx  = vx * 0.5 + 4 * Rnd() - 2
  133.     sT.Vy  = vy * 0.5 + 4 * Rnd() - 2
  134.     If fAllowGold <> 0 And Rnd() < 0.15 + 0.01 * BubbleClass.SpriteCount Then sT.Image = 44 : StatusText = "Catch Gold Ball For Bonus"
  135. End Sub
  136.  
  137.  
  138. Sub Game_Collide(ByVal sLowId, ByVal sHighId, ByVal coll)
  139. '   ------------
  140.     Dim ship
  141.     Dim bubble
  142.     Dim ammo
  143.     Dim sT
  144.  
  145.     Select Case coll
  146.         Case 2
  147.             Set ship   = sLowId
  148.             Set bubble = sHighId
  149.             If ship.Image <> 32 Then
  150.                 If bubble.Image = 44 Then
  151.                     'Score Bonus
  152.                     AddScore 200
  153.                     ExtraClass.CreateSprite ship.Left, ship.Top, 0
  154.                     bubble.Remove
  155.                 Else
  156.                     'Ship Hit Bubble
  157.                     Call DoShipHit
  158.                 End If
  159.             End If
  160.         Case 4
  161.             Set bubble = sLowId
  162.             Set ammo   = sHighId
  163.             ammo.Remove
  164.             If bubble.Image <= 57 Then
  165.                 AddScore 50
  166.                 bubble.Remove
  167.  
  168.                 'Create bursting bubble image
  169.                 If bubble.Image = 57 Then
  170.                     Set sT = ExtraClass.CreateSprite(bubble.Left, bubble.Top, 2)
  171.                     sT.Vx = bubble.Vx
  172.                     sT.Vy = bubble.Vy
  173.                 End If
  174.  
  175.                 Level = Level + 1   'Use Level marker to count # of bubbles destroyed
  176.  
  177.                 'Create two new bubbles. Don't create gold bubbles if a gold bubble was hit
  178.                 DoNewBubble bubble.Left, bubble.Top, bubble.Vx - ammo.Vx, bubble.Vy - ammo.Vy, bubble.Image = 57
  179.                 DoNewBubble bubble.Left, bubble.Top, bubble.Vx + ammo.Vx, bubble.Vy + ammo.Vy, bubble.Image = 57
  180.             Else
  181.                 bubble.Image = bubble.Image - 1
  182.                 'bubble.Vx = bubble.Vx + ammo.Vx / 3
  183.                 'bubble.Vy = bubble.Vy + ammo.Vy / 3
  184.                 AddScore 5
  185.             End If
  186.     End Select
  187. End Sub
  188.  
  189.  
  190. Sub Game_NewShip()
  191. '   ------------
  192.     ExtraClass.CreateSprite sShip.Left, sShip.Top, 1
  193.     ExtraClass.CreateSprite sShip.Left, sShip.Top, 1
  194.     ExtraClass.CreateSprite sShip.Left, sShip.Top, 1
  195.     ExtraClass.CreateSprite sShip.Left, sShip.Top, 1
  196. End Sub
  197.  
  198.  
  199.  
  200. '-----------------
  201. ' ShipClass events
  202. '
  203. Sub ShipClass_Border(ByVal s, ByVal brd)
  204. '   ----------------
  205.     'Randomize velocity, then bounce ship
  206.     s.Vx = s.Vx + 6 * Rnd() - 3
  207.     s.Vy = s.Vy + 6 * Rnd() - 3
  208.     StdBorderBounce s, brd
  209. End Sub
  210.  
  211.  
  212. '-------------------
  213. ' BubbleClass events
  214. '
  215. Sub BubbleClass_Init(ByVal s, ByVal u)
  216. '   ----------------
  217.     If s.Left = 0 Then
  218.         'New Bubble, so start it at an edge, and give it a random direction
  219.         Game.StdInitEdge s, u
  220.         s.Vx = 12 * Rnd() - 6
  221.         s.Vy = 12 * Rnd() - 6
  222.     End If
  223. End Sub
  224.  
  225. Sub BubbleClass_Border(ByVal s, ByVal brd)
  226. '   ------------------
  227.     StdBorderBounce s, brd
  228. End Sub
  229.  
  230. 'If no more enemies, create some
  231. Sub BubbleClass_LastTerm()
  232. '   --------------------
  233.     BubbleClass.CreateSprite 0, 0, 0
  234. End Sub
  235.  
  236.  
  237. '-----------------
  238. ' AmmoClass events
  239. '
  240. Sub AmmoClass_Border(ByVal s, ByVal brd)
  241. '   ----------------
  242.     s.Remove
  243. End Sub
  244.  
  245.  
  246. '------------------
  247. ' ExtraClass events
  248. '
  249. Sub ExtraClass_Init(ByVal s, ByVal u)
  250. '   ---------------
  251.     Select Case u
  252.         Case 0
  253.             s.Vy = -5               'Make the "200" go up
  254.         Case 1
  255.             s.Image = 49            'Animated +
  256.             s.Ay = .15              'Mild gravity
  257.             s.Vy = -6 * Rnd()       'Make these start going up, left gravity pull down
  258.             s.Vx = 6 * Rnd() - 3    'Rand horz velocity
  259.             s.TickEvent = 50        'Destroy in 50 ticks
  260.         Case 2
  261.             s.Image = 65            'Bursting bubble
  262.     End Select
  263. End Sub
  264.  
  265. Sub ExtraClass_Tick(ByVal s)
  266.     s.Remove
  267. End Sub
  268.  
  269. Sub ExtraClass_Border(ByVal s, ByVal brd)
  270.     If brd <> &h20 Then s.Remove
  271. End Sub
  272.  
  273. '--- EOF ---
  274.