📄 spreng.txt
字号:
AutoDocs Prepared for 'SPRENG.BAS'
Sprite Engine
Copyright Mark Meany, 1997.
Introduction
This Visual Basic v3 Sprite Engine is Freeware, it has been provided
for you to use in your own games providing the conditions laid out
below are followed:
1. It is accompanied by a link back to this my site.
http://www.geocities.com/SiliconValley/Bay/9520/index.html
2. This copyright notice is included in the accompanying documentation.
Documentation means: Text files, help files and About dialog.
3. Due credit is given:
That means documentation includes: Some source cM.Meany, 1997.
Disclaimer: This code is provided 'as is', no warranties expressed or
implied. You use this code on the understanding that the consequences
of doing so are soley your responsability.
For examples of the Sprite Engine in use, visit my web site and
download some of the games from there:
http://www.geocities.com/SiliconValley/Bay/9520/index.html
Live fast, code hard and die in a beautiful way.
Mark.
========================================================================================
Module Name Sprite Engine
Copyright Mark Meany, 1997
Version v1.1
Release Date 1st September 1997
Know Bugs
Palette Corruption Occurs when certain programs are running, eg Internet Explorer 3
I think I need to realise palettes at some point, but have yet to
experiment with this.
Revision History
19 Sept 1997 iSprLoadFrames()
Fixed to work with frame files generated by my Frame Editor v2
Handles files in XSrc,YSrc,XDst,YDst as opposed to X,Y,W,H.
========================================================================================
== // ==
Function iSprAllocateSprite (rtNew As SprNewSprite) As Integer
Purpose Allocate a sprite from the system, creates a
Save DC for background saving and initialises
all fields of the Sprite structure based on
values passed in the New Sprite structure.
Entry rtNew - A SprNewSprite structure that defines
the sprite to allocate.
Exit True if sprite allocated successfully
Comments Resources are freed should an error occur
== // ==
Function iSprCollision (ByVal viId1 As Integer, ByVal viId2 As Integer) As Integer
Purpose To determine if two sprites have collided
Entry viId1 - Index of first sprite
viId2 - Index of second sprite
Exit True if sprites have hit
Comments This uses a crude overlapping rectangles
algorithm that causes yells of 'that missed
me by miles' to be screamed by disgruntled
players;)
== // ==
Function iSprCollisionRange (ByVal viId As Integer, ByVal viStart As Integer, ByVal viEnd As Integer) As Integer
Purpose To determine if two sprites have collided
Entry viId - Index of first sprite
viStart - Index of first sprite in range
viEnd - Index of last sprite in range
Exit False if no collisions encountered, else
returns the ID+1 of the sprite hit
Comments This uses a crude overlapping rectangles
algorithm
== // ==
Function iSprGetPlayDC (ByVal viDstDc As Integer, ByVal viW As Integer, ByVal viH As Integer) As Integer
Purpose Creates a DC to use as the play area
Entry viDstDC - DC that the play area will be displayed on
viW - Width of play area in pixels
viH - Height of play area in pixels
Exit True if resources allocated, false otherwise
Comments Will exit false if a play area is already in use
== // ==
Function iSprLoadFrames (ByVal vsFName As String) As Integer
Purpose Load frame details from a file
Entry vsFName - name of data file to load
Exit True if operation successful
Comments The data file must reside in the same
directory as the executable.
Frame Editor completed Sep 7th '97!
== // ==
Function iSprLoadGfx (pic As PictureBox, ByVal vsFName As String) As Integer
Purpose Load sprite graphics from a *.BMP file into a
memory DC and create a mask DC for transparent
blitting as well
Entry pic - a picture box used to load the gfx
vsFName - Name of the *.BMP file to load
Exit True if file loaded and mask created
Comments The *.BMP file must reside in same directory
as the executable. All resources are released
if any errors occur
== // ==
Sub SprActivateSprite (ByVal viId As Integer, ByVal viX As Integer, ByVal viY As Integer)
Purpose Activates a sprite and makes initial background
save
Entry viId - Index of sprite to activate
viX - X pixel coord to display sprite at
viY - Y pixel coord to display sprite at
Comments
== // ==
Sub SprAnimAuto ()
Purpose Animate all active sprites that have iAnimAuto
set True
Entry None
Comments All animation sequences are assumed to be
cyclic.
== // ==
Sub SprAnimNextFrame (ByVal viId As Integer)
Purpose To move a sprite one frame forward in its
animation sequence
Entry viId - Index of sprite to animate
Comments All animation sequences are assumed to be
cyclic
== // ==
Sub SprAnimPrevFrame (ByVal viId As Integer)
Purpose To move a sprite one frame forward in its
animation sequence
Entry viId - Index of sprite to animate
Comments All animation sequences are assumed to be
cyclic
== // ==
Sub SprAnimSetFrame (ByVal viId As Integer, ByVal viFrame As Integer)
Purpose To set the frame used by a sprite
Entry viId - Index of sprite to animate
viFrame - frame to use
Comments The frames specified can be any frame, there
is no requirement that it be a member of the
animation sequence of the sprite
== // ==
Sub SprAnimSetFrameRel (ByVal viId As Integer, ByVal viRel As Integer)
Purpose To set the frame used by a sprite from its
animation sequence
Entry viId - Index of sprite to animate
viRel - Offset to required frame, 0=iFirstFrame
, 1=iFirstFrame+1,....
Comments The is no bounds checking done on the offset,
make sure it stays within iFirstFrame to
iLastFrame range!
== // ==
Sub SprDeactivateSprite (ByVal viId As Integer)
Purpose Deactivates a sprite
Entry viId - Index of sprite to deactivate
Comments
== // ==
Sub SprDraw ()
Purpose Save background and draw all sprites
Entry None
Comments Call this in game loop AFTER activating,
moving, deactivating sprites.
== // ==
Sub SprFreeAll ()
Purpose Free all sprite engine resources
Entry None
Exit None
Comments Call this just before program termination
== // ==
Sub SprFreeAllSprites ()
Purpose Free resources used by all sprites and mark
them as available
Entry None
Comments
== // ==
Sub SprFreeGfx ()
Purpose Free resources used to hold sprite graphics
and masks
Entry None
== // ==
Sub SprFreePlayDC ()
Purpose Release resources used for the game play area
Entry None
Comments
== // ==
Sub SprFreeSprite (ByVal viId As Integer)
Purpose Free resources used by a sprite and mark it
as available
Entry viId - Index value of the sprite to free
Comments
== // ==
Sub SprMoveSprite (ByVal viId As Integer, ByVal viX As Integer, ByVal viY As Integer)
Purpose To move a sprite to absolute coordinates
Entry viId - Spride index
viX - X pixel coordinate
viY - Y pixel coordinate
Comments
== // ==
Sub SprMoveSpriteRel (ByVal viId As Integer, ByVal viDx As Integer, ByVal viDy As Integer)
Purpose To move a sprite relative to its current
position
Entry viId - Spride index
viDx - X pixel offset (+ or -)
viDy - Y pixel offset (+ or -)
Comments
== // ==
Sub SprRestore ()
Purpose Restores background where all sprites have
been displayed.
Entry None
Comments Call this in game loop BEFORE deactivating
sprites.
== // ==
Sub SprShowPlayDC (ByVal viDstDc As Integer, ByVal viX As Integer, ByVal viY As Integer)
Purpose Display the play area
Entry viDstDC - Target DC to copy play area into
viX - X pixel coord in target DC
viY - Y pixel coord in target DC
== // ==
Index
Function iSprAllocateSprite (rtNew As SprNewSprite) As Integer
Function iSprCollision (ByVal viId1 As Integer, ByVal viId2 As Integer) As Integer
Function iSprCollisionRange (ByVal viId As Integer, ByVal viStart As Integer, ByVal viEnd As Integer) As Integer
Function iSprGetPlayDC (ByVal viDstDc As Integer, ByVal viW As Integer, ByVal viH As Integer) As Integer
Function iSprLoadFrames (ByVal vsFName As String) As Integer
Function iSprLoadGfx (pic As PictureBox, ByVal vsFName As String) As Integer
Sub SprActivateSprite (ByVal viId As Integer, ByVal viX As Integer, ByVal viY As Integer)
Sub SprAnimAuto ()
Sub SprAnimNextFrame (ByVal viId As Integer)
Sub SprAnimPrevFrame (ByVal viId As Integer)
Sub SprAnimSetFrame (ByVal viId As Integer, ByVal viFrame As Integer)
Sub SprAnimSetFrameRel (ByVal viId As Integer, ByVal viRel As Integer)
Sub SprDeactivateSprite (ByVal viId As Integer)
Sub SprDraw ()
Sub SprFreeAll ()
Sub SprFreeAllSprites ()
Sub SprFreeGfx ()
Sub SprFreePlayDC ()
Sub SprFreeSprite (ByVal viId As Integer)
Sub SprMoveSprite (ByVal viId As Integer, ByVal viX As Integer, ByVal viY As Integer)
Sub SprMoveSpriteRel (ByVal viId As Integer, ByVal viDx As Integer, ByVal viDy As Integer)
Sub SprRestore ()
Sub SprShowPlayDC (ByVal viDstDc As Integer, ByVal viX As Integer, ByVal viY As Integer)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -