commit a64ae89fecaacc886e0d4765d0ca475219299327
Author: Tim Young ";
+ $matches = array();
+ $matchingFileIndices = array();
+ $rankings = array();
+
+ $isFirst = true;
+
+ foreach($keywords as $word)
+ {
+ if (!array_key_exists($word, $wordDictionary))
+ {
+ return "Nothing found";
+ }
+ $occurrences = $wordDictionary[$word];
+
+ $matches[$word] = $occurrences;
+ $occurrenceIndices = array();
+
+ // Get a list of the file indices for this match
+ foreach($occurrences as $entry)
+ array_push($occurrenceIndices, ($entry >> 16));
+
+ if($isFirst)
+ {
+ $isFirst = false;
+ foreach($occurrenceIndices as $i)
+ {
+ array_push($matchingFileIndices, $i);
+ }
+ }
+ else
+ {
+ // After the first match, remove files that do not appear for
+ // all found keywords.
+ for($idx = 0; $idx < count($matchingFileIndices); $idx++)
+ {
+ if (!in_array($matchingFileIndices[$idx], $occurrenceIndices))
+ {
+ array_splice($matchingFileIndices, $idx, 1);
+ $idx--;
+ }
+ }
+ }
+ }
+
+ if(count($matchingFileIndices) == 0)
+ {
+ return "Nothing found";
+ }
+
+ // Rank the files based on the number of times the words occurs
+ foreach($matchingFileIndices as $index)
+ {
+ // Split out the title, filename, and word count
+ $fileIndex = explode("\x00", $fileInfo[$index]);
+
+ $title = $fileIndex[0];
+ $filename = $fileIndex[1];
+ $wordCount = intval($fileIndex[2]);
+ $matchCount = 0;
+
+ foreach($keywords as $words)
+ {
+ $occurrences = $matches[$word];
+
+ foreach($occurrences as $entry)
+ {
+ if(($entry >> 16) == $index)
+ $matchCount += $entry & 0xFFFF;
+ }
+ }
+
+ $r = new Ranking($filename, $title, $matchCount * 1000 / $wordCount);
+ array_push($rankings, $r);
+
+ if(count($rankings) > 99)
+ break;
+ }
+
+ // Sort by rank in descending order or by page title in ascending order
+ if($sortByTitle)
+ {
+ usort($rankings, "cmprankbytitle");
+ }
+ else
+ {
+ usort($rankings, "cmprank");
+ }
+
+ // Format the file list and return the results
+ foreach($rankings as $r)
+ {
+ $f = $r->filename;
+ $t = $r->pageTitle;
+ $sb .= "
Omitted $c more results
SpritePutBaseImageLocation Method (Double, Double) |
+ Namespace: + SpriteLibrary
public void PutBaseImageLocation( + double X, + double Y +)
SpriteClick Event |
+ Namespace: + SpriteLibrary
SpriteController Class |
+ Namespace: + SpriteLibrary
public class SpriteController
The SpriteController type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() ![]() | SpriteController(PictureBox) |
+ Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed. You want to have the PictureBox already defined, and a background image
+ already set for the PictureBox.
+ |
![]() ![]() | SpriteController(PictureBox, EventHandler) |
+ Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed.
+ |
+ + | Name | Description |
---|---|---|
![]() | BackgroundImage |
+ The Background Image on which the sprites are drawn. This image ends up having
+ sprite parts on it. The OriginalImage is the version that is clean. Use
+ ReplaceOriginalImage to replace the background Image.
+ |
![]() | OriginalImage |
+ The Image from which the background is taken when we erase sprites. The BackgroundImage
+ is the image that contains images of the sprites as well as the background image. Use
+ ReplaceOriginalImage to replace this and the BackgroundImage.
+ |
![]() | SpriteCount |
+ The count of all the sprites the controller knows about. This includes named
+ sprites, which may not be visible.
+ |
+ + | Name | Description |
---|---|---|
![]() | AddSprite |
+ Add the specified sprite to the list of sprites we know about. You usually do not need to do this.
+ Sprites add themselves to the controller when you create a new sprite.
+ |
![]() | AdjustPoint |
+ Adjust an image point so that it conforms to the picturebox.
+ |
![]() | AdjustRectangle |
+ Adjust a rectangle that is based on the image, according to the stretch of the picturebox
+ |
![]() | AllSprites |
+ Return a list of all sprites
+ |
![]() | ChangeTickInterval |
+ Change the Tick Interval. By default, the spritecontroller does a tick every 10ms, which
+ is very fast. Some people may prefer it to happen less regularly. Must be > 5, and less than 1001
+ |
![]() | CountSpritesBasedOff |
+ Count the number of sprites that were duplicated from the sprite with the specified name. When you use a
+ SpriteController.DuplicateSprite(string)
+ command, it creates a new sprite that is based off the named sprite. This function will count those duplicated sprites.
+ |
![]() | DestroyAllSprites |
+ Remove all sprites (even named sprites that have not yet been displayed)
+ |
![]() | DestroySprite |
+ Tell a sprite to destroy itself. The sprite will have Destroying property set to true from
+ the time you destroy it until it vanishes. Whe you destroy a sprite, it will erase itself
+ and remove itself from the controller. After it is destroyed, it is completely gone.
+ |
![]() ![]() | DuplicateSprite(String) |
+ Find a sprite that has been named with the specified name. Then duplicate that sprite
+ |
![]() | DuplicateSprite(Sprite) |
+ Make a duplicate of the specified sprite. The duplicate does not yet have a location.
+ |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Invalidate(Boolean) |
+ Invalidate the entire image on which the sprites are drawn
+ |
![]() | Invalidate(Rectangle, Boolean) |
+ Invalidate a rectangle that is specified in image coordinates
+ |
![]() | IsKeyPressed |
+ Check to see if any keys are pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | IsKeyPressed(Keys) |
+ Check to see if the given key is pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | KeysPressed |
+ Return a list of all the keys that are currently pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | NameSprite |
+ Find the specified Sprite in the controller and change its name to the specified string.
+ You can do the same thing with Sprite.SetName(Name) |
![]() | Pause |
+ Pause everything. It loops through all the sprites in the SpriteController and sends the specified
+ SpritePauseType to each one. Look at the documentation for SpritePauseType to determine which pause
+ type to use.
+ |
![]() | PlaceSpriteBehind |
+ Change the display order of the sprites such that the specified sprite appears behind the other sprite.
+ |
![]() | PlaceSpriteInFrontOf |
+ Make the sprite go in front of the specified sprite.
+ |
![]() | RegisterKeyDownFunction |
+ If you want to have a KeyDown function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+ |
![]() | RegisterKeyUpFunction |
+ If you want to have a KeyUp function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+ |
![]() | ReplaceOriginalImage |
+ Notify the sprite controller that you have changed the background image on the
+ PictureBox. Whatever background is on the picturebox is now used to draw all the sprites on.
+ |
![]() ![]() | ReplaceOriginalImage(Image) |
+ Replace the image on which the sprites are drawn. Use this when you move to a new playing field,
+ or want to have a different background
+ ![]()
+ Replacing the background image is actually a lot more complex than you might imagine. Once you use the
+ below code, it can be done without any problem. But you need to do it this way, or it just goofs up in
+ a number of small ways.
+ You need to tell the sprite controller that you are replacing the background image,
+ and you need to change the image to that image as well.Because the Images are actually
+ pointers to memory where the image sets, changes to one image will affect the other image.This goofs
+ things up, so what we do is duplicate the image twice, and tell the sprite controller to use one of the
+ copies and then set the background to be the other one of the two copies.Finally, we tell the picturebox
+ to invalidate itself.That does everything that is needed.
+ C# void ReplaceBackground(Image NewBackground) +{ + if (MyController == null) return; + if (NewBackground == null) return; + + Image OneImage = new Bitmap(NewBackground); + MyController.ReplaceOriginalImage(OneImage); + + Image TwoImage = new Bitmap(NewBackground); + pb_map.BackgroundImage = TwoImage; + pb_map.Invalidate(); +} |
![]() | ResetKeypressState |
+ Reset the keypress status. Sometimes the sprite controller misses a key being released (usually
+ because a window has taken priority, or something has changed). Calling this function will reset
+ the stored memory of whether a key has been pressed.
+ |
![]() | ReturnAdjustmentRatio |
+ Return an adjustment ratio. This is the image-size to picture-box ratio.
+ It is used for calculating precise pixels or picture-box locations.
+ |
![]() | ReturnPictureBoxAdjustedHeight |
+ Return the height of an object in picture-box terms. It is basically the virtual height
+ of the sprite or other item.
+ |
![]() | ReturnPictureBoxAdjustedPoint |
+ This does the reverse of an adjusted point. It takes a point on the image and
+ transforms it to one on the PictureBox
+ |
![]() | ReturnPictureBoxAdjustedWidth |
+ Return the width of an object in picture-box terms. It takes the width of a sprite or other
+ item that is being displayed on the screen, and calculates the width as displayed in the
+ picture-box (taking into consideration stretching or shrinking)
+ |
![]() | ReturnPointAdjustedForImage |
+ This takes a point, the location on a picturebox, and returns the corresponding point on the BackgroundImage.
+ Picturebox locations are "sloppy"; the background image locations are very precise. Since this takes a "sloppy"
+ number and returns a precise number, it does some rounding to figure out where the specified location is.
+ |
![]() | SoundIsFinished |
+ Check to see if the specified sound has finished playing
+ |
![]() | SoundPlay |
+ Play a sound that we can check to see if it has completed.
+ |
![]() | SpriteBackwards |
+ Change the display order of the specified sprite so it is more likely to go behind all other sprites.
+ |
![]() | SpriteForwards |
+ Change the display order of the specified sprite so it is more likely to go in front of other sprites
+ |
![]() | SpriteFromName |
+ Find a sprite that has a specified name. This returns the actual sprite with that name.
+ You usually want to use DuplicateSprite(Name) to clone the sprite and get one you can
+ destroy. If you destroy a named sprite without duplicating it, you may end up losing
+ it for the remainder of the program.
+ |
![]() | SpritesAtImagePoint |
+ This takes a point, as as specified on the image, and returns the sprites at that point. Different
+ functions use different coordinates, whether based off the background image, or based off the picturebox.
+ This one uses the background image coordinates. Use SpritesAdPoint() if you are doing something based off
+ a MouseUp or MouseDown function. This is used for functions based on sprite location or based off the absoloute
+ location (using the background image location is much more precise than the visible location in the picturebox)
+ |
![]() | SpritesAtPoint |
+ This takes a point, as given by the mouse-click args, and returns the sprites at that point. Different
+ functions use different coordinates, whether based off the background image, or based off the picturebox.
+ This one uses the picturebox coordinates. So you can use this directly from a MouseDown or MouseUp function.
+ |
![]() | SpritesBasedOff |
+ Return all sprites that were based off a particular sprite name.
+ When you use a
+ SpriteController.DuplicateSprite(string)
+ command, it creates a new sprite that is based off the named sprite. This function returns a list of those
+ duplicated sprites.
+ |
![]() | SpritesBasedOffAnything |
+ Return a list of all sprites which are not master sprites (which are duplicates of something)
+ |
![]() | SpritesInImageRectangle |
+ Return a list of all the sprites that intersect with the given background-image-based rectangle
+ |
![]() | SpritesThatHaveBeenDrawn |
+ Return a list of all sprites which have been drawn on the image
+ |
![]() | SpriteToBack |
+ Change the display order of the specified sprite so it goes behind all other sprites.
+ |
![]() | SpriteToFront |
+ Change the display order of the specified sprite so it goes in front of all other sprites.
+ |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | UnPause |
+ un-Pause everything. This will send the specified SpritePauseType unpause command
+ to all sprites.
+ |
+ + | Name | Description |
---|---|---|
![]() ![]() | DoTick |
+ The function called by the timer every 10 millisecods This is usually where you will do the majority of the work.
+ You can define this manually, or when you instantiate the SpriteController |
+ + | Name | Description |
---|---|---|
![]() | OptimizeForLargeSpriteImages |
+ If your sprite images need substantial growing or shrinking when displayed, you can try setting this to "true"
+ to see if it makes it run any faster. What it does is to resize the image once, and keep a cached copy of that
+ image at that size. If you use the same sprite, but with different sizes, setting this to "True" may actually slow
+ down the game instead of speeding it up.
+ |
![]() | RandomNumberGenerator |
+ Since everything needs a random number generator, we make one that should be accessible throughout your program.
+ |
![]() ![]() | SpriteComparisonDelegate |
+ Allow the sprite sort-method to be overridden.
+ |
SpriteController MySpriteController;
MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+MySpriteController = new SpriteController(MainDrawingArea);
SpriteControllerSoundPlay Method |
+ Namespace: + SpriteLibrary
public void SoundPlay( + Stream ToPlay, + string Name +)
SpriteControllerPlaceSpriteBehind Method |
+ Namespace: + SpriteLibrary
public void PlaceSpriteBehind( + Sprite WhatToSend, + Sprite ToGoBehind +)
SpriteSpriteAdjustedPoint Method |
+ Namespace: + SpriteLibrary
public Point SpriteAdjustedPoint( + Point location +)
SpriteReplaceImage Method |
+ Namespace: + SpriteLibrary
public void ReplaceImage( + Image newimage, + int animation = -1, + int frame = -1 +)
SpriteSpriteAnimationComplete Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteAnimationComplete
SpriteSetSpriteDirectionDegrees Method |
+ Namespace: + SpriteLibrary
public void SetSpriteDirectionDegrees( + double AngleInDegrees +)
SpriteDestroying Property |
+ Namespace: + SpriteLibrary
SpriteMovingToPoint Property |
+ Namespace: + SpriteLibrary
SpriteAddAnimation Method |
+ + | Name | Description |
---|---|---|
![]() | AddAnimation(Image) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Size) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Int32) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand.
+ |
![]() | AddAnimation(Image, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Boolean, Boolean) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand using the MirrorHorizontally or MirrorVertically booleans.
+ |
![]() | AddAnimation(Image, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Point, Image, Int32, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
SpriteMoveTo Method (ListPoint) |
+ Namespace: + SpriteLibrary
public void MoveTo( + List<Point> DestinationList +)
SpriteMouseEnter Event |
+ Namespace: + SpriteLibrary
SpriteAddAnimation Method (Int32, Boolean, Boolean) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + int AnimationToCopy, + bool MirrorHorizontal, + bool MirrorVertical +)
SpriteSpriteArrivedAtWaypoint Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteArrivedAtWaypoint
SpriteEventArgsCollisionMethod Field |
+ Namespace: + SpriteLibrary
Sprite Constructor (SpriteController, Image, Int32, Int32) |
+ Namespace: + SpriteLibrary
public Sprite( + SpriteController Controller, + Image SpriteImage, + int width, + int height +)
SpriteSpriteEventHandler Delegate |
+ Namespace: + SpriteLibrary
public delegate void SpriteEventHandler( + Object sender, + SpriteEventArgs e +)
SpriteMoveTo Method |
+ + | Name | Description |
---|---|---|
![]() | MoveTo(ListPoint) |
+ Tell the sprite to move towards each point in turn. The sprite will move in a straight line until the first point.
+ From there it moves to the next point, until it has reached the last point. Every time it reaches a point, the
+ SpriteArrivedAtWaypoint event is triggered. When it reaches the final point in the list, the SpriteArrivedAtEndPoint
+ event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has
+ arrived, it is set to true.
+ |
![]() | MoveTo(Point) |
+ Tell the Sprite to move towards a destination. You need to give the sprite a MovementSpeed
+ and tell the sprite that it can automatically move. But the sprite will begin a journey towards
+ that point at the MovementSpeed you have set. When it gets to the point, the SpriteArrivedAtEndPoint event
+ will fire off. Also, the SpriteReachedEnd bool will be true.
+ |
![]() | MoveTo(Sprite) |
+ Move to where the destination sprite currently is at. This is a dumb move. It does not take into
+ consideration the movement direction of the destination sprite. So the moving sprite does need to be
+ moving a bit faster than the sprite you are trying to hit for it to do so.
+ |
SpriteRotation Property |
+ Namespace: + SpriteLibrary
SpriteAnimationCount Property |
+ Namespace: + SpriteLibrary
SpriteChangeAnimation Method |
+ Namespace: + SpriteLibrary
public void ChangeAnimation( + int WhichAnimation, + int StartFrame = 0 +)
SpriteConvertRadiansToDegrees Method |
+ Namespace: + SpriteLibrary
public double ConvertRadiansToDegrees( + double Radians +)
SpriteMoveTo Method (Sprite) |
+ Namespace: + SpriteLibrary
public void MoveTo( + Sprite Destination +)
SpriteController Methods |
The SpriteController type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | AddSprite |
+ Add the specified sprite to the list of sprites we know about. You usually do not need to do this.
+ Sprites add themselves to the controller when you create a new sprite.
+ |
![]() | AdjustPoint |
+ Adjust an image point so that it conforms to the picturebox.
+ |
![]() | AdjustRectangle |
+ Adjust a rectangle that is based on the image, according to the stretch of the picturebox
+ |
![]() | AllSprites |
+ Return a list of all sprites
+ |
![]() | ChangeTickInterval |
+ Change the Tick Interval. By default, the spritecontroller does a tick every 10ms, which
+ is very fast. Some people may prefer it to happen less regularly. Must be > 5, and less than 1001
+ |
![]() | CountSpritesBasedOff |
+ Count the number of sprites that were duplicated from the sprite with the specified name. When you use a
+ SpriteController.DuplicateSprite(string)
+ command, it creates a new sprite that is based off the named sprite. This function will count those duplicated sprites.
+ |
![]() | DestroyAllSprites |
+ Remove all sprites (even named sprites that have not yet been displayed)
+ |
![]() | DestroySprite |
+ Tell a sprite to destroy itself. The sprite will have Destroying property set to true from
+ the time you destroy it until it vanishes. Whe you destroy a sprite, it will erase itself
+ and remove itself from the controller. After it is destroyed, it is completely gone.
+ |
![]() ![]() | DuplicateSprite(String) |
+ Find a sprite that has been named with the specified name. Then duplicate that sprite
+ |
![]() | DuplicateSprite(Sprite) |
+ Make a duplicate of the specified sprite. The duplicate does not yet have a location.
+ |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Invalidate(Boolean) |
+ Invalidate the entire image on which the sprites are drawn
+ |
![]() | Invalidate(Rectangle, Boolean) |
+ Invalidate a rectangle that is specified in image coordinates
+ |
![]() | IsKeyPressed |
+ Check to see if any keys are pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | IsKeyPressed(Keys) |
+ Check to see if the given key is pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | KeysPressed |
+ Return a list of all the keys that are currently pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | NameSprite |
+ Find the specified Sprite in the controller and change its name to the specified string.
+ You can do the same thing with Sprite.SetName(Name) |
![]() | Pause |
+ Pause everything. It loops through all the sprites in the SpriteController and sends the specified
+ SpritePauseType to each one. Look at the documentation for SpritePauseType to determine which pause
+ type to use.
+ |
![]() | PlaceSpriteBehind |
+ Change the display order of the sprites such that the specified sprite appears behind the other sprite.
+ |
![]() | PlaceSpriteInFrontOf |
+ Make the sprite go in front of the specified sprite.
+ |
![]() | RegisterKeyDownFunction |
+ If you want to have a KeyDown function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+ |
![]() | RegisterKeyUpFunction |
+ If you want to have a KeyUp function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+ |
![]() | ReplaceOriginalImage |
+ Notify the sprite controller that you have changed the background image on the
+ PictureBox. Whatever background is on the picturebox is now used to draw all the sprites on.
+ |
![]() ![]() | ReplaceOriginalImage(Image) |
+ Replace the image on which the sprites are drawn. Use this when you move to a new playing field,
+ or want to have a different background
+ ![]()
+ Replacing the background image is actually a lot more complex than you might imagine. Once you use the
+ below code, it can be done without any problem. But you need to do it this way, or it just goofs up in
+ a number of small ways.
+ You need to tell the sprite controller that you are replacing the background image,
+ and you need to change the image to that image as well.Because the Images are actually
+ pointers to memory where the image sets, changes to one image will affect the other image.This goofs
+ things up, so what we do is duplicate the image twice, and tell the sprite controller to use one of the
+ copies and then set the background to be the other one of the two copies.Finally, we tell the picturebox
+ to invalidate itself.That does everything that is needed.
+ C# void ReplaceBackground(Image NewBackground) +{ + if (MyController == null) return; + if (NewBackground == null) return; + + Image OneImage = new Bitmap(NewBackground); + MyController.ReplaceOriginalImage(OneImage); + + Image TwoImage = new Bitmap(NewBackground); + pb_map.BackgroundImage = TwoImage; + pb_map.Invalidate(); +} |
![]() | ResetKeypressState |
+ Reset the keypress status. Sometimes the sprite controller misses a key being released (usually
+ because a window has taken priority, or something has changed). Calling this function will reset
+ the stored memory of whether a key has been pressed.
+ |
![]() | ReturnAdjustmentRatio |
+ Return an adjustment ratio. This is the image-size to picture-box ratio.
+ It is used for calculating precise pixels or picture-box locations.
+ |
![]() | ReturnPictureBoxAdjustedHeight |
+ Return the height of an object in picture-box terms. It is basically the virtual height
+ of the sprite or other item.
+ |
![]() | ReturnPictureBoxAdjustedPoint |
+ This does the reverse of an adjusted point. It takes a point on the image and
+ transforms it to one on the PictureBox
+ |
![]() | ReturnPictureBoxAdjustedWidth |
+ Return the width of an object in picture-box terms. It takes the width of a sprite or other
+ item that is being displayed on the screen, and calculates the width as displayed in the
+ picture-box (taking into consideration stretching or shrinking)
+ |
![]() | ReturnPointAdjustedForImage |
+ This takes a point, the location on a picturebox, and returns the corresponding point on the BackgroundImage.
+ Picturebox locations are "sloppy"; the background image locations are very precise. Since this takes a "sloppy"
+ number and returns a precise number, it does some rounding to figure out where the specified location is.
+ |
![]() | SoundIsFinished |
+ Check to see if the specified sound has finished playing
+ |
![]() | SoundPlay |
+ Play a sound that we can check to see if it has completed.
+ |
![]() | SpriteBackwards |
+ Change the display order of the specified sprite so it is more likely to go behind all other sprites.
+ |
![]() | SpriteForwards |
+ Change the display order of the specified sprite so it is more likely to go in front of other sprites
+ |
![]() | SpriteFromName |
+ Find a sprite that has a specified name. This returns the actual sprite with that name.
+ You usually want to use DuplicateSprite(Name) to clone the sprite and get one you can
+ destroy. If you destroy a named sprite without duplicating it, you may end up losing
+ it for the remainder of the program.
+ |
![]() | SpritesAtImagePoint |
+ This takes a point, as as specified on the image, and returns the sprites at that point. Different
+ functions use different coordinates, whether based off the background image, or based off the picturebox.
+ This one uses the background image coordinates. Use SpritesAdPoint() if you are doing something based off
+ a MouseUp or MouseDown function. This is used for functions based on sprite location or based off the absoloute
+ location (using the background image location is much more precise than the visible location in the picturebox)
+ |
![]() | SpritesAtPoint |
+ This takes a point, as given by the mouse-click args, and returns the sprites at that point. Different
+ functions use different coordinates, whether based off the background image, or based off the picturebox.
+ This one uses the picturebox coordinates. So you can use this directly from a MouseDown or MouseUp function.
+ |
![]() | SpritesBasedOff |
+ Return all sprites that were based off a particular sprite name.
+ When you use a
+ SpriteController.DuplicateSprite(string)
+ command, it creates a new sprite that is based off the named sprite. This function returns a list of those
+ duplicated sprites.
+ |
![]() | SpritesBasedOffAnything |
+ Return a list of all sprites which are not master sprites (which are duplicates of something)
+ |
![]() | SpritesInImageRectangle |
+ Return a list of all the sprites that intersect with the given background-image-based rectangle
+ |
![]() | SpritesThatHaveBeenDrawn |
+ Return a list of all sprites which have been drawn on the image
+ |
![]() | SpriteToBack |
+ Change the display order of the specified sprite so it goes behind all other sprites.
+ |
![]() | SpriteToFront |
+ Change the display order of the specified sprite so it goes in front of all other sprites.
+ |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | UnPause |
+ un-Pause everything. This will send the specified SpritePauseType unpause command
+ to all sprites.
+ |
SpriteBaseImageLocation Property |
+ Namespace: + SpriteLibrary
SpriteSpriteInitializes Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteInitializes
SpriteControllerSpritesThatHaveBeenDrawn Method |
+ Namespace: + SpriteLibrary
public List<Sprite> SpritesThatHaveBeenDrawn()
SpriteControllerReplaceOriginalImage Method |
+ + | Name | Description |
---|---|---|
![]() | ReplaceOriginalImage |
+ Notify the sprite controller that you have changed the background image on the
+ PictureBox. Whatever background is on the picturebox is now used to draw all the sprites on.
+ |
![]() ![]() | ReplaceOriginalImage(Image) |
+ Replace the image on which the sprites are drawn. Use this when you move to a new playing field,
+ or want to have a different background
+ ![]()
+ Replacing the background image is actually a lot more complex than you might imagine. Once you use the
+ below code, it can be done without any problem. But you need to do it this way, or it just goofs up in
+ a number of small ways.
+ You need to tell the sprite controller that you are replacing the background image,
+ and you need to change the image to that image as well.Because the Images are actually
+ pointers to memory where the image sets, changes to one image will affect the other image.This goofs
+ things up, so what we do is duplicate the image twice, and tell the sprite controller to use one of the
+ copies and then set the background to be the other one of the two copies.Finally, we tell the picturebox
+ to invalidate itself.That does everything that is needed.
+ C# void ReplaceBackground(Image NewBackground) +{ + if (MyController == null) return; + if (NewBackground == null) return; + + Image OneImage = new Bitmap(NewBackground); + MyController.ReplaceOriginalImage(OneImage); + + Image TwoImage = new Bitmap(NewBackground); + pb_map.BackgroundImage = TwoImage; + pb_map.Invalidate(); +} |
SpriteController Constructor |
+ + | Name | Description |
---|---|---|
![]() ![]() | SpriteController(PictureBox) |
+ Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed. You want to have the PictureBox already defined, and a background image
+ already set for the PictureBox.
+ |
![]() ![]() | SpriteController(PictureBox, EventHandler) |
+ Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed.
+ |
SpriteControllerOptimizeForLargeSpriteImages Field |
+ Namespace: + SpriteLibrary
SpriteSetName Method |
+ Namespace: + SpriteLibrary
public void SetName( + string Name +)
SpriteSpriteExitsPictureBox Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteExitsPictureBox
SpriteKeyEventHandler Delegate |
+ Namespace: + SpriteLibrary
public delegate void SpriteKeyEventHandler( + Object sender, + KeyEventArgs e +)
Spritepayload Field |
public class TankPayload : SpritePayload { public int Armor; public int Speed; }
+ Namespace: + SpriteLibrary
SpriteSpriteHitsPictureBox Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteHitsPictureBox
SpriteAnimateJustAFewTimes Method |
+ Namespace: + SpriteLibrary
public void AnimateJustAFewTimes( + int WhichAnimation, + int HowManyAnimations, + int AnimationFrameToEndOn = -1 +)
SpriteControllerSpritesAtPoint Method |
+ Namespace: + SpriteLibrary
public List<Sprite> SpritesAtPoint( + Point Location +)
SpriteGetImage Method (Int32, Int32) |
+ Namespace: + SpriteLibrary
public Image GetImage( + int Animation_Index, + int Frame_Index +)
SpriteController Events |
The SpriteController type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() ![]() | DoTick |
+ The function called by the timer every 10 millisecods This is usually where you will do the majority of the work.
+ You can define this manually, or when you instantiate the SpriteController |
SpriteControllerReturnAdjustmentRatio Method |
+ Namespace: + SpriteLibrary
public SpriteAdjustmentRatio ReturnAdjustmentRatio()
SpriteControllerReturnPictureBoxAdjustedHeight Method |
+ Namespace: + SpriteLibrary
public int ReturnPictureBoxAdjustedHeight( + int Height +)
SpriteControllerInvalidate Method (Boolean) |
+ Namespace: + SpriteLibrary
public void Invalidate( + bool QueueUpInvalidation = true +)
SpriteEventArgs Methods |
The SpriteEventArgs type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
SpriteControllerResetKeypressState Method |
+ Namespace: + SpriteLibrary
public void ResetKeypressState()
SpriteControllerReplaceOriginalImage Method |
+ Namespace: + SpriteLibrary
public void ReplaceOriginalImage()
SpriteAddAnimation Method (Image, Size) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Image SpriteImage, + Size SpriteSize +)
SpritePayload Class |
+ Namespace: + SpriteLibrary
public class SpritePayload
The SpritePayload type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | SpritePayload | Initializes a new instance of the SpritePayload class |
+ + | Name | Description |
---|---|---|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
public class TankPayload : SpritePayload +{ + public int Armor = 20; + public int FireTime = 100; +}
TankSprite.Payload = new TankPayload();
if(TankSprite.payload != null and TankSprite.payload is TankPayload) +{ + TankPayload tPayload = (TankPayload)TankSprite.payload; tPayload.Armor--; +}
SpriteControllerAdjustRectangle Method |
+ Namespace: + SpriteLibrary
public Rectangle AdjustRectangle( + Rectangle ImageRectangle +)
SpriteSpriteAtImagePoint Method |
+ Namespace: + SpriteLibrary
public bool SpriteAtImagePoint( + Point location, + SpriteCollisionMethod method = SpriteCollisionMethod.rectangle +)
SpriteControllerIsKeyPressed Method |
+ + | Name | Description |
---|---|---|
![]() | IsKeyPressed |
+ Check to see if any keys are pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
![]() | IsKeyPressed(Keys) |
+ Check to see if the given key is pressed. There is a small glitch with the
+ key-pressed system. If the form loses focus, and someone releases a key, the key-up is never
+ triggered. It is a good thing to ResetKeypressState() occasionally if you think your form may have
+ lost focus.
+ |
SpriteClickTransparent Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler ClickTransparent
SpriteAddAnimation Method (Image, Int32) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Image SpriteImage, + int duration +)
SpriteControllerDestroySprite Method |
+ Namespace: + SpriteLibrary
public void DestroySprite( + Sprite what +)
SpriteReturnAdjustmentRatio Method |
+ Namespace: + SpriteLibrary
public SpriteAdjustmentRatio ReturnAdjustmentRatio()
SpriteAdjustmentRatio Methods |
The SpriteAdjustmentRatio type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.) |
SpritePayload Methods |
The SpritePayload type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
SpritePutBaseImageLocation Method (Point) |
+ Namespace: + SpriteLibrary
public void PutBaseImageLocation( + Point NewLocationOnImage +)
SpriteVisibleHeight Property |
+ Namespace: + SpriteLibrary
SpriteControllerSpriteToBack Method |
+ Namespace: + SpriteLibrary
public void SpriteToBack( + Sprite What +)
SpriteCheckSpriteHitsSprite Method |
+ Namespace: + SpriteLibrary
public void CheckSpriteHitsSprite( + Sprite target, + SpriteCollisionMethod how +)
SpriteFrameIndex Property |
+ Namespace: + SpriteLibrary
SpriteControllerDuplicateSprite Method (String) |
+ Namespace: + SpriteLibrary
public Sprite DuplicateSprite( + string Name +)
public void AddSprite(string name, int startx, int starty) +{ + Sprite NewSprite = MySpriteController.DuplicateSprite(What.ToString()); + if(NewSprite != null) + { + NewSprite.AutomaticallyMoves = true; + NewSprite.CannotMoveOutsideBox = true; + NewSprite.SetSpriteDirectionDegrees(180); //left + NewSprite.PutBaseImageLocation(new Point(startx, starty)); + NewSprite.MovementSpeed = 5; + } +}
SpritePictureBoxLocation Property |
+ Namespace: + SpriteLibrary
SpriteControllerDestroyAllSprites Method |
+ Namespace: + SpriteLibrary
public void DestroyAllSprites()
SpriteSpriteBeingDestroyed Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteBeingDestroyed
Sprite Constructor (SpriteController, Image, Int32, Int32, Int32) |
+ Namespace: + SpriteLibrary
public Sprite( + SpriteController Controller, + Image SpriteImage, + int width, + int height, + int durationInMilliseconds +)
Sprite Class |
+ Namespace: + SpriteLibrary
public class Sprite
The Sprite type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Sprite(Sprite, Boolean) |
+ Create a Sprite that is based off of the specified sprite. Clone the Sprite except that
+ we set SpriteName = "" and OrigSpriteName = the OldSprite.SpriteName. That way we know that
+ the sprite was duplicated from the original, and we can still distinguish the original from
+ the duplicate.
+ |
![]() | Sprite(SpriteController, Image) |
+ Generate a new single-frame sprite from the specified image.
+ |
![]() | Sprite(SpriteController, Image, Size) |
+ Generate a new sprite. It takes the image and the width and height. If there are multiple images of that width
+ and height in the image, an animation is created.
+ |
![]() | Sprite(SpriteController, Image, Int32, Int32) |
+ Generate a new sprite. It takes the image and the width and height. If there are multiple images of that width
+ and height in the image, an animation is created.
+ |
![]() | Sprite(SpriteController, Image, Int32, Int32, Int32) |
+ Generate a new sprite. It takes a width, height, and the duration in Milliseconds for each frame
+ |
![]() | Sprite(Point, SpriteController, Image, Int32, Int32, Int32, Int32) |
+ Create a Sprite from an animation image, specifying the number of consecutive
+ frames to grab.
+ |
+ + | Name | Description |
---|---|---|
![]() | AnimationCount |
+ The number of animations this sprite has
+ |
![]() | AnimationDone |
+ Report whether or not the animation has been completed. When you tell a Sprite to AnimateOnce,
+ this will report "false" until the animation sequence has been finished. At that time, the value
+ will be "True." The tricky bit is that this is a boolean. If you have not told a sprite to
+ animate once, it will always return "false." If a sprite is paused, this returns "false." The only
+ time this returns "true" is when you tell a sprite to animate once, or animate a few times, and those
+ times have completed. At that time, this will report "True". If you have a sprite with only one frame,
+ it may not look like it is "animating", but it is. It is simply animating that one frame over and over.
+ So, AnimationDone reports false, unless you have told it to animate_once.
+ |
![]() | AnimationIndex |
+ Get or set the animation nimber. It is best to change the animation using ChangeAnimation.
+ It is safer.
+ |
![]() | AutomaticallyMoves |
+ Determine if the sprite automatically moves (you need to give it a direction [using one of the
+ SetSpriteDirection functions] and speed [MovementSpeed = X] also)
+ |
![]() | BaseImageLocation |
+ The sprite location as found on the base image. This is usually the easiest location to use.
+ |
![]() | Destroying |
+ If the Sprite is in the middle of being Destroyed, this is set to true. When a Sprite is
+ Destroyed, it needs to erase itself and do some house-cleaning before it actually vanishes.
+ During this time, you may not want to use it. It is always a good thing to verify a Sprite
+ is not in the middle of being destroyed before you do something important with it. To Destroy
+ a Sprite, use the Sprite.Destroy() function.
+ |
![]() | FrameIndex |
+ This is the frame of the current animation sequence. You can use this if you need to figure out what frame index
+ to resume something at, or something like that.
+ |
![]() | GetSize |
+ Return the size of the sprite in reference to the image on which it is drawn. To get the
+ size of the Sprite in relation to the PictureBox, use GetVisibleSize
+ |
![]() | GetVisibleSize |
+ Return the relative size of the Sprite in relation to the PictureBox. If the box has been
+ stretched or shrunk, that affects the visible size of the sprite.
+ |
![]() | HasBeenDrawn |
+ Report whether or not this Sprite has been drawn. If it has, then it needs to be erased at
+ some point in time.
+ |
![]() | ID |
+ The Sprite ID as specified by the sprite controller.
+ |
![]() | MovingToPoint |
+ Tells us if we are in the process of doing a MoveTo operation. This boolean should be the
+ opposite of SpriteReachedEndpoint, but that boolean is poorly named. This is usually the easier
+ one to use.
+ |
![]() | Opacity |
+ Set the opacity of the sprite. The value should be between 0 and 1. 1 is solid, 0 is transparent.
+ Sometimes you want to drag a sprite around the map, or show a sprite that "could be there." Setting
+ the sprite opacity is usually how you do that. One warning, however. The opacity value takes effect the
+ next time it is drawn. If the sprite is animating rapidly, it will take effect nearly emmediately. If
+ it is not animating, not moving, or just sitting there, then it may not take effect for quite some time.
+ |
![]() | PictureBoxLocation |
+ The sprite location as found on the picture-box that this sprite is associated with. Used when dealing with mouse-clicks
+ |
![]() | Rotation |
+ Change the rotation of the sprite, using degrees. 0 degrees is to the right. 90 is up.
+ 180 left, 270 down. But, if your sprite was drawn facing up, then rotating it 90 degrees
+ will have it pointing left. The angle goes counter-clockwise. The image will be scaled
+ such that it continues to fit within the rectangle that it was originally in. This results
+ in a little bit of shrinking at times, but you should rarely notice that.
+ |
![]() | SpriteName |
+ The name of the sprite. Use SetSpriteName(Name) to change this name. Most Named sprites
+ are used to define what a sprite is. Once you have created a named sprite, you usually use
+ DuplicateSprite(String) to clone the sprite for use. The basic rule of thumb is
+ to load your sprites from images once, and name the initial sprites. Then, when you go to use
+ those sprites, get duplicates of them. The reason for this is because it takes more processing time to initially
+ create the sprites than it takes to duplicate them.
+ |
![]() | SpriteOriginName |
+ Return the name of the sprite that this was duplicated from. A duplicated sprite will have
+ no name, but will have a SpriteOriginName.
+ |
![]() | SpriteReachedEndPoint |
+ This is true unless we are using MoveTo(point) or MoveTo(list of points) to tell the sprite to move
+ from one place to the next. This boolean tells us if it has finished or not.
+ |
![]() | VisibleHeight |
+ The visible Height as seen in the PictureBox. It may be stretched, or shrunk from the actual
+ image size.
+ |
![]() | VisibleWidth |
+ The visible width as seen in the PictureBox. The Sprite may be stretched or shrunk from the
+ actual image size.
+ |
![]() | Zvalue |
+ A number from 0 to 100. Default = 50. Higher numbers print on top of lower numbers. If you want a sprite to
+ always be drawn on top of other sprites, give it a number higher than 50. If you want a sprite to go under
+ other sprites, make its number lower than 50.
+ |
+ + | Name | Description |
---|---|---|
![]() | AddAnimation(Image) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Size) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Int32) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand.
+ |
![]() | AddAnimation(Image, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Boolean, Boolean) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand using the MirrorHorizontally or MirrorVertically booleans.
+ |
![]() | AddAnimation(Image, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Point, Image, Int32, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AnimateJustAFewTimes |
+ Start a new animation. It will complete the animation the number of times you specify.
+ For example, if your sprite is walking, and one animation is one step, specifying 4 here
+ will result in your sprite taking 4 steps and then the animation stops. You will want
+ to make sure you are checking for when the animation stops, using the SpriteAnimationComplete event,
+ checking the Sprite.AnimationDone flag.
+ |
![]() | AnimateOnce |
+ Start a new animation, but do it just once. You can use AnimateJustAFewTimes(1) to the same effect.
+ Or, you can use AnimateJustAFewTimes with a different number. The SpriteAnimationComplete event will
+ fire off when the animation completes. The variable, Sprite.AnimationDone will be true once the
+ animation finishes animating.
+ |
![]() | CancelMoveTo |
+ Cancel a MoveTo command. The sprite will stop moving, and all the waypoints will be removed.
+ |
![]() | ChangeAnimation |
+ Start a new animation index from scratch
+ |
![]() | ChangeAnimationSpeed |
+ Change the animation speed of a particular animation. This looks at the first frame
+ and compares that frame to the speed specified. It adjusts all the animations by the
+ same percentage.
+ |
![]() | ChangeFrameAnimationSpeed |
+ Change the animation speed of a specific frame. Beware. This affects every sprite using this frame
+ |
![]() | CheckSpriteHitsSprite |
+ Check to see if two sprites hit each-other. The sprite collision methods are
+ not all programmed in.
+ |
![]() | ConvertDegreesToRadians |
+ Convert a number from degrees to radians.
+ |
![]() | ConvertRadiansToDegrees |
+ Convert a number from radians to degrees.
+ |
![]() | Destroy |
+ Tell the sprite to kill itself. It will erase itself and then
+ be removed from the spritelist. Then it will be gone forever.
+ |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetAnimationSpeed |
+ Return the animation speed of this particualar animation of the sprite.
+ |
![]() | GetFrameAnimationSpeed |
+ Get the animation speed of a single frame.
+ |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetImage |
+ return the current image frame. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
![]() | GetImage(Int32, Int32) |
+ return the frame for the given index. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
![]() | GetSpriteBaseImageCenter |
+ Return the centerpoint of the sprite, as found on the background image
+ |
![]() | GetSpriteDegrees |
+ Get the direction that the sprite is traveling in in degrees. You may want to
+ use Math.Round on the results. The value returned is usually just a tiny bit off
+ from what you set it with. For example, if you set the sprite movement direction
+ to be 270 degrees (down), this function may return it as 269.999992. Rounding the
+ number will give it back to you at probably the same direction you set it as.
+ |
![]() | GetSpritePictureboxCenter |
+ Return the centerpoint of the sprite, as found on the picturebox
+ |
![]() | GetSpriteRadans |
+ Returns the direction the sprite is currently traveling, using Radians.
+ |
![]() | GetSpriteVector |
+ Return the current vector that the sprite is moving along
+ |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | HideSprite |
+ Remove the sprite from the field. This does not destroy the sprite. It simply removes it from action.
+ Use UnhideSprite to show it again.
+ |
![]() | IsPaused |
+ Ask if the sprite is paused using the specified sprite type (default is PauseAll)
+ |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MoveTo(ListPoint) |
+ Tell the sprite to move towards each point in turn. The sprite will move in a straight line until the first point.
+ From there it moves to the next point, until it has reached the last point. Every time it reaches a point, the
+ SpriteArrivedAtWaypoint event is triggered. When it reaches the final point in the list, the SpriteArrivedAtEndPoint
+ event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has
+ arrived, it is set to true.
+ |
![]() | MoveTo(Point) |
+ Tell the Sprite to move towards a destination. You need to give the sprite a MovementSpeed
+ and tell the sprite that it can automatically move. But the sprite will begin a journey towards
+ that point at the MovementSpeed you have set. When it gets to the point, the SpriteArrivedAtEndPoint event
+ will fire off. Also, the SpriteReachedEnd bool will be true.
+ |
![]() | MoveTo(Sprite) |
+ Move to where the destination sprite currently is at. This is a dumb move. It does not take into
+ consideration the movement direction of the destination sprite. So the moving sprite does need to be
+ moving a bit faster than the sprite you are trying to hit for it to do so.
+ |
![]() | Pause |
+ Pause the sprite. We can pause just the animation (and still let it move), pause movement (and let it animate), or pause everything.
+ |
![]() | PutBaseImageLocation(Point) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
![]() | PutBaseImageLocation(Double, Double) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
![]() | PutPictureBoxLocation |
+ Put the Sprite at a specified location, using the dimentions of the PictureBox.
+ You want to use this if you got your X/Y position from a mouse-click. Otherwise,
+ this is the harder way to track things, particularly if your window can resize. Use
+ PutBaseImageLocation instead.
+ |
![]() | RecalcPictureBoxLocation |
+ Done when the box resizes. We need to recompute the picturebox location. The resize function
+ automatically calls this. You should never need to do so.
+ |
![]() | ReplaceImage |
+ Replace a sprite image. It will replace the current frame unless you specify both an animation
+ and the frame within the animation you wish to replace. Warning: This replaces the image_frame
+ for every sprite that uses that is based off the same image.
+ |
![]() | ReturnAdjustmentRatio |
+ Taking into consideration how the sprite is stretched or shrunk, it
+ returns a SpriteAdjustmentRatio that can be used to work with the sprite
+ itself.
+ |
![]() | SendToBack |
+ Make the sprite go behind all other sprites
+ |
![]() | SendToFront |
+ Make the sprite show up in front of all other sprites.
+ |
![]() | SetName |
+ Give this sprite a name. This way we can make a duplicate of it by specifying the name
+ |
![]() | SetSize |
+ Resize the sprite using the base image coordinates. The width and height specified
+ are relative to the size of the background image, not the picturebox.
+ |
![]() | SetSpriteDirection |
+ Set the sprite direction using a vector. The vector may contain
+ a speed as well as the movement delta (amount of x shift, and amount
+ of y shift.) If so, this function may also affect the movement speed
+ Most people prefer to use SetSpriteDirectionDegrees instead of using
+ vectors.
+ |
![]() | SetSpriteDirectionDegrees |
+ Given a "degree" (from 0 to 360, set the direction
+ that the sprite moves automatically. 0 is right, 90 is up, 180 is left
+ and 270 is down.
+ |
![]() | SetSpriteDirectionRadians |
+ Set the sprite direction using Radians. Most people do not want to use this.
+ Use SetSpriteDirectionDegrees instead unless you like math and know what you
+ are doing with Radians.
+ |
![]() | SetSpriteDirectionToPoint |
+ Sets the Sprite Moving towards a given point. You are responsible to do something with it once it gets there.
+ If you want it to automatically stop upon reaching it, use MoveTo instead. Actually, the MoveTo function works
+ a lot better than this one. Because of integer rounding and a few other things, this function is a little
+ bit imprecise. If you send it towards a point, it will go in that general direction. The MoveTo function
+ will perpetually recalculate its way to the destination point and actually reach that point. SetSpriteDirectionToPoint
+ will sort-of head in the direction of the point. But MoveTo will go to that point.
+ |
![]() | SpriteAdjustedPoint |
+ Because sprites are scaled (shrunk or stretched), this function finds the point
+ within the sprite that is specified by the location. this function is used by
+ a number of internal processes, but may be useful to you. But probably not.
+ |
![]() | SpriteAtImagePoint |
+ Check to see if the sprite exists at the point specified. The point given is
+ in coordinates used by the image (not the PictureBox, use SpriteAtPictureBox for that)
+ |
![]() | SpriteAtPictureBoxPoint |
+ Return true or false, asking if the specifiec sprite is at the point on the picturebox.
+ You can use this with a mouse-click to see if you are clicking on a sprite. Use the
+ SpriteCollisionMethod "transparent" to see if you have clicked on an actual pixel of the
+ sprite instead of just within the sprite rectangle.
+ |
![]() | SpriteCanMoveOnImage |
+ Return true if the sprite can go to this point and still be on the drawing-board.
+ |
![]() | SpriteCanMoveOnPictureBox |
+ Return true if the sprite can go to this point and still be on the drawing-board.
+ |
![]() | SpriteIntersectsRectangle |
+ Check to see if the specified rectangle overlaps with the sprite.
+ |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | UnhideSprite |
+ Make the sprite reappear. If you have not positioned it yet, it will show up at the top corner. It is best to only
+ use this when you have hidden it using HideSprite
+ |
![]() | UnPause |
+ unpause the sprite.
+ |
+ + | Name | Description |
---|---|---|
![]() | CheckBeforeMove |
+ This event fires off before a sprite is drawn. Use it if you have constraints. You
+ can change the location or cancel the move entirely.
+ |
![]() | Click |
+ This event happens when someone clicks on the sprite (on the rectangle in which the sprite is).
+ If you want the event to fire off only when someone clicks on the visible part of the sprite,
+ use ClickTransparent instead.
+ |
![]() | ClickTransparent |
+ This event happens when someone clicks on the sprite (on the sprite image itself).
+ If the sprite is sometimes hidden, but you want the click to work even if it is not
+ visible at that instant, use Click instead.
+ |
![]() | MouseEnter |
+ When the mouse moves over the sprite. Use this for a menu, when you want the menu item to glow when the
+ mouse is over the menu item sprite.
+ |
![]() | MouseEnterTransparent |
+ When the mouse moves over a non-transparent portoin of the sprite. Use this for a menu, when you want the
+ menu item to glow when the mouse is over the menu item sprite.
+ |
![]() | MouseHover |
+ This event happens when the mouse moves over the sprite, and then pauses. We use the hover timing from the
+ parent form.
+ |
![]() | MouseHoverTransparent |
+ This event happens when the mouse moves over a non-transparent portion of the sprite, and then pauses.
+ We use the hover timing from the parent form.
+ |
![]() | MouseLeave |
+ When the mouse moves off the sprite. Use this for a menu, when you want the menu item to stop glowing when
+ the mouse moves away from the menu item sprite.
+ |
![]() | MouseLeaveTransparent |
+ When the mouse moves off the non-transparent portion of the sprite. Use this for a menu, when you want the
+ menu item to stop glowing when
+ the mouse moves away from the menu item sprite.
+ |
![]() | SpriteAnimationComplete |
+ Only used when you tell an animation to animate once. At the end of the animation,
+ this function fires off.
+ |
![]() | SpriteArrivedAtEndPoint |
+ An event for when you tell a Sprite to MoveTo(Point) a specific point, or, when you
+ tell the Sprite to MoveTo(list of points). When the Sprite has reached the final destination,
+ the Sprite fires off this event.
+ |
![]() | SpriteArrivedAtWaypoint |
+ When you tell a sprite to MoveTo(list of points), this fires off every time it gets to
+ one of the points. When it gets to the final point, only the SpriteAtEndPoint event fires off.
+ |
![]() | SpriteBeingDestroyed |
+ The Sprite has just been told to be destroyed. You might want to do some cleanup.
+ If you need to destroy some payload data, or tell something to cleanup after the sprite
+ this is where to do that.
+ |
![]() | SpriteChangesAnimationFrames |
+ When the frame of an animation changes. If you want to have something happen every time
+ the foot of your monster comes down, when the swing of your sword is at certain points, etc.
+ Check to see that the Animaton and FrameIndex are what you expect them to be.
+ |
![]() | SpriteExitsPictureBox |
+ This happens when the sprite has exited the picture box. Useful when you want to
+ keep sprites from traveling on forever after exiting.
+ |
![]() | SpriteHitsPictureBox |
+ This happens when the sprite hits the border of the picture-box.
+ Useful for when you want to have shots explode when they hit the side.
+ |
![]() | SpriteHitsSprite |
+ This happens when two sprites hit each-other. The SpriteEventArgs that is returned
+ contains the sprite that this sprite hits.
+ |
![]() | SpriteInitializes |
+ This event happens right after the sprite is created. Use this to immediately set a
+ sprite to animate once or something like that.
+ |
+ + | Name | Description |
---|---|---|
![]() | CannotMoveOutsideBox |
+ Determine if the sprite will automatically move outside the box. If not, it will hit the side of the box and stick
+ |
![]() | MirrorHorizontally |
+ Flip the image when it gets printed. If your sprite is walking left, flipping it will
+ make it look like it is going right.
+ This works great for many things. But, if your program is gobbling memory or CPU, you may need to
+ consider using Sprite.AddAnimation |
![]() | MirrorVertically |
+ Flip the image when it gets printed. If your sprite looks like it is facing up, doing
+ this will make it look like it faces down.
+ This works great for many things. But, if your program is gobbling memory or CPU, you may need to
+ consider using Sprite.AddAnimation |
![]() | MovementSpeed |
+ The movement speed of the sprite. To make a Sprite move, you need to set the MovementSpeed,
+ the direction (using
+ SetSpriteDirection(Vector),
+ SetSpriteDirectionToPoint(Point),
+ SetSpriteDirectionRadians(Double),
+ or SetSpriteDirectionDegrees(Double)), and the
+ AutomaticallyMoves property.
+ The speed is calculated in pixels per amount of time. A higher number is faster than a lower number.
+ |
![]() | payload |
+ A Sprite can hold a payload. Use this to store extra information about the various Sprites. Health, Armor,
+ Shoot time, etc. But, to store information in the payload, you need to make a new class of SpritePayload. The syntax
+ for doing so is:
+ public class TankPayload : SpritePayload { public int Armor; public int Speed; } |
SpriteControllerAllSprites Method |
+ Namespace: + SpriteLibrary
SpriteUnPause Method |
+ Namespace: + SpriteLibrary
public void UnPause( + SpritePauseType What = SpritePauseType.PauseAll +)
SpriteControllerUnPause Method |
+ Namespace: + SpriteLibrary
public void UnPause( + SpritePauseType What = SpritePauseType.PauseAll +)
SpriteMirrorVertically Field |
+ Namespace: + SpriteLibrary
SpriteControllerAdjustPoint Method |
+ Namespace: + SpriteLibrary
public Point AdjustPoint( + Point LocationOnImage +)
SpritePayload Constructor |
+ Namespace: + SpriteLibrary
public SpritePayload()
SpriteZvalue Property |
+ Namespace: + SpriteLibrary
SpriteLibrary Namespace |
+ + | Class | Description |
---|---|---|
![]() | Sprite |
+ A Sprite is an animated image that has a size, position, rotation, and possible vector
+ It tracks where in the animation sequence it is, can report colisions, etc. This SpriteController
+ draws, moves, and deals with most graphical aspects of the sprites for you.
+ |
![]() ![]() | SpriteController |
+ A sprite controller is the main heart of the sprite class. Each SpriteController manages one picturebox.
+ If at all possible, try to keep each game in one picturebox, and try to avoid making and destroying
+ new forms with SpriteController/pictureboxes in them. It is hard to destroy them completely.
+ |
![]() | SpriteEventArgs |
+ An EventArgs that contains information about Sprites. Most of the Sprite events use
+ this SpriteEventArgs.
+ |
![]() ![]() | SpritePayload |
+ The SpritePayload is a stub of a class, for storing user-defined data and functions along with a sprite.
+ |
+ + | Structure | Description |
---|---|---|
![]() | SpriteAdjustmentRatio |
+ A structure that contains the width and height adjustment ratio. Use this if you need to manually calculate positions
+ between the PictureBox that the sprite is in, and the Background Image itself.
+ |
+ + | Delegate | Description |
---|---|---|
![]() | SpriteSpriteEventHandler |
+ A delegate that has a SpriteEventArgs instead of EventArgs. Used for most
+ of the Sprite events. This allows us to pass more information from sprite events than
+ a basic EventArgs allows for
+ |
![]() | SpriteKeyEventHandler |
+ This is a delegate for a keypress event.
+ |
+ + | Enumeration | Description |
---|---|---|
![]() | SpriteCollisionMethod |
+ The various types of collisions a sprite can have. Currently only rectangle works. The other types were added when I
+ thought the different types of collision types were needed. Someday we may add these if we find they are useful, or if
+ someone else decides they want to help program the SpriteLibrary. These values are primarily used in Sprite Events
+ |
![]() | SpritePauseType |
+ The type of pause signals you can give a sprite or the sprite controller
+ |
Sprite Fields |
The Sprite type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | CannotMoveOutsideBox |
+ Determine if the sprite will automatically move outside the box. If not, it will hit the side of the box and stick
+ |
![]() | MirrorHorizontally |
+ Flip the image when it gets printed. If your sprite is walking left, flipping it will
+ make it look like it is going right.
+ This works great for many things. But, if your program is gobbling memory or CPU, you may need to
+ consider using Sprite.AddAnimation |
![]() | MirrorVertically |
+ Flip the image when it gets printed. If your sprite looks like it is facing up, doing
+ this will make it look like it faces down.
+ This works great for many things. But, if your program is gobbling memory or CPU, you may need to
+ consider using Sprite.AddAnimation |
![]() | MovementSpeed |
+ The movement speed of the sprite. To make a Sprite move, you need to set the MovementSpeed,
+ the direction (using
+ SetSpriteDirection(Vector),
+ SetSpriteDirectionToPoint(Point),
+ SetSpriteDirectionRadians(Double),
+ or SetSpriteDirectionDegrees(Double)), and the
+ AutomaticallyMoves property.
+ The speed is calculated in pixels per amount of time. A higher number is faster than a lower number.
+ |
![]() | payload |
+ A Sprite can hold a payload. Use this to store extra information about the various Sprites. Health, Armor,
+ Shoot time, etc. But, to store information in the payload, you need to make a new class of SpritePayload. The syntax
+ for doing so is:
+ public class TankPayload : SpritePayload { public int Armor; public int Speed; } |
SpriteControllerSpriteCount Property |
+ Namespace: + SpriteLibrary
SpriteUnhideSprite Method |
+ Namespace: + SpriteLibrary
public void UnhideSprite()
SpriteEventArgsTargetSprite Field |
+ Namespace: + SpriteLibrary
SpriteCannotMoveOutsideBox Field |
+ Namespace: + SpriteLibrary
SpriteMouseLeave Event |
+ Namespace: + SpriteLibrary
SpriteControllerReturnPictureBoxAdjustedWidth Method |
+ Namespace: + SpriteLibrary
public int ReturnPictureBoxAdjustedWidth( + int Width +)
SpritePutPictureBoxLocation Method |
+ Namespace: + SpriteLibrary
public void PutPictureBoxLocation( + Point NewLocationOnPictureBox +)
SpriteSetSize Method |
+ Namespace: + SpriteLibrary
public void SetSize( + Size NewSize +)
SpriteSpriteOriginName Property |
+ Namespace: + SpriteLibrary
SpriteControllerOriginalImage Property |
+ Namespace: + SpriteLibrary
SpriteControllerIsKeyPressed Method (Keys) |
+ Namespace: + SpriteLibrary
public bool IsKeyPressed( + Keys k +)
SpriteControllerSpriteToFront Method |
+ Namespace: + SpriteLibrary
public void SpriteToFront( + Sprite What +)
SpriteEventArgs Fields |
The SpriteEventArgs type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Cancel |
+ Used primarily in the CheckBeforeMove event. If you set cancel to true, then the move fails.
+ You can use this to keep a Sprite from going places where it ought not to go.
+ |
![]() | CollisionMethod |
+ The CollisionMethod used in the event. Currently, only rectangle collisions are used
+ |
![]() | NewLocation |
+ For the CheckBeforeMove event, newlocation will be the location the sprite is trying
+ to move to. You can adjust the point (move it left, right, up, down) and it will affect
+ the placement of the sprite.
+ |
![]() | TargetSprite |
+ If another Sprite is involved in the event (Collision), than that Sprite is included here.
+ It will be null if no other Sprite is involved.
+ |
SpriteSpriteChangesAnimationFrames Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteChangesAnimationFrames
SpriteChangeFrameAnimationSpeed Method |
+ Namespace: + SpriteLibrary
public void ChangeFrameAnimationSpeed( + int WhichAnimation, + int WhichFrame, + int newSpeed +)
SpriteGetSpriteRadans Method |
+ Namespace: + SpriteLibrary
public double GetSpriteRadans()
Sprite Constructor |
+ + | Name | Description |
---|---|---|
![]() | Sprite(Sprite, Boolean) |
+ Create a Sprite that is based off of the specified sprite. Clone the Sprite except that
+ we set SpriteName = "" and OrigSpriteName = the OldSprite.SpriteName. That way we know that
+ the sprite was duplicated from the original, and we can still distinguish the original from
+ the duplicate.
+ |
![]() | Sprite(SpriteController, Image) |
+ Generate a new single-frame sprite from the specified image.
+ |
![]() | Sprite(SpriteController, Image, Size) |
+ Generate a new sprite. It takes the image and the width and height. If there are multiple images of that width
+ and height in the image, an animation is created.
+ |
![]() | Sprite(SpriteController, Image, Int32, Int32) |
+ Generate a new sprite. It takes the image and the width and height. If there are multiple images of that width
+ and height in the image, an animation is created.
+ |
![]() | Sprite(SpriteController, Image, Int32, Int32, Int32) |
+ Generate a new sprite. It takes a width, height, and the duration in Milliseconds for each frame
+ |
![]() | Sprite(Point, SpriteController, Image, Int32, Int32, Int32, Int32) |
+ Create a Sprite from an animation image, specifying the number of consecutive
+ frames to grab.
+ |
SpriteAddAnimation Method (Point, Image, Int32, Int32, Int32, Int32) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Point Start, + Image SpriteImage, + int width, + int height, + int duration, + int Count +)
SpriteGetSize Property |
+ Namespace: + SpriteLibrary
SpriteControllerPlaceSpriteInFrontOf Method |
+ Namespace: + SpriteLibrary
public void PlaceSpriteInFrontOf( + Sprite WhatToSend, + Sprite ToGoInFrontOf +)
SpriteID Property |
+ Namespace: + SpriteLibrary
Sprite Constructor (Point, SpriteController, Image, Int32, Int32, Int32, Int32) |
+ Namespace: + SpriteLibrary
public Sprite( + Point Start, + SpriteController Controller, + Image SpriteImage, + int width, + int height, + int duration, + int Count +)
SpriteMouseLeaveTransparent Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler MouseLeaveTransparent
SpriteControllerSpritesAtImagePoint Method |
+ Namespace: + SpriteLibrary
public List<Sprite> SpritesAtImagePoint( + Point Location +)
SpriteOpacity Property |
+ Namespace: + SpriteLibrary
SpriteController Fields |
The SpriteController type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | OptimizeForLargeSpriteImages |
+ If your sprite images need substantial growing or shrinking when displayed, you can try setting this to "true"
+ to see if it makes it run any faster. What it does is to resize the image once, and keep a cached copy of that
+ image at that size. If you use the same sprite, but with different sizes, setting this to "True" may actually slow
+ down the game instead of speeding it up.
+ |
![]() | RandomNumberGenerator |
+ Since everything needs a random number generator, we make one that should be accessible throughout your program.
+ |
![]() ![]() | SpriteComparisonDelegate |
+ Allow the sprite sort-method to be overridden.
+ |
SpriteAdjustmentRatiowidth_ratio Field |
+ Namespace: + SpriteLibrary
SpriteChangeAnimationSpeed Method |
+ Namespace: + SpriteLibrary
public void ChangeAnimationSpeed( + int WhichAnimation, + int newSpeed +)
SpriteControllerReturnPictureBoxAdjustedPoint Method |
+ Namespace: + SpriteLibrary
public Point ReturnPictureBoxAdjustedPoint( + Point LocationOnImage +)
SpriteIsPaused Method |
+ Namespace: + SpriteLibrary
public bool IsPaused( + SpritePauseType What = SpritePauseType.PauseAll +)
SpriteSpriteIntersectsRectangle Method |
+ Namespace: + SpriteLibrary
public bool SpriteIntersectsRectangle( + Rectangle target +)
Sprite Constructor (SpriteController, Image) |
+ Namespace: + SpriteLibrary
public Sprite( + SpriteController Controller, + Image SpriteImage +)
SpriteSpriteCanMoveOnPictureBox Method |
+ Namespace: + SpriteLibrary
public bool SpriteCanMoveOnPictureBox( + Point newpoint +)
SpriteAdjustmentRatio Fields |
The SpriteAdjustmentRatio type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | height_ratio |
+ Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+ |
![]() | width_ratio |
+ Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+ |
SpriteAddAnimation Method (Image, Int32, Int32) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Image SpriteImage, + int width, + int height +)
SpriteControllerBackgroundImage Property |
+ Namespace: + SpriteLibrary
SpriteSpriteAtPictureBoxPoint Method |
+ Namespace: + SpriteLibrary
public bool SpriteAtPictureBoxPoint( + Point location, + SpriteCollisionMethod method = SpriteCollisionMethod.rectangle +)
SpriteAddAnimation Method (Image, Int32, Int32, Int32) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Image SpriteImage, + int width, + int height, + int duration +)
SpriteControllerNameSprite Method |
+ Namespace: + SpriteLibrary
public void NameSprite( + Sprite What, + string Name +)
SpriteAdjustmentRatioheight_ratio Field |
+ Namespace: + SpriteLibrary
Sprite Methods |
The Sprite type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | AddAnimation(Image) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Size) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Image, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Int32) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand.
+ |
![]() | AddAnimation(Image, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Int32, Boolean, Boolean) |
+ Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand using the MirrorHorizontally or MirrorVertically booleans.
+ |
![]() | AddAnimation(Image, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AddAnimation(Point, Image, Int32, Int32, Int32, Int32) |
+ Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+ |
![]() | AnimateJustAFewTimes |
+ Start a new animation. It will complete the animation the number of times you specify.
+ For example, if your sprite is walking, and one animation is one step, specifying 4 here
+ will result in your sprite taking 4 steps and then the animation stops. You will want
+ to make sure you are checking for when the animation stops, using the SpriteAnimationComplete event,
+ checking the Sprite.AnimationDone flag.
+ |
![]() | AnimateOnce |
+ Start a new animation, but do it just once. You can use AnimateJustAFewTimes(1) to the same effect.
+ Or, you can use AnimateJustAFewTimes with a different number. The SpriteAnimationComplete event will
+ fire off when the animation completes. The variable, Sprite.AnimationDone will be true once the
+ animation finishes animating.
+ |
![]() | CancelMoveTo |
+ Cancel a MoveTo command. The sprite will stop moving, and all the waypoints will be removed.
+ |
![]() | ChangeAnimation |
+ Start a new animation index from scratch
+ |
![]() | ChangeAnimationSpeed |
+ Change the animation speed of a particular animation. This looks at the first frame
+ and compares that frame to the speed specified. It adjusts all the animations by the
+ same percentage.
+ |
![]() | ChangeFrameAnimationSpeed |
+ Change the animation speed of a specific frame. Beware. This affects every sprite using this frame
+ |
![]() | CheckSpriteHitsSprite |
+ Check to see if two sprites hit each-other. The sprite collision methods are
+ not all programmed in.
+ |
![]() | ConvertDegreesToRadians |
+ Convert a number from degrees to radians.
+ |
![]() | ConvertRadiansToDegrees |
+ Convert a number from radians to degrees.
+ |
![]() | Destroy |
+ Tell the sprite to kill itself. It will erase itself and then
+ be removed from the spritelist. Then it will be gone forever.
+ |
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetAnimationSpeed |
+ Return the animation speed of this particualar animation of the sprite.
+ |
![]() | GetFrameAnimationSpeed |
+ Get the animation speed of a single frame.
+ |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetImage |
+ return the current image frame. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
![]() | GetImage(Int32, Int32) |
+ return the frame for the given index. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
![]() | GetSpriteBaseImageCenter |
+ Return the centerpoint of the sprite, as found on the background image
+ |
![]() | GetSpriteDegrees |
+ Get the direction that the sprite is traveling in in degrees. You may want to
+ use Math.Round on the results. The value returned is usually just a tiny bit off
+ from what you set it with. For example, if you set the sprite movement direction
+ to be 270 degrees (down), this function may return it as 269.999992. Rounding the
+ number will give it back to you at probably the same direction you set it as.
+ |
![]() | GetSpritePictureboxCenter |
+ Return the centerpoint of the sprite, as found on the picturebox
+ |
![]() | GetSpriteRadans |
+ Returns the direction the sprite is currently traveling, using Radians.
+ |
![]() | GetSpriteVector |
+ Return the current vector that the sprite is moving along
+ |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | HideSprite |
+ Remove the sprite from the field. This does not destroy the sprite. It simply removes it from action.
+ Use UnhideSprite to show it again.
+ |
![]() | IsPaused |
+ Ask if the sprite is paused using the specified sprite type (default is PauseAll)
+ |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | MoveTo(ListPoint) |
+ Tell the sprite to move towards each point in turn. The sprite will move in a straight line until the first point.
+ From there it moves to the next point, until it has reached the last point. Every time it reaches a point, the
+ SpriteArrivedAtWaypoint event is triggered. When it reaches the final point in the list, the SpriteArrivedAtEndPoint
+ event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has
+ arrived, it is set to true.
+ |
![]() | MoveTo(Point) |
+ Tell the Sprite to move towards a destination. You need to give the sprite a MovementSpeed
+ and tell the sprite that it can automatically move. But the sprite will begin a journey towards
+ that point at the MovementSpeed you have set. When it gets to the point, the SpriteArrivedAtEndPoint event
+ will fire off. Also, the SpriteReachedEnd bool will be true.
+ |
![]() | MoveTo(Sprite) |
+ Move to where the destination sprite currently is at. This is a dumb move. It does not take into
+ consideration the movement direction of the destination sprite. So the moving sprite does need to be
+ moving a bit faster than the sprite you are trying to hit for it to do so.
+ |
![]() | Pause |
+ Pause the sprite. We can pause just the animation (and still let it move), pause movement (and let it animate), or pause everything.
+ |
![]() | PutBaseImageLocation(Point) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
![]() | PutBaseImageLocation(Double, Double) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
![]() | PutPictureBoxLocation |
+ Put the Sprite at a specified location, using the dimentions of the PictureBox.
+ You want to use this if you got your X/Y position from a mouse-click. Otherwise,
+ this is the harder way to track things, particularly if your window can resize. Use
+ PutBaseImageLocation instead.
+ |
![]() | RecalcPictureBoxLocation |
+ Done when the box resizes. We need to recompute the picturebox location. The resize function
+ automatically calls this. You should never need to do so.
+ |
![]() | ReplaceImage |
+ Replace a sprite image. It will replace the current frame unless you specify both an animation
+ and the frame within the animation you wish to replace. Warning: This replaces the image_frame
+ for every sprite that uses that is based off the same image.
+ |
![]() | ReturnAdjustmentRatio |
+ Taking into consideration how the sprite is stretched or shrunk, it
+ returns a SpriteAdjustmentRatio that can be used to work with the sprite
+ itself.
+ |
![]() | SendToBack |
+ Make the sprite go behind all other sprites
+ |
![]() | SendToFront |
+ Make the sprite show up in front of all other sprites.
+ |
![]() | SetName |
+ Give this sprite a name. This way we can make a duplicate of it by specifying the name
+ |
![]() | SetSize |
+ Resize the sprite using the base image coordinates. The width and height specified
+ are relative to the size of the background image, not the picturebox.
+ |
![]() | SetSpriteDirection |
+ Set the sprite direction using a vector. The vector may contain
+ a speed as well as the movement delta (amount of x shift, and amount
+ of y shift.) If so, this function may also affect the movement speed
+ Most people prefer to use SetSpriteDirectionDegrees instead of using
+ vectors.
+ |
![]() | SetSpriteDirectionDegrees |
+ Given a "degree" (from 0 to 360, set the direction
+ that the sprite moves automatically. 0 is right, 90 is up, 180 is left
+ and 270 is down.
+ |
![]() | SetSpriteDirectionRadians |
+ Set the sprite direction using Radians. Most people do not want to use this.
+ Use SetSpriteDirectionDegrees instead unless you like math and know what you
+ are doing with Radians.
+ |
![]() | SetSpriteDirectionToPoint |
+ Sets the Sprite Moving towards a given point. You are responsible to do something with it once it gets there.
+ If you want it to automatically stop upon reaching it, use MoveTo instead. Actually, the MoveTo function works
+ a lot better than this one. Because of integer rounding and a few other things, this function is a little
+ bit imprecise. If you send it towards a point, it will go in that general direction. The MoveTo function
+ will perpetually recalculate its way to the destination point and actually reach that point. SetSpriteDirectionToPoint
+ will sort-of head in the direction of the point. But MoveTo will go to that point.
+ |
![]() | SpriteAdjustedPoint |
+ Because sprites are scaled (shrunk or stretched), this function finds the point
+ within the sprite that is specified by the location. this function is used by
+ a number of internal processes, but may be useful to you. But probably not.
+ |
![]() | SpriteAtImagePoint |
+ Check to see if the sprite exists at the point specified. The point given is
+ in coordinates used by the image (not the PictureBox, use SpriteAtPictureBox for that)
+ |
![]() | SpriteAtPictureBoxPoint |
+ Return true or false, asking if the specifiec sprite is at the point on the picturebox.
+ You can use this with a mouse-click to see if you are clicking on a sprite. Use the
+ SpriteCollisionMethod "transparent" to see if you have clicked on an actual pixel of the
+ sprite instead of just within the sprite rectangle.
+ |
![]() | SpriteCanMoveOnImage |
+ Return true if the sprite can go to this point and still be on the drawing-board.
+ |
![]() | SpriteCanMoveOnPictureBox |
+ Return true if the sprite can go to this point and still be on the drawing-board.
+ |
![]() | SpriteIntersectsRectangle |
+ Check to see if the specified rectangle overlaps with the sprite.
+ |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | UnhideSprite |
+ Make the sprite reappear. If you have not positioned it yet, it will show up at the top corner. It is best to only
+ use this when you have hidden it using HideSprite
+ |
![]() | UnPause |
+ unpause the sprite.
+ |
SpriteSpriteHitsSprite Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteHitsSprite
SpriteMouseEnterTransparent Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler MouseEnterTransparent
SpriteEventArgsCancel Field |
+ Namespace: + SpriteLibrary
SpritePutBaseImageLocation Method |
+ + | Name | Description |
---|---|---|
![]() | PutBaseImageLocation(Point) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
![]() | PutBaseImageLocation(Double, Double) |
+ Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+ |
SpriteCancelMoveTo Method |
+ Namespace: + SpriteLibrary
public void CancelMoveTo()
SpriteSpriteReachedEndPoint Property |
+ Namespace: + SpriteLibrary
SpriteControllerDuplicateSprite Method |
+ + | Name | Description |
---|---|---|
![]() ![]() | DuplicateSprite(String) |
+ Find a sprite that has been named with the specified name. Then duplicate that sprite
+ |
![]() | DuplicateSprite(Sprite) |
+ Make a duplicate of the specified sprite. The duplicate does not yet have a location.
+ |
SpriteSetSpriteDirection Method |
+ Namespace: + SpriteLibrary
public void SetSpriteDirection( + Vector newVector +)
SpriteControllerRegisterKeyDownFunction Method |
+ Namespace: + SpriteLibrary
public void RegisterKeyDownFunction( + SpriteKeyEventHandler Func +)
SpriteGetVisibleSize Property |
+ Namespace: + SpriteLibrary
SpriteGetImage Method |
+ + | Name | Description |
---|---|---|
![]() | GetImage |
+ return the current image frame. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
![]() | GetImage(Int32, Int32) |
+ return the frame for the given index. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+ |
SpriteControllerRegisterKeyUpFunction Method |
+ Namespace: + SpriteLibrary
public void RegisterKeyUpFunction( + SpriteKeyEventHandler Func +)
SpriteControllerSpriteForwards Method |
+ Namespace: + SpriteLibrary
public void SpriteForwards( + Sprite What +)
SpriteCollisionMethod Enumeration |
+ Namespace: + SpriteLibrary
public enum SpriteCollisionMethod
+ + | Member name | Value | Description |
---|---|---|---|
rectangle | 0 | + Checks if the two rectangles that contain the sprites overlap. Each rectangle is the starting location of the sprite + (top left) with the sprite width, and height marking the other sides of the rectangle. + | |
circle | 1 | + Draws a circle (ellipse) inside the sprite rectangles and see if those ellipses overlap + | |
transparency | 2 | + Check to see if nontransparent portions of a sprite collide. Not working. + |
SpriteControllerRandomNumberGenerator Field |
+ Namespace: + SpriteLibrary
SpriteRecalcPictureBoxLocation Method |
+ Namespace: + SpriteLibrary
public void RecalcPictureBoxLocation()
SpriteControllerDoTick Event |
+ Namespace: + SpriteLibrary
public partial class ShootingFieldForm : Form +{ + public ShootingFieldForm() + { + InitializeComponent(); + MainDrawingArea.BackgroundImage = Properties.Resources.Background; + MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch; + MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress); + } + + private void CheckForKeyPress(object sender, EventArgs e) + { + bool left = false; + bool right = false; + bool space = false; + bool didsomething = false; + TimeSpan duration = DateTime.Now - LastMovement; + if (duration.TotalMilliseconds < 100) + return; + LastMovement = DateTime.Now; + if (MySpriteController.IsKeyPressed(Keys.A) || MySpriteController.IsKeyPressed(Keys.Left)) + { + left = true; + } + if (MySpriteController.IsKeyPressed(Keys.D)||MySpriteController.IsKeyPressed(Keys.Right)) + { + right = true; + } + if (left && right) return; //do nothing if we conflict + if (left) + { + if (LastDirection != MyDir.left) + { + Spaceship.SetSpriteDirectionDegrees(180); + //We want to only change animation once. Every time we change + //the animation, it starts at the first frame again. + Spaceship.ChangeAnimation(0); + LastDirection = MyDir.left; + } + didsomething = true; + Spaceship.MovementSpeed = 15; + Spaceship.AutomaticallyMoves = true; + } + if (right) + { + if (LastDirection != MyDir.right) + { + Spaceship.SetSpriteDirectionDegrees(0); + Spaceship.ChangeAnimation(0); + LastDirection = MyDir.right; + } + didsomething = true; + Spaceship.AutomaticallyMoves = true; + Spaceship.MovementSpeed = 15; + } + if(!didsomething) + { + LastDirection = MyDir.stopped; + //No keys pressed. Stop moving + Spaceship.MovementSpeed = 0; + } + }
Sprite Constructor (Sprite, Boolean) |
+ Namespace: + SpriteLibrary
public Sprite( + Sprite OldSprite, + bool RetainName = false +)
SpriteDestroy Method |
+ Namespace: + SpriteLibrary
public void Destroy()
SpriteControllerKeysPressed Method |
+ Namespace: + SpriteLibrary
public List<Keys> KeysPressed()
Sprite Properties |
The Sprite type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | AnimationCount |
+ The number of animations this sprite has
+ |
![]() | AnimationDone |
+ Report whether or not the animation has been completed. When you tell a Sprite to AnimateOnce,
+ this will report "false" until the animation sequence has been finished. At that time, the value
+ will be "True." The tricky bit is that this is a boolean. If you have not told a sprite to
+ animate once, it will always return "false." If a sprite is paused, this returns "false." The only
+ time this returns "true" is when you tell a sprite to animate once, or animate a few times, and those
+ times have completed. At that time, this will report "True". If you have a sprite with only one frame,
+ it may not look like it is "animating", but it is. It is simply animating that one frame over and over.
+ So, AnimationDone reports false, unless you have told it to animate_once.
+ |
![]() | AnimationIndex |
+ Get or set the animation nimber. It is best to change the animation using ChangeAnimation.
+ It is safer.
+ |
![]() | AutomaticallyMoves |
+ Determine if the sprite automatically moves (you need to give it a direction [using one of the
+ SetSpriteDirection functions] and speed [MovementSpeed = X] also)
+ |
![]() | BaseImageLocation |
+ The sprite location as found on the base image. This is usually the easiest location to use.
+ |
![]() | Destroying |
+ If the Sprite is in the middle of being Destroyed, this is set to true. When a Sprite is
+ Destroyed, it needs to erase itself and do some house-cleaning before it actually vanishes.
+ During this time, you may not want to use it. It is always a good thing to verify a Sprite
+ is not in the middle of being destroyed before you do something important with it. To Destroy
+ a Sprite, use the Sprite.Destroy() function.
+ |
![]() | FrameIndex |
+ This is the frame of the current animation sequence. You can use this if you need to figure out what frame index
+ to resume something at, or something like that.
+ |
![]() | GetSize |
+ Return the size of the sprite in reference to the image on which it is drawn. To get the
+ size of the Sprite in relation to the PictureBox, use GetVisibleSize
+ |
![]() | GetVisibleSize |
+ Return the relative size of the Sprite in relation to the PictureBox. If the box has been
+ stretched or shrunk, that affects the visible size of the sprite.
+ |
![]() | HasBeenDrawn |
+ Report whether or not this Sprite has been drawn. If it has, then it needs to be erased at
+ some point in time.
+ |
![]() | ID |
+ The Sprite ID as specified by the sprite controller.
+ |
![]() | MovingToPoint |
+ Tells us if we are in the process of doing a MoveTo operation. This boolean should be the
+ opposite of SpriteReachedEndpoint, but that boolean is poorly named. This is usually the easier
+ one to use.
+ |
![]() | Opacity |
+ Set the opacity of the sprite. The value should be between 0 and 1. 1 is solid, 0 is transparent.
+ Sometimes you want to drag a sprite around the map, or show a sprite that "could be there." Setting
+ the sprite opacity is usually how you do that. One warning, however. The opacity value takes effect the
+ next time it is drawn. If the sprite is animating rapidly, it will take effect nearly emmediately. If
+ it is not animating, not moving, or just sitting there, then it may not take effect for quite some time.
+ |
![]() | PictureBoxLocation |
+ The sprite location as found on the picture-box that this sprite is associated with. Used when dealing with mouse-clicks
+ |
![]() | Rotation |
+ Change the rotation of the sprite, using degrees. 0 degrees is to the right. 90 is up.
+ 180 left, 270 down. But, if your sprite was drawn facing up, then rotating it 90 degrees
+ will have it pointing left. The angle goes counter-clockwise. The image will be scaled
+ such that it continues to fit within the rectangle that it was originally in. This results
+ in a little bit of shrinking at times, but you should rarely notice that.
+ |
![]() | SpriteName |
+ The name of the sprite. Use SetSpriteName(Name) to change this name. Most Named sprites
+ are used to define what a sprite is. Once you have created a named sprite, you usually use
+ DuplicateSprite(String) to clone the sprite for use. The basic rule of thumb is
+ to load your sprites from images once, and name the initial sprites. Then, when you go to use
+ those sprites, get duplicates of them. The reason for this is because it takes more processing time to initially
+ create the sprites than it takes to duplicate them.
+ |
![]() | SpriteOriginName |
+ Return the name of the sprite that this was duplicated from. A duplicated sprite will have
+ no name, but will have a SpriteOriginName.
+ |
![]() | SpriteReachedEndPoint |
+ This is true unless we are using MoveTo(point) or MoveTo(list of points) to tell the sprite to move
+ from one place to the next. This boolean tells us if it has finished or not.
+ |
![]() | VisibleHeight |
+ The visible Height as seen in the PictureBox. It may be stretched, or shrunk from the actual
+ image size.
+ |
![]() | VisibleWidth |
+ The visible width as seen in the PictureBox. The Sprite may be stretched or shrunk from the
+ actual image size.
+ |
![]() | Zvalue |
+ A number from 0 to 100. Default = 50. Higher numbers print on top of lower numbers. If you want a sprite to
+ always be drawn on top of other sprites, give it a number higher than 50. If you want a sprite to go under
+ other sprites, make its number lower than 50.
+ |
Sprite Events |
The Sprite type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | CheckBeforeMove |
+ This event fires off before a sprite is drawn. Use it if you have constraints. You
+ can change the location or cancel the move entirely.
+ |
![]() | Click |
+ This event happens when someone clicks on the sprite (on the rectangle in which the sprite is).
+ If you want the event to fire off only when someone clicks on the visible part of the sprite,
+ use ClickTransparent instead.
+ |
![]() | ClickTransparent |
+ This event happens when someone clicks on the sprite (on the sprite image itself).
+ If the sprite is sometimes hidden, but you want the click to work even if it is not
+ visible at that instant, use Click instead.
+ |
![]() | MouseEnter |
+ When the mouse moves over the sprite. Use this for a menu, when you want the menu item to glow when the
+ mouse is over the menu item sprite.
+ |
![]() | MouseEnterTransparent |
+ When the mouse moves over a non-transparent portoin of the sprite. Use this for a menu, when you want the
+ menu item to glow when the mouse is over the menu item sprite.
+ |
![]() | MouseHover |
+ This event happens when the mouse moves over the sprite, and then pauses. We use the hover timing from the
+ parent form.
+ |
![]() | MouseHoverTransparent |
+ This event happens when the mouse moves over a non-transparent portion of the sprite, and then pauses.
+ We use the hover timing from the parent form.
+ |
![]() | MouseLeave |
+ When the mouse moves off the sprite. Use this for a menu, when you want the menu item to stop glowing when
+ the mouse moves away from the menu item sprite.
+ |
![]() | MouseLeaveTransparent |
+ When the mouse moves off the non-transparent portion of the sprite. Use this for a menu, when you want the
+ menu item to stop glowing when
+ the mouse moves away from the menu item sprite.
+ |
![]() | SpriteAnimationComplete |
+ Only used when you tell an animation to animate once. At the end of the animation,
+ this function fires off.
+ |
![]() | SpriteArrivedAtEndPoint |
+ An event for when you tell a Sprite to MoveTo(Point) a specific point, or, when you
+ tell the Sprite to MoveTo(list of points). When the Sprite has reached the final destination,
+ the Sprite fires off this event.
+ |
![]() | SpriteArrivedAtWaypoint |
+ When you tell a sprite to MoveTo(list of points), this fires off every time it gets to
+ one of the points. When it gets to the final point, only the SpriteAtEndPoint event fires off.
+ |
![]() | SpriteBeingDestroyed |
+ The Sprite has just been told to be destroyed. You might want to do some cleanup.
+ If you need to destroy some payload data, or tell something to cleanup after the sprite
+ this is where to do that.
+ |
![]() | SpriteChangesAnimationFrames |
+ When the frame of an animation changes. If you want to have something happen every time
+ the foot of your monster comes down, when the swing of your sword is at certain points, etc.
+ Check to see that the Animaton and FrameIndex are what you expect them to be.
+ |
![]() | SpriteExitsPictureBox |
+ This happens when the sprite has exited the picture box. Useful when you want to
+ keep sprites from traveling on forever after exiting.
+ |
![]() | SpriteHitsPictureBox |
+ This happens when the sprite hits the border of the picture-box.
+ Useful for when you want to have shots explode when they hit the side.
+ |
![]() | SpriteHitsSprite |
+ This happens when two sprites hit each-other. The SpriteEventArgs that is returned
+ contains the sprite that this sprite hits.
+ |
![]() | SpriteInitializes |
+ This event happens right after the sprite is created. Use this to immediately set a
+ sprite to animate once or something like that.
+ |
SpriteControllerIsKeyPressed Method |
+ Namespace: + SpriteLibrary
public bool IsKeyPressed()
SpriteControllerChangeTickInterval Method |
+ Namespace: + SpriteLibrary
public void ChangeTickInterval( + int newTickMilliseconds +)
SpriteSendToBack Method |
+ Namespace: + SpriteLibrary
public void SendToBack()
SpriteControllerSpritesInImageRectangle Method |
+ Namespace: + SpriteLibrary
public List<Sprite> SpritesInImageRectangle( + Rectangle Location +)
SpriteSpriteCanMoveOnImage Method |
+ Namespace: + SpriteLibrary
public bool SpriteCanMoveOnImage( + Point newpoint +)
SpriteMirrorHorizontally Field |
+ Namespace: + SpriteLibrary
SpriteControllerInvalidate Method (Rectangle, Boolean) |
+ Namespace: + SpriteLibrary
public void Invalidate( + Rectangle ImageRectangle, + bool QueueUpInvalidation = true +)
SpriteController Properties |
The SpriteController type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | BackgroundImage |
+ The Background Image on which the sprites are drawn. This image ends up having
+ sprite parts on it. The OriginalImage is the version that is clean. Use
+ ReplaceOriginalImage to replace the background Image.
+ |
![]() | OriginalImage |
+ The Image from which the background is taken when we erase sprites. The BackgroundImage
+ is the image that contains images of the sprites as well as the background image. Use
+ ReplaceOriginalImage to replace this and the BackgroundImage.
+ |
![]() | SpriteCount |
+ The count of all the sprites the controller knows about. This includes named
+ sprites, which may not be visible.
+ |
SpriteControllerSpritesBasedOffAnything Method |
+ Namespace: + SpriteLibrary
SpriteVisibleWidth Property |
+ Namespace: + SpriteLibrary
SpriteGetAnimationSpeed Method |
+ Namespace: + SpriteLibrary
public int GetAnimationSpeed( + int WhichAnimation +)
SpriteController Constructor (PictureBox, EventHandler) |
+ Namespace: + SpriteLibrary
public SpriteController( + PictureBox Area, + EventHandler TimerTickMethod +)
public partial class ShootingFieldForm : Form +{ + public ShootingFieldForm() + { + InitializeComponent(); + MainDrawingArea.BackgroundImage = Properties.Resources.Background; + MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch; + MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress); + } + + private void CheckForKeyPress(object sender, EventArgs e) + { + //Do stuff here + } +}
SpriteControllerPause Method |
+ Namespace: + SpriteLibrary
public void Pause( + SpritePauseType What = SpritePauseType.PauseAll +)
SpriteSetSpriteDirectionToPoint Method |
+ Namespace: + SpriteLibrary
public void SetSpriteDirectionToPoint( + Point ImagePointDestination +)
SpriteControllerSpriteBackwards Method |
+ Namespace: + SpriteLibrary
public void SpriteBackwards( + Sprite What +)
SpriteGetSpriteDegrees Method |
+ Namespace: + SpriteLibrary
public double GetSpriteDegrees()
SpriteMouseHoverTransparent Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler MouseHoverTransparent
SpriteMouseHover Event |
+ Namespace: + SpriteLibrary
SpriteControllerCountSpritesBasedOff Method |
+ Namespace: + SpriteLibrary
public int CountSpritesBasedOff( + string Name +)
SpritePause Method |
+ Namespace: + SpriteLibrary
public void Pause( + SpritePauseType What = SpritePauseType.PauseAll +)
SpriteController Constructor (PictureBox) |
+ Namespace: + SpriteLibrary
public SpriteController( + PictureBox Area +)
public partial class ShootingFieldForm : Form +{ + public ShootingFieldForm() + { + InitializeComponent(); + MainDrawingArea.BackgroundImage = Properties.Resources.Background; + MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch; + MySpriteController = new SpriteController(MainDrawingArea); + } +}
SpriteControllerSoundIsFinished Method |
+ Namespace: + SpriteLibrary
public bool SoundIsFinished( + string Name +)
SpriteEventArgsNewLocation Field |
+ Namespace: + SpriteLibrary
SpriteControllerSpritesBasedOff Method |
+ Namespace: + SpriteLibrary
public List<Sprite> SpritesBasedOff( + string SpriteName +)
SpriteSpriteArrivedAtEndPoint Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler SpriteArrivedAtEndPoint
SpriteGetFrameAnimationSpeed Method |
+ Namespace: + SpriteLibrary
public int GetFrameAnimationSpeed( + int WhichAnimation, + int WhichFrame +)
SpriteAddAnimation Method (Image) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + Image SpriteImage +)
SpriteHideSprite Method |
+ Namespace: + SpriteLibrary
public void HideSprite()
SpriteControllerReturnPointAdjustedForImage Method |
+ Namespace: + SpriteLibrary
public Point ReturnPointAdjustedForImage( + Point LocationOnPicturebox +)
SpriteSpriteName Property |
+ Namespace: + SpriteLibrary
SpriteControllerSpriteFromName Method |
+ Namespace: + SpriteLibrary
public Sprite SpriteFromName( + string Name +)
SpriteMovementSpeed Field |
+ Namespace: + SpriteLibrary
SpriteGetSpriteVector Method |
+ Namespace: + SpriteLibrary
SpriteControllerReplaceOriginalImage Method (Image) |
void ReplaceBackground(Image NewBackground) +{ + if (MyController == null) return; + if (NewBackground == null) return; + + Image OneImage = new Bitmap(NewBackground); + MyController.ReplaceOriginalImage(OneImage); + + Image TwoImage = new Bitmap(NewBackground); + pb_map.BackgroundImage = TwoImage; + pb_map.Invalidate(); +}
+ Namespace: + SpriteLibrary
public void ReplaceOriginalImage( + Image tImage +)
SpriteAdjustmentRatio Structure |
+ Namespace: + SpriteLibrary
public struct SpriteAdjustmentRatio
The SpriteAdjustmentRatio type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType.) |
![]() | GetHashCode | Returns the hash code for this instance. (Inherited from ValueType.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType.) |
+ + | Name | Description |
---|---|---|
![]() | height_ratio |
+ Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+ |
![]() | width_ratio |
+ Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+ |
SpriteAddAnimation Method (Int32, Int32) |
+ Namespace: + SpriteLibrary
public void AddAnimation( + int AnimationToCopy, + int RotationDegrees +)
SpriteSetSpriteDirectionRadians Method |
+ Namespace: + SpriteLibrary
public void SetSpriteDirectionRadians( + double AngleInRadians +)
Sprite Constructor (SpriteController, Image, Size) |
+ Namespace: + SpriteLibrary
public Sprite( + SpriteController Controller, + Image SpriteImage, + Size SpriteSize +)
SpriteMoveTo Method (Point) |
+ Namespace: + SpriteLibrary
public void MoveTo( + Point Destination +)
SpriteSendToFront Method |
+ Namespace: + SpriteLibrary
public void SendToFront()
SpriteControllerDuplicateSprite Method (Sprite) |
+ Namespace: + SpriteLibrary
public Sprite DuplicateSprite( + Sprite What +)
SpriteGetSpriteBaseImageCenter Method |
+ Namespace: + SpriteLibrary
public Point GetSpriteBaseImageCenter()
SpriteGetSpritePictureboxCenter Method |
+ Namespace: + SpriteLibrary
public Point GetSpritePictureboxCenter()
SpritePauseType Enumeration |
+ Namespace: + SpriteLibrary
public enum SpritePauseType
+ + | Member name | Value | Description |
---|---|---|---|
PauseAnimation | 0 | + Pause the animating. Animation resumes from the current frame when we unpause. A paused animation will continue + to display the same image frame until it is unpaused. + | |
PauseMovement | 1 | + Pause any automatic movement. Movement resumes where it was left off if you unpause. The sprite will + just sit there until unpaused. + | |
PauseEvents | 2 | + Pause events. Sprite collisions, movement checks, etc are stopped until the unpause. + | |
PauseAll | 3 | + All pausable things are paused. PauseAnimation, PauseMovement, and PauseEvents. + |
SpriteAnimationDone Property |
+ Namespace: + SpriteLibrary
SpriteControllerAddSprite Method |
+ Namespace: + SpriteLibrary
public void AddSprite( + Sprite SpriteToAdd +)
SpriteHasBeenDrawn Property |
+ Namespace: + SpriteLibrary
SpriteCheckBeforeMove Event |
+ Namespace: + SpriteLibrary
public event SpriteSpriteEventHandler CheckBeforeMove
SpriteEventArgs Class |
+ Namespace: + SpriteLibrary
public class SpriteEventArgs : EventArgs
The SpriteEventArgs type exposes the following members.
+ + | Name | Description |
---|---|---|
![]() | SpriteEventArgs | Initializes a new instance of the SpriteEventArgs class |
+ + | Name | Description |
---|---|---|
![]() | Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
+ + | Name | Description |
---|---|---|
![]() | Cancel |
+ Used primarily in the CheckBeforeMove event. If you set cancel to true, then the move fails.
+ You can use this to keep a Sprite from going places where it ought not to go.
+ |
![]() | CollisionMethod |
+ The CollisionMethod used in the event. Currently, only rectangle collisions are used
+ |
![]() | NewLocation |
+ For the CheckBeforeMove event, newlocation will be the location the sprite is trying
+ to move to. You can adjust the point (move it left, right, up, down) and it will affect
+ the placement of the sprite.
+ |
![]() | TargetSprite |
+ If another Sprite is involved in the event (Collision), than that Sprite is included here.
+ It will be null if no other Sprite is involved.
+ |
SpriteAnimationIndex Property |
+ Namespace: + SpriteLibrary
SpriteControllerSpriteComparisonDelegate Field |
+ Namespace: + SpriteLibrary
SpriteComparisonDelegate = delegate (Sprite first, Sprite second) { return first.Zvalue.CompareTo(second.Zvalue); };
SpriteAutomaticallyMoves Property |
+ Namespace: + SpriteLibrary
SpriteEventArgs Constructor |
+ Namespace: + SpriteLibrary
public SpriteEventArgs()
SpriteGetImage Method |
+ Namespace: + SpriteLibrary
public Image GetImage()
SpriteConvertDegreesToRadians Method |
+ Namespace: + SpriteLibrary
public double ConvertDegreesToRadians( + double Degrees +)
SpriteControllerInvalidate Method |
+ + | Name | Description |
---|---|---|
![]() | Invalidate(Boolean) |
+ Invalidate the entire image on which the sprites are drawn
+ |
![]() | Invalidate(Rectangle, Boolean) |
+ Invalidate a rectangle that is specified in image coordinates
+ |
SpriteAnimateOnce Method |
+ Namespace: + SpriteLibrary
public void AnimateOnce( + int WhichAnimation, + int AnimationFrameToEndOn = -1 +)
If you are not redirected automatically, follow this link to the default topic.
+ + diff --git a/SpriteLibrary/Doc/Help/scripts/branding-Website.js b/SpriteLibrary/Doc/Help/scripts/branding-Website.js new file mode 100644 index 0000000..06ab980 --- /dev/null +++ b/SpriteLibrary/Doc/Help/scripts/branding-Website.js @@ -0,0 +1,624 @@ +//=============================================================================================================== +// System : Sandcastle Help File Builder +// File : branding-Website.js +// Author : Eric Woodruff (Eric@EWoodruff.us) +// Updated : 03/04/2015 +// Note : Copyright 2014-2015, Eric Woodruff, All rights reserved +// Portions Copyright 2014 Sam Harwell, All rights reserved +// +// This file contains the methods necessary to implement the lightweight TOC and search functionality. +// +// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be +// distributed with the code. It can also be found at the project website: https://GitHub.com/EWSoftware/SHFB. This +// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, +// and source files. +// +// Date Who Comments +// ============================================================================================================== +// 05/04/2014 EFW Created the code based on a combination of the lightweight TOC code from Sam Harwell and +// the existing search code from SHFB. +//=============================================================================================================== + +// Width of the TOC +var tocWidth; + +// Search method (0 = To be determined, 1 = ASPX, 2 = PHP, anything else = client-side script +var searchMethod = 0; + +// Table of contents script + +// Initialize the TOC by restoring its width from the cookie if present +function InitializeToc() +{ + tocWidth = parseInt(GetCookie("TocWidth", "280")); + ResizeToc(); + $(window).resize(SetNavHeight) +} + +function SetNavHeight() +{ + $leftNav = $("#leftNav") + $topicContent = $("#TopicContent") + leftNavPadding = $leftNav.outerHeight() - $leftNav.height() + contentPadding = $topicContent.outerHeight() - $topicContent.height() + // want outer height of left navigation div to match outer height of content + leftNavHeight = $topicContent.outerHeight() - leftNavPadding + $leftNav.css("min-height", leftNavHeight + "px") +} + +// Increase the TOC width +function OnIncreaseToc() +{ + if(tocWidth < 1) + tocWidth = 280; + else + tocWidth += 100; + + if(tocWidth > 680) + tocWidth = 0; + + ResizeToc(); + SetCookie("TocWidth", tocWidth); +} + +// Reset the TOC to its default width +function OnResetToc() +{ + tocWidth = 0; + + ResizeToc(); + SetCookie("TocWidth", tocWidth); +} + +// Resize the TOC width +function ResizeToc() +{ + var toc = document.getElementById("leftNav"); + + if(toc) + { + // Set TOC width + toc.style.width = tocWidth + "px"; + + var leftNavPadding = 10; + + document.getElementById("TopicContent").style.marginLeft = (tocWidth + leftNavPadding) + "px"; + + // Position images + document.getElementById("TocResize").style.left = (tocWidth + leftNavPadding) + "px"; + + // Hide/show increase TOC width image + document.getElementById("ResizeImageIncrease").style.display = (tocWidth >= 680) ? "none" : ""; + + // Hide/show reset TOC width image + document.getElementById("ResizeImageReset").style.display = (tocWidth < 680) ? "none" : ""; + } + + SetNavHeight() +} + +// Toggle a TOC entry between its collapsed and expanded state +function Toggle(item) +{ + var isExpanded = $(item).hasClass("tocExpanded"); + + $(item).toggleClass("tocExpanded tocCollapsed"); + + if(isExpanded) + { + Collapse($(item).parent()); + } + else + { + var childrenLoaded = $(item).parent().attr("data-childrenloaded"); + + if(childrenLoaded) + { + Expand($(item).parent()); + } + else + { + var tocid = $(item).next().attr("tocid"); + + $.ajax({ + url: "../toc/" + tocid + ".xml", + async: true, + dataType: "xml", + success: function(data) + { + BuildChildren($(item).parent(), data); + } + }); + } + } +} + +// HTML encode a value for use on the page +function HtmlEncode(value) +{ + // Create an in-memory div, set it's inner text (which jQuery automatically encodes) then grab the encoded + // contents back out. The div never exists on the page. + return $('').text(value).html(); +} + +// Build the child entries of a TOC entry +function BuildChildren(tocDiv, data) +{ + var childLevel = +tocDiv.attr("data-toclevel") + 1; + var childTocLevel = childLevel >= 10 ? 10 : childLevel; + var elements = data.getElementsByTagName("HelpTOCNode"); + + var isRoot = true; + + if(data.getElementsByTagName("HelpTOC").length == 0) + { + // The first node is the root node of this group, don't show it again + isRoot = false; + } + + for(var i = elements.length - 1; i > 0 || (isRoot && i == 0); i--) + { + var childHRef, childId = elements[i].getAttribute("Url"); + + if(childId != null && childId.length > 5) + { + // The Url attribute has the form "html/{childId}.htm" + childHRef = childId.substring(5, childId.length); + childId = childId.substring(5, childId.lastIndexOf(".")); + } + else + { + // The Id attribute is in raw form. There is no URL (empty container node). In this case, we'll + // just ignore it and go nowhere. It's a rare case that isn't worth trying to get the first child. + // Instead, we'll just expand the node (see below). + childHRef = "#"; + childId = elements[i].getAttribute("Id"); + } + + var existingItem = null; + + tocDiv.nextAll().each(function() + { + if(!existingItem && $(this).children().last("a").attr("tocid") == childId) + { + existingItem = $(this); + } + }); + + if(existingItem != null) + { + // First move the children of the existing item + var existingChildLevel = +existingItem.attr("data-toclevel"); + var doneMoving = false; + var inserter = tocDiv; + + existingItem.nextAll().each(function() + { + if(!doneMoving && +$(this).attr("data-toclevel") > existingChildLevel) + { + inserter.after($(this)); + inserter = $(this); + $(this).attr("data-toclevel", +$(this).attr("data-toclevel") + childLevel - existingChildLevel); + + if($(this).hasClass("current")) + $(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel") + " current")); + else + $(this).attr("class", "toclevel" + (+$(this).attr("data-toclevel"))); + } + else + { + doneMoving = true; + } + }); + + // Now move the existing item itself + tocDiv.after(existingItem); + existingItem.attr("data-toclevel", childLevel); + existingItem.attr("class", "toclevel" + childLevel); + } + else + { + var hasChildren = elements[i].getAttribute("HasChildren"); + var childTitle = HtmlEncode(elements[i].getAttribute("Title")); + var expander = ""; + + if(hasChildren) + expander = ""; + + var text = "Omitted " + (matchingFileIndices.length - rankings.length) + " more results
"; + + return content; +} diff --git a/SpriteLibrary/Doc/Help/scripts/branding.js b/SpriteLibrary/Doc/Help/scripts/branding.js new file mode 100644 index 0000000..3e55541 --- /dev/null +++ b/SpriteLibrary/Doc/Help/scripts/branding.js @@ -0,0 +1,560 @@ +//=============================================================================================================== +// System : Sandcastle Help File Builder +// File : branding.js +// Author : Eric Woodruff (Eric@EWoodruff.us) +// Updated : 10/08/2015 +// Note : Copyright 2014-2015, Eric Woodruff, All rights reserved +// Portions Copyright 2010-2014 Microsoft, All rights reserved +// +// This file contains the methods necessary to implement the language filtering, collapsible section, and +// copy to clipboard options. +// +// This code is published under the Microsoft Public License (Ms-PL). A copy of the license should be +// distributed with the code and can be found at the project website: https://GitHub.com/EWSoftware/SHFB. This +// notice, the author's name, and all copyright notices must remain intact in all applications, documentation, +// and source files. +// +// Date Who Comments +// ============================================================================================================== +// 05/04/2014 EFW Created the code based on the MS Help Viewer script +//=============================================================================================================== + +// The IDs of all code snippet sets on the same page are stored so that we can keep them in synch when a tab is +// selected. +var allTabSetIds = new Array(); + +// The IDs of language-specific text (LST) spans are used as dictionary keys so that we can get access to the +// spans and update them when the user changes to a different language tab. The values of the dictionary +// objects are pipe separated language-specific attributes (lang1=value|lang2=value|lang3=value). The language +// ID can be specific (cs, vb, cpp, etc.) or may be a neutral entry (nu) which specifies text common to multiple +// languages. If a language is not present and there is no neutral entry, the span is hidden for all languages +// to which it does not apply. +var allLSTSetIds = new Object(); + +// Help 1 persistence support. This code must appear inline. +var isHelp1; + +var curLoc = document.location + "."; + +if(curLoc.indexOf("mk:@MSITStore") == 0) +{ + isHelp1 = true; + curLoc = "ms-its:" + curLoc.substring(14, curLoc.length - 1); + document.location.replace(curLoc); +} +else + if(curLoc.indexOf("ms-its:") == 0) + isHelp1 = true; + else + isHelp1 = false; + +// The OnLoad method +function OnLoad(defaultLanguage) +{ + var defLang; + + if(typeof (defaultLanguage) == "undefined" || defaultLanguage == null || defaultLanguage == "") + defLang = "vb"; + else + defLang = defaultLanguage; + + // In MS Help Viewer, the transform the topic is ran through can move the footer. Move it back where it + // belongs if necessary. + try + { + var footer = document.getElementById("pageFooter") + + if(footer) + { + var footerParent = document.body; + + if(footer.parentElement != footerParent) + { + footer.parentElement.removeChild(footer); + footerParent.appendChild(footer); + } + } + } + catch(e) + { + } + + var language = GetCookie("CodeSnippetContainerLanguage", defLang); + + // If LST exists on the page, set the LST to show the user selected programming language + UpdateLST(language); + + // If code snippet groups exist, set the current language for them + if(allTabSetIds.length > 0) + { + var i = 0; + + while(i < allTabSetIds.length) + { + var tabCount = 1; + + // The tab count may vary so find the last one in this set + while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null) + tabCount++; + + tabCount--; + + // If not grouped, skip it + if(tabCount > 1) + SetCurrentLanguage(allTabSetIds[i], language, tabCount); + + i++; + } + } + + InitializeToc(); +} + +// This is just a place holder. The website script implements this function to initialize it's in-page TOC pane +function InitializeToc() +{ +} + +// This function executes in the OnLoad event and ChangeTab action on code snippets. The function parameter +// is the user chosen programming language. This function iterates through the "allLSTSetIds" dictionary object +// to update the node value of the LST span tag per the user's chosen programming language. +function UpdateLST(language) +{ + for(var lstMember in allLSTSetIds) + { + var devLangSpan = document.getElementById(lstMember); + + if(devLangSpan != null) + { + // There may be a carriage return before the LST span in the content so the replace function below + // is used to trim the whitespace at the end of the previous node of the current LST node. + if(devLangSpan.previousSibling != null && devLangSpan.previousSibling.nodeValue != null) + devLangSpan.previousSibling.nodeValue = devLangSpan.previousSibling.nodeValue.replace(/\s+$/, ""); + + var langs = allLSTSetIds[lstMember].split("|"); + var k = 0; + var keyValue; + + while(k < langs.length) + { + keyValue = langs[k].split("="); + + if(keyValue[0] == language) + { + devLangSpan.innerHTML = keyValue[1]; + + // Help 1 and MS Help Viewer workaround. Add a space if the following text element starts + // with a space to prevent things running together. + if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null) + { + if (devLangSpan.parentNode.nextSibling.nodeValue != null && + !devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/)) + { + devLangSpan.innerHTML = keyValue[1] + " "; + } + } + break; + } + + k++; + } + + // If not found, default to the neutral language. If there is no neutral language entry, clear the + // content to hide it. + if(k >= langs.length) + { + if(language != "nu") + { + k = 0; + + while(k < langs.length) + { + keyValue = langs[k].split("="); + + if(keyValue[0] == "nu") + { + devLangSpan.innerHTML = keyValue[1]; + + // Help 1 and MS Help Viewer workaround. Add a space if the following text element + // starts with a space to prevent things running together. + if(devLangSpan.parentNode != null && devLangSpan.parentNode.nextSibling != null) + { + if(devLangSpan.parentNode.nextSibling.nodeValue != null && + !devLangSpan.parentNode.nextSibling.nodeValue.substring(0, 1).match(/[.,);:!/?]/)) + { + devLangSpan.innerHTML = keyValue[1] + " "; + } + } + break; + } + + k++; + } + } + + if(k >= langs.length) + devLangSpan.innerHTML = ""; + } + } + } +} + +// Get the specified cookie. If not found, return the specified default value. +function GetCookie(cookieName, defaultValue) +{ + if(isHelp1) + { + try + { + var globals = Help1Globals; + + var value = globals.Load(cookieName); + + if(value == null) + value = defaultValue; + + return value; + } + catch(e) + { + return defaultValue; + } + } + + var cookie = document.cookie.split("; "); + + for(var i = 0; i < cookie.length; i++) + { + var crumb = cookie[i].split("="); + + if(cookieName == crumb[0]) + return unescape(crumb[1]) + } + + return defaultValue; +} + +// Set the specified cookie to the specified value +function SetCookie(name, value) +{ + if(isHelp1) + { + try + { + var globals = Help1Globals; + + globals.Save(name, value); + } + catch(e) + { + } + + return; + } + + var today = new Date(); + + today.setTime(today.getTime()); + + // Set the expiration time to be 60 days from now (in milliseconds) + var expires_date = new Date(today.getTime() + (60 * 1000 * 60 * 60 * 24)); + + document.cookie = name + "=" + escape(value) + ";expires=" + expires_date.toGMTString() + ";path=/"; +} + +// Add a language-specific text ID +function AddLanguageSpecificTextSet(lstId) +{ + var keyValue = lstId.split("?") + + allLSTSetIds[keyValue[0]] = keyValue[1]; +} + +var clipboardHandler; + +// Add a language tab set ID +function AddLanguageTabSet(tabSetId) +{ + allTabSetIds.push(tabSetId); + + // Create the clipboard handler on first use + if(clipboardHandler == null && typeof (Clipboard) == "function") + { + clipboardHandler = new Clipboard('.copyCodeSnippet', + { + text: function (trigger) + { + // Get the code to copy to the clipboard from the active tab of the given tab set + var i = 1, tabSetId = trigger.id; + var pos = tabSetId.indexOf('_'); + + if(pos == -1) + return ""; + + tabSetId = tabSetId.substring(0, pos); + + do + { + contentId = tabSetId + "_code_Div" + i; + tabTemp = document.getElementById(contentId); + + if(tabTemp != null && tabTemp.style.display != "none") + break; + + i++; + + } while(tabTemp != null); + + if(tabTemp == null) + return ""; + + return document.getElementById(contentId).innerText; + } + }); + } +} + +// Switch the active tab for all of other code snippets +function ChangeTab(tabSetId, language, snippetIdx, snippetCount) +{ + SetCookie("CodeSnippetContainerLanguage", language); + + SetActiveTab(tabSetId, snippetIdx, snippetCount); + + // If LST exists on the page, set the LST to show the user selected programming language + UpdateLST(language); + + var i = 0; + + while(i < allTabSetIds.length) + { + // We just care about other snippets + if(allTabSetIds[i] != tabSetId) + { + // Other tab sets may not have the same number of tabs + var tabCount = 1; + + while(document.getElementById(allTabSetIds[i] + "_tab" + tabCount) != null) + tabCount++; + + tabCount--; + + // If not grouped, skip it + if(tabCount > 1) + SetCurrentLanguage(allTabSetIds[i], language, tabCount); + } + + i++; + } +} + +// Sets the current language in the specified tab set +function SetCurrentLanguage(tabSetId, language, tabCount) +{ + var tabIndex = 1; + + while(tabIndex <= tabCount) + { + var tabTemp = document.getElementById(tabSetId + "_tab" + tabIndex); + + if(tabTemp != null && tabTemp.innerHTML.indexOf("'" + language + "'") != -1) + break; + + tabIndex++; + } + + if(tabIndex > tabCount) + { + // Select the first non-disabled tab + tabIndex = 1; + + if(document.getElementById(tabSetId + "_tab1").className == "codeSnippetContainerTabPhantom") + { + tabIndex++; + + while(tabIndex <= tabCount) + { + var tab = document.getElementById(tabSetId + "_tab" + tabIndex); + + if(tab.className != "codeSnippetContainerTabPhantom") + { + tab.className = "codeSnippetContainerTabActive"; + document.getElementById(tabSetId + "_code_Div" + j).style.display = "block"; + break; + } + + tabIndex++; + } + } + } + + SetActiveTab(tabSetId, tabIndex, tabCount); +} + +// Set the active tab within a tab set +function SetActiveTab(tabSetId, tabIndex, tabCount) +{ + var i = 1; + + while(i <= tabCount) + { + var tabTemp = document.getElementById(tabSetId + "_tab" + i); + + if (tabTemp != null) + { + if(tabTemp.className == "codeSnippetContainerTabActive") + tabTemp.className = "codeSnippetContainerTab"; + else + if(tabTemp.className == "codeSnippetContainerTabPhantom") + tabTemp.style.display = "none"; + + var codeTemp = document.getElementById(tabSetId + "_code_Div" + i); + + if(codeTemp.style.display != "none") + codeTemp.style.display = "none"; + } + + i++; + } + + // Phantom tabs are shown or hidden as needed + if(document.getElementById(tabSetId + "_tab" + tabIndex).className != "codeSnippetContainerTabPhantom") + document.getElementById(tabSetId + "_tab" + tabIndex).className = "codeSnippetContainerTabActive"; + else + document.getElementById(tabSetId + "_tab" + tabIndex).style.display = "block"; + + document.getElementById(tabSetId + "_code_Div" + tabIndex).style.display = "block"; +} + +// Copy the code from the active tab of the given tab set to the clipboard +function CopyToClipboard(tabSetId) +{ + var tabTemp, contentId; + var i = 1; + + if(typeof (Clipboard) == "function") + return; + + do + { + contentId = tabSetId + "_code_Div" + i; + tabTemp = document.getElementById(contentId); + + if(tabTemp != null && tabTemp.style.display != "none") + break; + + i++; + + } while(tabTemp != null); + + if(tabTemp == null) + return; + + if(window.clipboardData) + { + try + { + window.clipboardData.setData("Text", document.getElementById(contentId).innerText); + } + catch(e) + { + alert("Permission denied. Enable copying to the clipboard."); + } + } + else if(window.netscape) + { + try + { + netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); + + var clip = Components.classes["@mozilla.org/widget/clipboard;1"].createInstance( + Components.interfaces.nsIClipboard); + + if(!clip) + return; + + var trans = Components.classes["@mozilla.org/widget/transferable;1"].createInstance( + Components.interfaces.nsITransferable); + + if(!trans) + return; + + trans.addDataFlavor("text/unicode"); + + var str = new Object(); + var len = new Object(); + var str = Components.classes["@mozilla.org/supports-string;1"].createInstance( + Components.interfaces.nsISupportsString); + + var copytext = document.getElementById(contentId).textContent; + + str.data = copytext; + trans.setTransferData("text/unicode", str, copytext.length * 2); + + var clipid = Components.interfaces.nsIClipboard; + + clip.setData(trans, null, clipid.kGlobalClipboard); + } + catch(e) + { + alert("Permission denied. Enter \"about:config\" in the address bar and double-click the \"signed.applets.codebase_principal_support\" setting to enable copying to the clipboard."); + } + } +} + +// Expand or collapse a section +function SectionExpandCollapse(togglePrefix) +{ + var image = document.getElementById(togglePrefix + "Toggle"); + var section = document.getElementById(togglePrefix + "Section"); + + if(image != null && section != null) + if(section.style.display == "") + { + image.src = image.src.replace("SectionExpanded.png", "SectionCollapsed.png"); + section.style.display = "none"; + } + else + { + image.src = image.src.replace("SectionCollapsed.png", "SectionExpanded.png"); + section.style.display = ""; + } +} + +// Expand or collapse a section when it has the focus and Enter is hit +function SectionExpandCollapse_CheckKey(togglePrefix, eventArgs) +{ + if(eventArgs.keyCode == 13) + SectionExpandCollapse(togglePrefix); +} + +// Help 1 persistence object. This requires a hidden input element on the page with a class of "userDataStyle" +// defined in the style sheet that implements the user data binary behavior: +// +var Help1Globals = +{ + UserDataCache: function() + { + var userData = document.getElementById("userDataCache"); + + return userData; + }, + + Load: function(key) + { + var userData = this.UserDataCache(); + + userData.load("userDataSettings"); + + var value = userData.getAttribute(key); + + return value; + }, + + Save: function(key, value) + { + var userData = this.UserDataCache(); + userData.setAttribute(key, value); + userData.save("userDataSettings"); + } +}; diff --git a/SpriteLibrary/Doc/Help/scripts/clipboard.min.js b/SpriteLibrary/Doc/Help/scripts/clipboard.min.js new file mode 100644 index 0000000..580433f --- /dev/null +++ b/SpriteLibrary/Doc/Help/scripts/clipboard.min.js @@ -0,0 +1,7 @@ +/*! + * clipboard.js v1.5.12 + * https://zenorocha.github.io/clipboard.js + * + * Licensed MIT © Zeno Rocha + */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;at |
$name
\n";
+ #print Dumper($invalue);
+ my $summary = $invalue->{summary};
+ $summary =~ s/^\s+|\s+$//g;
+ print "Summary: $summary
\n" if defined $invalue->{summary};
+ #if(defined $invalue->{returns})
+ #{
+ # if(UNIVERSAL::isa($invalue->{returns}, 'HASH'))
+ # {
+ # #print Dumper $invalue->{returns};
+ # }
+ # else
+ # {
+ # print "Returns: $invalue->{returns}
\n\n" if defined $invalue->{returns};
+ # }
+ #}
+ #if(defined $invalue->{param})
+ #{
+ # print "Parameters\n";
+ # print "
\n";
+ }
+
+# print "$inkey = \n";
+# print Dumper($invalue);G
+ }
+ }
+}
+print "\n";
diff --git a/SpriteLibrary/Doc/SpriteLibrary.shfbproj b/SpriteLibrary/Doc/SpriteLibrary.shfbproj
new file mode 100644
index 0000000..1d1f3b8
--- /dev/null
+++ b/SpriteLibrary/Doc/SpriteLibrary.shfbproj
@@ -0,0 +1,101 @@
+
+
Sprite.AnimationCount
+Summary: The number of animations this sprite has
+
Sprite.AnimationDone
+Summary: Report whether or not the animation has been completed. When you tell a Sprite to AnimateOnce,
+ this will report "false" until the animation sequence has been finished. At that time, the value
+ will be "True." The tricky bit is that this is a boolean. If you have not told a sprite to
+ animate once, it will always return "false." If a sprite is paused, this returns "false." The only
+ time this returns "true" is when you tell a sprite to animate once, or animate a few times, and those
+ times have completed. At that time, this will report "True". If you have a sprite with only one frame,
+ it may not look like it is "animating", but it is. It is simply animating that one frame over and over.
+ So, AnimationDone reports false, unless you have told it to animate_once.
+
Sprite.AnimationIndex
+Summary: Get or set the animation nimber. It is best to change the animation using ChangeAnimation.
+ It is safer.
+
Sprite.AutomaticallyMoves
+Summary: Determine if the sprite automatically moves (you need to give it a direction [using one of the
+ SetSpriteDirection functions] and speed [MovementSpeed = X] also)
+
Sprite.BaseImageLocation
+Summary: The sprite location as found on the base image. This is usually the easiest location to use.
+
Sprite.Destroying
+Summary: If the Sprite is in the middle of being Destroyed, this is set to true. When a Sprite is
+ Destroyed, it needs to erase itself and do some house-cleaning before it actually vanishes.
+ During this time, you may not want to use it. It is always a good thing to verify a Sprite
+ is not in the middle of being destroyed before you do something important with it. To Destroy
+ a Sprite, use the Sprite.Destroy() function.
+
Sprite.FrameIndex
+Summary: This is the frame of the current animation sequence.
+
Sprite.GetSize
+Summary: Return the size of the sprite in reference to the image on which it is drawn. To get the
+ size of the Sprite in relation to the PictureBox, use GetVisibleSize
+
Sprite.GetVisibleSize
+Summary: Return the relative size of the Sprite in relation to the PictureBox. If the box has been
+ stretched or shrunk, that affects the visible size of the sprite.
+
Sprite.HasBeenDrawn
+Summary: Report whether or not this Sprite has been drawn. If it has, then it needs to be erased at
+ some point in time.
+
Sprite.ID
+Summary: The Sprite ID as specified by the sprite controller.
+
Sprite.MovingToPoint
+Summary: Tells us if we are in the process of doing a MoveTo operation. This boolean should be the
+ opposite of SpriteReachedEndpoint, but that boolean is poorly named. This is usually the easier
+ one to use.
+
Sprite.Opacity
+Summary: Set the opacity of the sprite. The value should be between 0 and 1. 1 is solid, 0 is transparent.
+
Sprite.PictureBoxLocation
+Summary: The sprite location as found on the picture-box that this sprite is associated with. Used when dealing with mouse-clicks
+
Sprite.Rotation
+Summary: Change the rotation of the sprite, using degrees. 0 degrees is to the right. 90 is up.
+ 180 left, 270 down. But, if your sprite was drawn facing up, then rotating it 90 degrees
+ will have it pointing left. The angle goes counter-clockwise. The image will be scaled
+ such that it continues to fit within the rectangle that it was originally in. This results
+ in a little bit of shrinking at times, but you should rarely notice that.
+
Sprite.SpriteName
+Summary: The name of the sprite. Use SetSpriteName(Name) to change this name. Most Named sprites
+ are used to define what a sprite is. Once you have created a named sprite, you usually use
+ SpriteController.DuplicateSprite(Name) to clone the sprite for use.
+
Sprite.SpriteOriginName
+Summary: Return the name of the sprite that this was duplicated from. A duplicated sprite will have
+ no name, but will have a SpriteOriginName.
+
Sprite.SpriteReachedEndPoint
+Summary: This is true unless we are using MoveTo(point) or MoveTo(list of points) to tell the sprite to move
+ from one place to the next. This boolean tells us if it has finished or not.
+
Sprite.VisibleHeight
+Summary: The visible Height as seen in the PictureBox. It may be stretched, or shrunk from the actual
+ image size.
+
Sprite.VisibleWidth
+Summary: The visible width as seen in the PictureBox. The Sprite may be stretched or shrunk from the
+ actual image size.
+
Sprite.Zvalue
+Summary: A number from 0 to 100. Default = 50. Higher numbers print on top of lower numbers. If you want a sprite to
+ always be drawn on top of other sprites, give it a number higher than 50. If you want a sprite to go under
+ other sprites, make its number lower than 50.
+
SpriteController.BackgroundImage
+Summary: The Background Image on which the sprites are drawn. This image ends up having
+ sprite parts on it. The OriginalImage is the version that is clean. Use
+ ReplaceOriginalImage to replace the background Image.
+
SpriteController.OriginalImage
+Summary: The Image from which the background is taken when we erase sprites. The BackgroundImage
+ is the image that contains images of the sprites as well as the background image. Use
+ ReplaceOriginalImage to replace this and the BackgroundImage.
+
SpriteController.SpriteCount
+Summary: The count of all the sprites the controller knows about. This includes named
+ sprites, which may not be visible
+
Constructor: Animation.(SpriteLibrary.SmartImage,System.Drawing.Image,System.Int32,System.Int32,System.Int32)
+Summary: Create an image from an image that has a bunch of frames in the one image.
+ Start at (0,0) with the specified height and width. Pull out as many images as we can
+
Constructor: Animation.(System.Drawing.Point,SpriteLibrary.SmartImage,System.Drawing.Image,System.Int32,System.Int32,System.Int32,System.Int32)
+Summary: Create an image from an image that has a bunch of frames in the one image.
+ Start at the specified position (Start), and grab Count items (if we can find them)
+
Constructor: SmartImage.(SpriteLibrary.SpriteController,System.Drawing.Image,System.Int32,System.Int32,System.Int32)
+Summary: Make an animated image from an image that contains multiple frames
+
SmartImage.AnimationDone(System.Int32,System.Int32,System.Boolean)
+Summary: Check to see if the animation is in the last frame. Only works if animateonce is set to true
+
SmartImage.AnimationFrameCount(System.Int32)
+Summary: Return the number of frames that the specified animation has.
+
SmartImage.NeedsNewImage(System.Int32,System.Int32,System.TimeSpan)
+Summary: Return true if the specified animation and frame for that animation needs
+ to be changed due to the time passing.
+
Constructor: Sprite.(SpriteLibrary.Sprite,System.Boolean)
+Summary: Create a Sprite that is based off of the specified sprite. Clone the Sprite except that
+ we set SpriteName = "" and OrigSpriteName = the OldSprite.SpriteName. That way we know that
+ the sprite was duplicated from the original, and we can still distinguish the original from
+ the duplicate.
+
Constructor: Sprite.(SpriteLibrary.SpriteController,System.Drawing.Image,System.Int32,System.Int32)
+Summary: Generate a new sprite. It takes the image and the width and height. If there are multiple images of that width and height in the image, an animation is created.
+
Constructor: Sprite.(SpriteLibrary.SpriteController,System.Drawing.Image,System.Int32,System.Int32,System.Int32)
+Summary: Generate a new sprite. It takes a width, height, and the duration in Milliseconds for each frame
+
Constructor: Sprite.(System.Drawing.Point,SpriteLibrary.SpriteController,System.Drawing.Image,System.Int32,System.Int32,System.Int32,System.Int32)
+Summary: Create a Sprite from an animation image, specifying the number of consecutive
+ frames to grab.
+
Sprite.ActuallyDraw
+Summary: Actually draw the Sprite. Never use this. It is used by the SpriteController
+
Sprite.AddAnimation(System.Drawing.Image,System.Int32,System.Int32)
+Summary: Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+
Sprite.AddAnimation(System.Drawing.Image,System.Int32,System.Int32,System.Int32)
+Summary: Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+
Sprite.AddAnimation(System.Drawing.Point,System.Drawing.Image,System.Int32,System.Int32,System.Int32,System.Int32)
+Summary: Add another animation to an existing Sprite. After you add animations, you can use
+ ChangeAnimation to select which animation you want the specified sprite to show.
+ For example, you may want to have Animation 0 be a guy walking left, and animation 1 is
+ that same guy walking right. Because we do not specify the number of frames, it starts
+ at the top-left corner and grabs as many frames as it can from the image.
+
Sprite.AddAnimation(System.Int32,System.Boolean,System.Boolean)
+Summary: Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand.
+
Sprite.AddAnimation(System.Int32,System.Int32)
+Summary: Duplicate an animation, except rotated by the specified number of degrees. For example, if you have
+ a single animation (0), and you want to rotate it by 90 degrees, it will create animation 1 with that
+ rotation to it. In the long haul, generating a few rotated animations is less memory intensive than
+ rotating it on demand.
+
Sprite.AnimateJustAFewTimes(System.Int32,System.Int32)
+Summary: Start a new animation. It will complete the animation the number of times you specify.
+ For example, if your sprite is walking, and one animation is one step, specifying 4 here
+ will result in your sprite taking 4 steps and then the animation stops. You will want
+ to make sure you are checking for when the animation stops, using the SpriteAnimationComplete event,
+ checking the Sprite.AnimationDone flag.
+
Sprite.AnimateOnce(System.Int32)
+Summary: Start a new animation, but do it just once. You can use AnimateJustAFewTimes(1) to the same effect.
+ Or, you can use AnimateJustAFewTimes with a different number. The SpriteAnimationComplete event will
+ fire off when the animation completes. The variable, Sprite.AnimationDone will be true once the
+ animation finishes animating.
+
Sprite.CancelMoveTo
+Summary: Cancel a MoveTo command. The sprite will stop moving, and all the waypoints will be removed.
+
Sprite.ChangeAnimation(System.Int32,System.Int32)
+Summary: Start a new animation index from scratch
+
Sprite.ChangeAnimationSpeed(System.Int32,System.Int32)
+Summary: Change the animation speed of a particular animation. This looks at the first frame
+ and compares that frame to the speed specified. It adjusts all the animations by the
+ same percentage.
+
Sprite.ChangeFrameAnimationSpeed(System.Int32,System.Int32,System.Int32)
+Summary: Change the animation speed of a specific frame. Beware. This affects every sprite using this frame
+
Sprite.CheckSpriteHitsSprite(SpriteLibrary.Sprite,SpriteLibrary.SpriteCollisionMethod)
+Summary: Check to see if two sprites hit each-other. The sprite collision methods are
+ not all programmed in.
+
Sprite.ConvertDegreesToRadians(System.Double)
+Summary: Convert a number from degrees to radians.
+
Sprite.ConvertRadiansToDegrees(System.Double)
+Summary: Convert a number from radians to degrees.
+
Sprite.Destroy
+Summary: Tell the sprite to kill itself. It will erase itself and then
+ be removed from the spritelist. Then it will be gone forever.
+
Sprite.GetAnimationSpeed(System.Int32)
+Summary: Return the animation speed of this particualar animation of the sprite.
+
Sprite.GetFrameAnimationSpeed(System.Int32,System.Int32)
+Summary: Get the animation speed of a single frame.
+
Sprite.GetImage
+Summary: return the current image frame. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+
Sprite.GetImage(System.Int32,System.Int32)
+Summary: return the frame for the given index. Warning: If you write to this image, it will
+ affect all sprites using this frame.
+
Sprite.GetMoveToSpritePoint(SpriteLibrary.Sprite)
+Summary: Return the point that this sprite needs to be shooting for, for the center of this sprite to
+ hit the center of the destination sprite.
+
Sprite.GetSpriteBaseImageCenter
+Summary: Return the centerpoint of the sprite, as found on the background image
+
Sprite.GetSpriteDegrees
+Summary: Get the direction that the sprite is traveling in in degrees. You may want to
+ use Math.Round on the results. The value returned is usually just a tiny bit off
+ from what you set it with. For example, if you set the sprite movement direction
+ to be 270 degrees (down), this function may return it as 269.999992. Rounding the
+ number will give it back to you at probably the same direction you set it as.
+
Sprite.GetSpritePictureboxCenter
+Summary: Return the centerpoint of the sprite, as found on the picturebox
+
Sprite.GetSpriteRadans
+Summary: Returns the direction the sprite is currently traveling, using Radians.
+
Sprite.GetSpriteVector
+Summary: Return the current vector that the sprite is moving along
+
Sprite.HideSprite
+Summary: Remove the sprite from the field. This does not destroy the sprite. It simply removes it from action.
+ Use UnhideSprite to show it again.
+
Sprite.IsPaused(SpriteLibrary.SpritePauseType)
+Summary: Ask if the sprite is paused using the specified sprite type (default is PauseAll)
+
Sprite.MoveTo(SpriteLibrary.Sprite)
+Summary: Move to where the destination sprite currently is at. This is a dumb move. It does not take into
+ consideration the movement direction of the destination sprite. So the moving sprite does need to be
+ moving a bit faster than the sprite you are trying to hit for it to do so.
+
Sprite.MoveTo(System.Collections.Generic.List{System.Drawing.Point})
+Summary: Tell the sprite to move towards each point in turn. The sprite will move in a straight line until the first point.
+ From there it moves to the next point, until it has reached the last point. Every time it reaches a point, the
+ SpriteArrivedAtWaypoint event is triggered. When it reaches the final point in the list, the SpriteArrivedAtEndPoint
+ event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has
+ arrived, it is set to true.
+
Sprite.MoveTo(System.Drawing.Point)
+Summary: Tell the Sprite to move towards a destination. You need to give the sprite a MovementSpeed
+ and tell the sprite that it can automatically move. But the sprite will begin a journey towards
+ that point at the MovementSpeed you have set. When it gets to the point, the SpriteArrivedAtEndPoint event
+ will fire off. Also, the SpriteReachedEnd bool will be true.
+
Sprite.NoteSpriteHitsSprite(SpriteLibrary.Sprite,SpriteLibrary.SpriteCollisionMethod)
+Summary: This is used when two sprites hit each-other.
+
Sprite.Pause(SpriteLibrary.SpritePauseType)
+Summary: Pause the sprite. We can pause just the animation (and still let it move), pause movement (and let it animate), or pause everything.
+
Sprite.PutBaseImageLocation(System.Double,System.Double)
+Summary: Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+
Sprite.PutBaseImageLocation(System.Drawing.Point)
+Summary: Put the Sprite at a specified location, using the dimentions of the BackgroundImage.
+ Unless you are using coordinates you have gotten from a mouse-click, this is how you want
+ to place a Sprite somewhere. It is the easiest way to track things. But, if you are
+ doing something using mouse-click coordinates, you want to use PutPictureBoxLocation
+
Sprite.PutPictureBoxLocation(System.Drawing.Point)
+Summary: Put the Sprite at a specified location, using the dimentions of the PictureBox.
+ You want to use this if you got your X/Y position from a mouse-click. Otherwise,
+ this is the harder way to track things, particularly if your window can resize. Use
+ PutBaseImageLocation instead.
+
Sprite.RecalcPictureBoxLocation
+Summary: Done when the box resizes. We need to recompute the picturebox location. The resize function
+ automatically calls this. You should never need to do so.
+
Sprite.ReplaceImage(System.Drawing.Image,System.Int32,System.Int32)
+Summary: Replace a sprite image. It will replace the current frame unless you specify both an animation
+ and the frame within the animation you wish to replace. Warning: This replaces the image_frame
+ for every sprite that uses that is based off the same image.
+
Sprite.ReturnAdjustmentRatio
+Summary: Taking into consideration how the sprite is stretched or shrunk, it
+ returns a SpriteAdjustmentRatio that can be used to work with the sprite
+ itself.
+
Sprite.SendToBack
+Summary: Make the sprite go behind all other sprites
+
Sprite.SendToFront
+Summary: Make the sprite show up in front of all other sprites.
+
Sprite.SetName(System.String)
+Summary: Give this sprite a name. This way we can make a duplicate of it by specifying the name
+
Sprite.SetSize(System.Drawing.Size)
+Summary: Resize the sprite using the base image coordinates. The width and height specified
+ are relative to the size of the background image, not the picturebox.
+
Sprite.SetSpriteDirection(System.Windows.Vector)
+Summary: Set the sprite direction using a vector. The vector may contain
+ a speed as well as the movement delta (amount of x shift, and amount
+ of y shift.) If so, this function may also affect the movement speed
+ Most people prefer to use SetSpriteDirectionDegrees instead of using
+ vectors.
+
Sprite.SetSpriteDirectionDegrees(System.Double)
+Summary: Given a "degree" (from 0 to 360, set the direction
+ that the sprite moves automatically. 0 is right, 90 is up, 180 is left
+ and 270 is down.
+
Sprite.SetSpriteDirectionRadians(System.Double)
+Summary: Set the sprite direction using Radians. Most people do not want to use this.
+ Use SetSpriteDirectionDegrees instead unless you like math and know what you
+ are doing with Radians.
+
Sprite.SetSpriteDirectionToPoint(System.Drawing.Point)
+Summary: Sets the Sprite Moving towards a given point. You are responsible to do something with it once it gets there.
+ If you want it to automatically stop upon reaching it, use MoveTo instead. Actually, the MoveTo function works
+ a lot better than this one. Because of integer rounding and a few other things, this function is a little
+ bit imprecise. If you send it towards a point, it will go in that general direction. The MoveTo function
+ will perpetually recalculate its way to the destination point and actually reach that point. SetSpriteDirectionToPoint
+ will sort-of head in the direction of the point. But MoveTo will go to that point.
+
Sprite.SpriteAdjustedPoint(System.Drawing.Point)
+Summary: Because sprites are scaled (shrunk or stretched), this function finds the point
+ within the sprite that is specified by the location. this function is used by
+ a number of internal processes, but may be useful to you. But probably not.
+
Sprite.SpriteAtImagePoint(System.Drawing.Point,SpriteLibrary.SpriteCollisionMethod)
+Summary: Check to see if the sprite exists at the point specified. The point given is
+ in coordinates used by the image (not the PictureBox, use SpriteAtPictureBox for that)
+
Sprite.SpriteAtPictureBoxPoint(System.Drawing.Point,SpriteLibrary.SpriteCollisionMethod)
+Summary: Return true or false, asking if the specifiec sprite is at the point on the picturebox.
+ You can use this with a mouse-click to see if you are clicking on a sprite. Use the
+ SpriteCollisionMethod "transparent" to see if you have clicked on an actual pixel of the
+ sprite instead of just within the sprite rectangle.
+
Sprite.SpriteCanMoveOnImage(System.Drawing.Point)
+Summary: Return true if the sprite can go to this point and still be on the drawing-board.
+
Sprite.SpriteCanMoveOnPictureBox(System.Drawing.Point)
+Summary: Return true if the sprite can go to this point and still be on the drawing-board.
+
Sprite.SpriteIntersectsRectangle(System.Drawing.Rectangle)
+Summary: Check to see if the specified rectangle overlaps with the sprite.
+
Sprite.Tick
+Summary: This is run from the sprite controller every 10 miliseconds. You should never
+ need to call this yourself.
+
Sprite.UnPause(SpriteLibrary.SpritePauseType)
+Summary: unpause the sprite.
+
Sprite.UnhideSprite
+Summary: Make the sprite reappear. If you have not positioned it yet, it will show up at the top corner. It is best to only
+ use this when you have hidden it using HideSprite
+
Constructor: SpriteController.(System.Windows.Forms.PictureBox)
+Summary: Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed.
+
Constructor: SpriteController.(System.Windows.Forms.PictureBox,System.EventHandler)
+Summary: Create a sprite controller, specifying the picturebox on which the sprites
+ will be displayed.
+
SpriteController.AddSprite(SpriteLibrary.Sprite)
+Summary: Add the specified sprite to the list of sprites we know about. You usually do not need to do this.
+ Sprites add themselves to the controller when you create a new sprite.
+
SpriteController.AdjustPoint(System.Drawing.Point)
+Summary: Adjust an image point so that it conforms to the picturebox.
+
SpriteController.AdjustRectangle(System.Drawing.Rectangle)
+Summary: Adjust a rectangle that is based on the image, according to the stretch of the picturebox
+
SpriteController.AllSprites
+Summary: Return a list of all sprites
+
SpriteController.ChangeTickInterval(System.Int32)
+Summary: Change the Tick Interval. By default, the spritecontroller does a tick every 10ms, which
+ is very short. Some people may prefer it to happen less regularly. Must be > 5, and less than 1001
+
SpriteController.CountSpritesBasedOff(System.String)
+Summary: Count the number of sprites that were duplicated from the sprite with the specified name
+
SpriteController.DestroyAllSprites
+Summary: Remove all sprites (even named sprites that have not yet been displayed)
+
SpriteController.DestroySprite(SpriteLibrary.Sprite)
+Summary: Tell a sprite to destroy itself. The sprite will have Destroying property set to true from
+ the time you destroy it until it vanishes. Whe you destroy a sprite, it will erase itself
+ and remove itself from the controller. After it is destroyed, it is completely gone.
+
SpriteController.DuplicateSprite(SpriteLibrary.Sprite)
+Summary: Make a duplicate of the specified sprite. The duplicate does not yet have a location.
+
SpriteController.DuplicateSprite(System.String)
+Summary: Find a sprite that has been named with the specified name. Then duplicate that sprite
+
SpriteController.Invalidate(System.Boolean)
+Summary: Invalidate the entire image on which the sprites are drawn
+
SpriteController.Invalidate(System.Drawing.Rectangle,System.Boolean)
+Summary: Invalidate a rectangle that is specified in image coordinates
+
SpriteController.IsKeyPressed
+Summary: Check to see if any keys are pressed.
+
SpriteController.IsKeyPressed(System.Windows.Forms.Keys)
+Summary: Check to see if the given key is pressed.
+
SpriteController.KeysPressed
+Summary: Return a list of all the keys that are currently pressed.
+
SpriteController.Local_Setup
+Summary: Define some things and set up some things that need defining at instantiation
+
SpriteController.MouseClickOnBox(System.Object,System.Windows.Forms.MouseEventArgs)
+Summary: This is what happens when someone clicks on the PictureBox. We want to pass any Click events to the Sprite
+
SpriteController.MouseHover(System.Object,System.EventArgs)
+Summary: Check to see if we are hovering over anything
+
SpriteController.NameSprite(SpriteLibrary.Sprite,System.String)
+Summary: Find the specified Sprite in the controller and change its name to the specified string.
+ You can do the same thing with Sprite.SetName(Name)
+
SpriteController.Pause(SpriteLibrary.SpritePauseType)
+Summary: Pause everything
+
SpriteController.PlaceSpriteBehind(SpriteLibrary.Sprite,SpriteLibrary.Sprite)
+Summary: Change the display order of the sprites such that the specified sprite appears behind the other sprite.
+
SpriteController.PlaceSpriteInFrontOf(SpriteLibrary.Sprite,SpriteLibrary.Sprite)
+Summary: Make the sprite go in front of the specified sprite.
+
SpriteController.PlayAsync(System.IO.Stream,System.String,System.EventHandler)
+Summary: Play a sound bit in a separate thread. When the thread is done, set a bool saying that
+
SpriteController.ProcessImageResize(System.Object,System.EventArgs)
+Summary: Process a form resize by recalculating all the picturebox locations for all sprites.
+
SpriteController.RegisterKeyDownFunction(SpriteLibrary.SpriteKeyEventHandler)
+Summary: If you want to have a KeyDown function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+
SpriteController.RegisterKeyUpFunction(SpriteLibrary.SpriteKeyEventHandler)
+Summary: If you want to have a KeyUp function that is triggered by a keypress function, add the event here.
+ The event should have the parameters (object sender, KeyEventArgs e)
+
SpriteController.ReplaceOriginalImage
+Summary: Notify the sprite controller that you have changed the background image on the
+ PictureBox. Whatever background is on the picturebox is now used to draw all the sprites on.
+
SpriteController.ReplaceOriginalImage(System.Drawing.Image)
+Summary: Replace the image on which the sprites are drawn. Use this when you move to a new playing field,
+ or want to have a different background
+
SpriteController.ResetKeypressState
+Summary: Reset the keypress status. Sometimes the sprite controller misses a key being released (usually
+ because a window has taken priority, or something has changed). Calling this function will reset
+ the stored memory of whether a key has been pressed.
+
SpriteController.ReturnAdjustmentRatio
+Summary: Return an adjustment ratio. This is the image-size to picture-box ratio.
+ It is used for calculating precise pixels or picture-box locations.
+
SpriteController.ReturnPictureBoxAdjustedHeight(System.Int32)
+Summary: Return the height of an object in picture-box terms. It is basically the virtual height
+ of the sprite or other item.
+
SpriteController.ReturnPictureBoxAdjustedPoint(System.Drawing.Point)
+Summary: This does the reverse of an adjusted point. It takes a point on the image and
+ transforms it to one on the PictureBox
+
SpriteController.ReturnPictureBoxAdjustedWidth(System.Int32)
+Summary: Return the width of an object in picture-box terms. It takes the width of a sprite or other
+ item that is being displayed on the screen, and calculates the width as displayed in the
+ picture-box (taking into consideration stretching or shrinking)
+
SpriteController.ReturnPointAdjustedForImage(System.Drawing.Point)
+Summary: This takes a point, the location on a picturebox, and returns the corresponding point on the BackgroundImage.
+
SpriteController.SoundIsFinished(System.String)
+Summary: Check to see if the specified sound has finished playing
+
SpriteController.SoundPlay(System.IO.Stream,System.String)
+Summary: Play a sound that we can check to see if it has completed.
+
SpriteController.SpriteBackwards(SpriteLibrary.Sprite)
+Summary: Change the display order of the specified sprite so it is more likely to go behind all other sprites.
+
SpriteController.SpriteForwards(SpriteLibrary.Sprite)
+Summary: Change the display order of the specified sprite so it is more likely to go in front of other sprites
+
SpriteController.SpriteFromName(System.String)
+Summary: Find a sprite that has a specified name. This returns the actual sprite with that name.
+ You usually want to use DuplicateSprite(Name) to clone the sprite and get one you can
+ destroy. If you destroy a named sprite without duplicating it, you may end up losing
+ it for the remainder of the program.
+
SpriteController.SpriteToBack(SpriteLibrary.Sprite)
+Summary: Change the display order of the specified sprite so it goes behind all other sprites.
+
SpriteController.SpriteToFront(SpriteLibrary.Sprite)
+Summary: Change the display order of the specified sprite so it goes in front of all other sprites.
+
SpriteController.SpritesAtImagePoint(System.Drawing.Point)
+Summary: This takes a point, as as specified on the image, and returns the sprites at that point.
+
SpriteController.SpritesAtPoint(System.Drawing.Point)
+Summary: This takes a point, as given by the mouse-click args, and returns the sprites at that point.
+
SpriteController.SpritesBasedOff(System.String)
+Summary: Return all sprites that were based off a particular sprite name
+
SpriteController.SpritesBasedOffAnything
+Summary: Return a list of all sprites which are not master sprites (have been based off something)
+
SpriteController.SpritesInImageRectangle(System.Drawing.Rectangle)
+Summary: Return a list of all the sprites that intersect with the given background-image-based rectangle
+
SpriteController.SpritesThatHaveBeenDrawn
+Summary: Return a list of all sprites which have been drawn on the image
+
SpriteController.TimerTick(System.Object,System.EventArgs)
+Summary: The function called by the timer every 10 millisecods We also call do_tick, which
+ is the function defined by the user.
+
SpriteController.UnPause(SpriteLibrary.SpritePauseType)
+Summary: un-Pause everything
+
Sprite.CheckBeforeMove
+Summary: This event fires off before a sprite is drawn. Use it if you have constraints. You
+ can change the location or cancel the move entirely.
+
Sprite.Click
+Summary: This event happens when someone clicks on the sprite (on the rectangle in which the sprite is).
+ If you want the event to fire off only when someone clicks on the visible part of the sprite,
+ use ClickTransparent instead.
+
Sprite.ClickTransparent
+Summary: This event happens when someone clicks on the sprite (on the sprite image itself).
+ If the sprite is sometimes hidden, but you want the click to work even if it is not
+ visible at that instant, use Click instead.
+
Sprite.MouseEnter
+Summary: When the mouse moves over the sprite. Use this for a menu, when you want the menu item to glow when the
+ mouse is over the menu item sprite.
+
Sprite.MouseHover
+Summary: This event happens when the mouse moves over the sprite, and then pauses. We use the hover timing from the
+ parent form.
+
Sprite.MouseLeave
+Summary: When the mouse moves off the sprite. Use this for a menu, when you want the menu item to stop glowing when
+ the mouse moves away from the menu item sprite.
+
Sprite.SpriteAnimationComplete
+Summary: Only used when you tell an animation to animate once. At the end of the animation,
+ this function fires off.
+
Sprite.SpriteArrivedAtEndPoint
+Summary: An event for when you tell a Sprite to MoveTo(Point) a specific point, or, when you
+ tell the Sprite to MoveTo(list of points). When the Sprite has reached the final destination,
+ the Sprite fires off this event.
+
Sprite.SpriteArrivedAtWaypoint
+Summary: When you tell a sprite to MoveTo(list of points), this fires off every time it gets to
+ one of the points. When it gets to the final point, only the SpriteAtEndPoint event fires off.
+
Sprite.SpriteBeingDestroyed
+Summary: The Sprite has just been told to be destroyed. You might want to do some cleanup.
+ If you need to destroy some payload data, or tell something to cleanup after the sprite
+ this is where to do that.
+
Sprite.SpriteChangesAnimationFrames
+Summary: When the frame of an animation changes. If you want to have something happen every time
+ the foot of your monster comes down, when the swing of your sword is at certain points, etc.
+ Check to see that the Animaton and FrameIndex are what you expect them to be.
+
Sprite.SpriteExitsPictureBox
+Summary: This happens when the sprite has exited the picture box. Useful when you want to
+ keep sprites from traveling on forever after exiting.
+
Sprite.SpriteHitsPictureBox
+Summary: This happens when the sprite hits the border of the picture-box.
+ Useful for when you want to have shots explode when they hit the side.
+
Sprite.SpriteHitsSprite
+Summary: This happens when two sprites hit each-other. The SpriteEventArgs that is returned
+ contains the sprite that this sprite hits.
+
Sprite.SpriteInitializes
+Summary: This event happens right after the sprite is created. Use this to immediately set a
+ sprite to animate once or something like that.
+
SpriteController.DoTick
+Summary: Define a stub for an event handler that the programmer can define if they want to run
+ something on the tick, along with the sprite animations.
+
Sprite.CannotMoveOutsideBox
+Summary: Determine if the sprite will automatically move outside the box. If not, it will hit the side of the box and stick
+
Sprite.MirrorHorizontally
+Summary: Flip the image when it gets printed. If your sprite is walking left, flipping it will
+ make it look like it is going right.
+
Sprite.MirrorVertically
+Summary: Flip the image when it gets printed. If your sprite looks like it is facing up, doing
+ this will make it look like it faces down.
+
Sprite.MovementSpeed
+Summary: The movement speed of the sprite. To make a Sprite move, you need to set the MovementSpeed,
+ the direction (using SetSpriteDirection), and the AutomaticallyMoves property.
+
Sprite.MovingToSprite
+Summary: If we are trying to collide with a sprite, we store that sprite here.
+
Sprite.payload
+Summary: A Sprite can hold a payload. Use this to store extra information about the various Sprites. Health, Armor,
+ Shoot time, etc. But, to store information in the payload, you need to make a new class of SpritePayload. The syntax
+ for doing so is: public class TankPayload : SpritePayload { public int Armor; public int Speed; }
+ You can access the payload and retrieve the various values.
+
SpriteAdjustmentRatio.height_ratio
+Summary: Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+
SpriteAdjustmentRatio.width_ratio
+Summary: Divide a picturebox ratio by this to get the image location. Multiply an image location by this to get the picturebox location.
+
SpriteCollisionMethod.circle
+Summary: Draws a circle (ellipse) inside the sprite rectangles and see if those ellipses overlap
+
SpriteCollisionMethod.rectangle
+Summary: Checks if the two rectangles that contain the sprites overlap
+
SpriteCollisionMethod.transparency
+Summary: Check to see if nontransparent portions of a sprite collide. Not working.
+
SpriteController.InvalidateList
+Summary: This is only used by the SpriteController. It allows us to queue up invalidation requests.
+
SpriteController.OptimizeForLargeSpriteImages
+Summary: If your sprite images need substantial growing or shrinking when displayed, you can try setting this to "true"
+ to see if it makes it run any faster. What it does is to resize the image once, and keep a cached copy of that
+ image at that size. If you use the same sprite, but with different sizes, setting this to "True" may actually slow
+ down the game instead of speeding it up.
+
SpriteController.RandomNumberGenerator
+Summary: Since everything needs a random number generator, we make one that should be accessible throughout your program.
+
SpriteController.SpriteComparisonDelegate
+Summary: Allow the sprite sort-method to be overridden. The default sprite sort method is:
+ SpriteComparisonDelegate = delegate (Sprite first, Sprite second) { return first.Zvalue.CompareTo(second.Zvalue); };
+ Which compares just the Zvalues of the two sprites. Often you will want to have a more refined sort. The sort
+ order determines which sprites appear on top of other sprites. In the default state, if two sprites have the
+ same Zvalue, it is very uncleaer which one will draw on top of the other one. By overridding this sort function,
+ you can specify a very precise order of which sprite is on top and which is behind.
+
SpriteEventArgs.Cancel
+Summary: Used primarily in the CheckBeforeMove event. If you set cancel to true, then the move fails.
+ You can use this to keep a Sprite from going places where it ought not to go.
+
SpriteEventArgs.CollisionMethod
+Summary: The CollisionMethod used in the event. Currently, only rectangle collisions are used
+
SpriteEventArgs.NewLocation
+Summary: For the CheckBeforeMove event, newlocation will be the location the sprite is trying
+ to move to. You can adjust the point (move it left, right, up, down) and it will affect
+ the placement of the sprite.
+
SpriteEventArgs.TargetSprite
+Summary: If another Sprite is involved in the event (Collision), than that Sprite is included here.
+ It will be null if no other Sprite is involved.
+
SpritePauseType.PauseAll
+Summary: All pausable things are paused.
+
SpritePauseType.PauseAnimation
+Summary: Pause the animating. Animation resumes from the current frame when we unpause
+
SpritePauseType.PauseEvents
+Summary: Pause events. Sprite collisions, movement checks, etc are stopped until the unpause
+
SpritePauseType.PauseMovement
+Summary: Pause any automatic movement. Movement resumes where it was left off if you unpause
+
diff --git a/SpriteLibrary/KeyMessageFilter.cs b/SpriteLibrary/KeyMessageFilter.cs
new file mode 100644
index 0000000..cbc2ad6
--- /dev/null
+++ b/SpriteLibrary/KeyMessageFilter.cs
@@ -0,0 +1,107 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace SpriteLibrary
+{
+ ///
+ /// private KeyMessageFilter the_filter = new KeyMessageFilter();
+ ///
+ /// When the form loads (in the
+ /// Application.AddMessageFilter(the_filter);
+ ///
+ /// And then, to use it, do something like:
+ ///
+ /// bool Up = m_filter.IsKeyPressed(Keys.W);
+ /// bool Down = m_filter.IsKeyPressed(Keys.S);
+ ///
+ /// Much of this code was found here:
+ /// public class TankPayload : SpritePayload { public int Armor; public int Speed; }
+ ///
+ /// You can access the payload and retrieve the various values.
+ ///
+ /// SpriteController MySpriteController;
+ ///
+ /// And then, when the form is created, after the InitializeComponents() function, you
+ /// need to configure the drawing area and create the sprite controller:
+ ///
+ /// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ /// MySpriteController = new SpriteController(MainDrawingArea);
+ ///
+ /// In this case, MainDrawingArea is the picturebox where all the sprites will be displayed.
+ ///
+ /// public partial class ShootingFieldForm : Form
+ /// {
+ /// public ShootingFieldForm()
+ /// {
+ /// InitializeComponent();
+ /// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ /// MySpriteController = new SpriteController(MainDrawingArea);
+ /// }
+ /// }
+ ///
+ ///
+ /// public partial class ShootingFieldForm : Form
+ /// {
+ /// public ShootingFieldForm()
+ /// {
+ /// InitializeComponent();
+ /// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ /// MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress);
+ /// }
+ ///
+ /// private void CheckForKeyPress(object sender, EventArgs e)
+ /// {
+ /// //Do stuff here
+ /// }
+ /// }
+ ///
+ ///
+ ///
+ /// SpriteComparisonDelegate = delegate (Sprite first, Sprite second) { return first.Zvalue.CompareTo(second.Zvalue); };
+ ///
+ /// Which compares just the Zvalues of the two sprites. Often you will want to have a more refined sort. The sort
+ /// order determines which sprites appear on top of other sprites. In the default state, if two sprites have the
+ /// same Zvalue, it is very uncleaer which one will draw on top of the other one. By overridding this sort function,
+ /// you can specify a very precise order of which sprite is on top and which is behind.
+ ///
+ /// void ReplaceBackground(Image NewBackground)
+ ///{
+ /// if (MyController == null) return;
+ /// if (NewBackground == null) return;
+ ///
+ /// Image OneImage = new Bitmap(NewBackground);
+ /// MyController.ReplaceOriginalImage(OneImage);
+ ///
+ /// Image TwoImage = new Bitmap(NewBackground);
+ /// pb_map.BackgroundImage = TwoImage;
+ /// pb_map.Invalidate();
+ ///}
+ ///
+ ///
+ /// public partial class ShootingFieldForm : Form
+ /// {
+ /// public ShootingFieldForm()
+ /// {
+ /// InitializeComponent();
+ /// MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ /// MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ /// MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress);
+ /// }
+ ///
+ /// private void CheckForKeyPress(object sender, EventArgs e)
+ /// {
+ /// bool left = false;
+ /// bool right = false;
+ /// bool space = false;
+ /// bool didsomething = false;
+ /// TimeSpan duration = DateTime.Now - LastMovement;
+ /// if (duration.TotalMilliseconds < 100)
+ /// return;
+ /// LastMovement = DateTime.Now;
+ /// if (MySpriteController.IsKeyPressed(Keys.A) || MySpriteController.IsKeyPressed(Keys.Left))
+ /// {
+ /// left = true;
+ /// }
+ /// if (MySpriteController.IsKeyPressed(Keys.D)||MySpriteController.IsKeyPressed(Keys.Right))
+ /// {
+ /// right = true;
+ /// }
+ /// if (left && right) return; //do nothing if we conflict
+ /// if (left)
+ /// {
+ /// if (LastDirection != MyDir.left)
+ /// {
+ /// Spaceship.SetSpriteDirectionDegrees(180);
+ /// //We want to only change animation once. Every time we change
+ /// //the animation, it starts at the first frame again.
+ /// Spaceship.ChangeAnimation(0);
+ /// LastDirection = MyDir.left;
+ /// }
+ /// didsomething = true;
+ /// Spaceship.MovementSpeed = 15;
+ /// Spaceship.AutomaticallyMoves = true;
+ /// }
+ /// if (right)
+ /// {
+ /// if (LastDirection != MyDir.right)
+ /// {
+ /// Spaceship.SetSpriteDirectionDegrees(0);
+ /// Spaceship.ChangeAnimation(0);
+ /// LastDirection = MyDir.right;
+ /// }
+ /// didsomething = true;
+ /// Spaceship.AutomaticallyMoves = true;
+ /// Spaceship.MovementSpeed = 15;
+ /// }
+ /// if(!didsomething)
+ /// {
+ /// LastDirection = MyDir.stopped;
+ /// //No keys pressed. Stop moving
+ /// Spaceship.MovementSpeed = 0;
+ /// }
+ /// }
+ ///
+ ///
+ /// public void AddSprite(string name, int startx, int starty)
+ /// {
+ /// Sprite NewSprite = MySpriteController.DuplicateSprite(What.ToString());
+ /// if(NewSprite != null)
+ /// {
+ /// NewSprite.AutomaticallyMoves = true;
+ /// NewSprite.CannotMoveOutsideBox = true;
+ /// NewSprite.SetSpriteDirectionDegrees(180); //left
+ /// NewSprite.PutBaseImageLocation(new Point(startx, starty));
+ /// NewSprite.MovementSpeed = 5;
+ /// }
+ /// }
+ ///
+ ///
+ /// public class TankPayload : SpritePayload
+ /// {
+ /// public int Armor = 20;
+ /// public int FireTime = 100;
+ /// }
+ ///
+ /// And then you add that to your sprite:
+ /// TankSprite.Payload = new TankPayload();
+ /// If there is no payload, then the payload
+ /// property is null. If you have multiple types of SpritePayloads, you may need to do something like:
+ ///
+ /// if(TankSprite.payload != null and TankSprite.payload is TankPayload)
+ /// {
+ /// TankPayload tPayload = (TankPayload)TankSprite.payload; tPayload.Armor--;
+ /// }
+ ///
+ ///
+ private KeyMessageFilter the_filter = new KeyMessageFilter();
+
+ When the form loads (in the
+ Application.AddMessageFilter(the_filter);
+
+ And then, to use it, do something like:
+
+ bool Up = m_filter.IsKeyPressed(Keys.W);
+ bool Down = m_filter.IsKeyPressed(Keys.S);
+
+ Much of this code was found here:
+ public class TankPayload : SpritePayload { public int Armor; public int Speed; }
+
+ You can access the payload and retrieve the various values.
+
+ SpriteController MySpriteController;
+
+ And then, when the form is created, after the InitializeComponents() function, you
+ need to configure the drawing area and create the sprite controller:
+
+ MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ MySpriteController = new SpriteController(MainDrawingArea);
+
+ In this case, MainDrawingArea is the picturebox where all the sprites will be displayed.
+
+ public partial class ShootingFieldForm : Form
+ {
+ public ShootingFieldForm()
+ {
+ InitializeComponent();
+ MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ MySpriteController = new SpriteController(MainDrawingArea);
+ }
+ }
+
+
+ public partial class ShootingFieldForm : Form
+ {
+ public ShootingFieldForm()
+ {
+ InitializeComponent();
+ MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress);
+ }
+
+ private void CheckForKeyPress(object sender, EventArgs e)
+ {
+ //Do stuff here
+ }
+ }
+
+
+
+ SpriteComparisonDelegate = delegate (Sprite first, Sprite second) { return first.Zvalue.CompareTo(second.Zvalue); };
+
+ Which compares just the Zvalues of the two sprites. Often you will want to have a more refined sort. The sort
+ order determines which sprites appear on top of other sprites. In the default state, if two sprites have the
+ same Zvalue, it is very uncleaer which one will draw on top of the other one. By overridding this sort function,
+ you can specify a very precise order of which sprite is on top and which is behind.
+
+ void ReplaceBackground(Image NewBackground)
+ {
+ if (MyController == null) return;
+ if (NewBackground == null) return;
+
+ Image OneImage = new Bitmap(NewBackground);
+ MyController.ReplaceOriginalImage(OneImage);
+
+ Image TwoImage = new Bitmap(NewBackground);
+ pb_map.BackgroundImage = TwoImage;
+ pb_map.Invalidate();
+ }
+
+
+ public partial class ShootingFieldForm : Form
+ {
+ public ShootingFieldForm()
+ {
+ InitializeComponent();
+ MainDrawingArea.BackgroundImage = Properties.Resources.Background;
+ MainDrawingArea.BackgroundImageLayout = ImageLayout.Stretch;
+ MySpriteController = new SpriteController(MainDrawingArea, CheckForKeyPress);
+ }
+
+ private void CheckForKeyPress(object sender, EventArgs e)
+ {
+ bool left = false;
+ bool right = false;
+ bool space = false;
+ bool didsomething = false;
+ TimeSpan duration = DateTime.Now - LastMovement;
+ if (duration.TotalMilliseconds < 100)
+ return;
+ LastMovement = DateTime.Now;
+ if (MySpriteController.IsKeyPressed(Keys.A) || MySpriteController.IsKeyPressed(Keys.Left))
+ {
+ left = true;
+ }
+ if (MySpriteController.IsKeyPressed(Keys.D)||MySpriteController.IsKeyPressed(Keys.Right))
+ {
+ right = true;
+ }
+ if (left && right) return; //do nothing if we conflict
+ if (left)
+ {
+ if (LastDirection != MyDir.left)
+ {
+ Spaceship.SetSpriteDirectionDegrees(180);
+ //We want to only change animation once. Every time we change
+ //the animation, it starts at the first frame again.
+ Spaceship.ChangeAnimation(0);
+ LastDirection = MyDir.left;
+ }
+ didsomething = true;
+ Spaceship.MovementSpeed = 15;
+ Spaceship.AutomaticallyMoves = true;
+ }
+ if (right)
+ {
+ if (LastDirection != MyDir.right)
+ {
+ Spaceship.SetSpriteDirectionDegrees(0);
+ Spaceship.ChangeAnimation(0);
+ LastDirection = MyDir.right;
+ }
+ didsomething = true;
+ Spaceship.AutomaticallyMoves = true;
+ Spaceship.MovementSpeed = 15;
+ }
+ if(!didsomething)
+ {
+ LastDirection = MyDir.stopped;
+ //No keys pressed. Stop moving
+ Spaceship.MovementSpeed = 0;
+ }
+ }
+
+
+ public void AddSprite(string name, int startx, int starty)
+ {
+ Sprite NewSprite = MySpriteController.DuplicateSprite(What.ToString());
+ if(NewSprite != null)
+ {
+ NewSprite.AutomaticallyMoves = true;
+ NewSprite.CannotMoveOutsideBox = true;
+ NewSprite.SetSpriteDirectionDegrees(180); //left
+ NewSprite.PutBaseImageLocation(new Point(startx, starty));
+ NewSprite.MovementSpeed = 5;
+ }
+ }
+
+
+ public class TankPayload : SpritePayload
+ {
+ public int Armor = 20;
+ public int FireTime = 100;
+ }
+
+ And then you add that to your sprite:
+ TankSprite.Payload = new TankPayload();
+ If there is no payload, then the payload
+ property is null. If you have multiple types of SpritePayloads, you may need to do something like:
+
+ if(TankSprite.payload != null and TankSprite.payload is TankPayload)
+ {
+ TankPayload tPayload = (TankPayload)TankSprite.payload; tPayload.Armor--;
+ }
+
+