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