home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{8661C691-76E8-11D1-AE63-0004ACFF9AE2}#1.0#0"; "ASPRITE.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 2445
- ClientLeft = 615
- ClientTop = 795
- ClientWidth = 3750
- LinkTopic = "Form1"
- ScaleHeight = 2445
- ScaleWidth = 3750
- Begin ASPRITELib.ASprite ASprite1
- Height = 732
- Left = 1320
- TabIndex = 0
- Top = 600
- Width = 1212
- _Version = 65536
- _ExtentX = 2138
- _ExtentY = 1291
- _StockProps = 0
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
- '**********
- '** This example application uses the ASprite ActiveX Control
- '** For more ASprite examples, visit
- '** http://www.dreamscape.com/beaulieu
- '** This code and the ASprite ActiveX Control are furnished
- '** without warranty of any kind. The author cannot be held
- '** liable for any damages due to their use.
- '**********
- '** This example shows a minimal DirectX app with keyboard
- '** and joystick input, buffered sound, and sprite collision.
- '**********
- Const DIRECTION_STOPPED = 0
- 'ShowCursor used to hide hourglass that VB puts up when busy
- Private Declare Function ShowCursor Lib "User32" (ByVal bShow As Integer) As Integer
- Private Sub Form_Activate()
- Dim xx As Integer
- 'make sure we're in the dir with all of the bmps and wavs
- ChDir App.Path
- 'notify DirectX of our main window
- ASprite1.hWnd = Form1.hWnd
- 'initialize DirectSound
- ASprite1.SoundInit
- 'load our two wav sound files
- ASprite1.SoundLoad 0, "explode.wav"
- ASprite1.SoundLoad 1, "laugh.wav"
- 'initialize DirectDraw
- ASprite1.DrawInit 640, 480, 8, 0
- 'load tutorial.bmp - it will contain 16 sprites, and will use
- 'palette entry 11 (blue) for transparent color
- ASprite1.SpriteLoad "tutorial.bmp", 16, 11
- 'define sprite 0
- ASprite1.SpriteDefine 0, 290, 215, 0, 0, 80, 65, 16, 8, 1, 1
- 'define sprites 1 thru 15
- For xx = 1 To 15
- ASprite1.SpriteDefine xx, Int((600 * Rnd) + 1), Int((440 * Rnd) + 1), 0, 130, 78, 79, 8, 8, Int((8 * Rnd) + 1), 1
- Next
- 'set our text window attributes
- ASprite1.TextSetAttributes 639, 60, "Arial", 32, RGB(255, 255, 0), RGB(0, 0, 0)
- 'turn control over to the rendering loop
- RunMain
- End Sub
- Public Sub RunMain()
- Dim iCurrentDirection, xx As Integer
- Dim bContinue As Boolean
- bContinue = True
- ShowCursor (False)
- Do While bContinue
- If ASprite1.InputIsKeyPressed(vbKeyEscape) Then
- 'User wants to quit!
- bContinue = False
- End If
- ' read the user input - try keyboard first the joystick
- iCurrentDirection = ASprite1.InputKeyArrowDirection
- If iCurrentDirection = DIRECTION_STOPPED Then
- iCurrentDirection = ASprite1.InputJoyStickDirection
- End If
- 'fill the back buffer with palette entry 0 (black)
- ASprite1.DrawFloodFill 0
- 'move and display sprite 0 (ball)
- ASprite1.SpriteMove 0, iCurrentDirection, 4
- ASprite1.SpriteSetNextFrame 0
- ASprite1.SpriteDisplay 0
- 'animate and display sprites 1 thru 16 (faces)
- For xx = 1 To 16
- ASprite1.SpriteSetNextFrame xx
- ASprite1.SpriteDisplay xx
- If ASprite1.SpriteGetActive(xx) And Int((800 * Rnd) + 1) = 1 Then
- ASprite1.SoundPlay 1
- End If
- If ASprite1.SpriteTestCollision(0, xx) Then
- ASprite1.SpriteSetActive xx, False
- ASprite1.SoundPlay 0
- End If
- Next
- ASprite1.TextDisplay "ASprite ActiveX Control Tutorial", 1, 420
- ASprite1.DrawFlipBackBuffer
- Loop
- ShowCursor (True)
- ' clean up and get out
- ASprite1.DrawDisable
- ASprite1.SoundDisable
- Unload Form1
- End Sub
-