From 2fdc1d26ab36dbe5452bb1346355d406460ac9ec Mon Sep 17 00:00:00 2001 From: Tim Young Date: Mon, 25 Sep 2017 14:27:54 -0500 Subject: [PATCH] Lots more documentation updates for the sprite controller --- SpriteLibrary/Sprite.cs | 86 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/SpriteLibrary/Sprite.cs b/SpriteLibrary/Sprite.cs index c4983c6..d747492 100644 --- a/SpriteLibrary/Sprite.cs +++ b/SpriteLibrary/Sprite.cs @@ -137,10 +137,25 @@ namespace SpriteLibrary private Sprite MovingToSprite = null; private bool _AutomaticallyMoves = false; //Does the sprite move in the direction it has been set? + /// /// Determine if the sprite automatically moves (you need to give it a direction [using one of the /// SetSpriteDirection functions] and speed [MovementSpeed = X] also) /// + /// + /// Here is a short bit of code, showing how AutomaticallyMoves is part of the bigger picture. You + /// need to set the direction (or use a function), as well + /// as setting the speed. + /// + /// Sprite NewSprite = MySpriteController.DuplicateSprite("Dragon"); + /// NewSprite.AutomaticallyMoves = true; + /// NewSprite.CannotMoveOutsideBox = true; + /// NewSprite.SpriteHitsPictureBox += SpriteBounces; + /// NewSprite.SetSpriteDirectionDegrees(90); + /// NewSprite.PutBaseImageLocation(new Point(startx, starty)); + /// NewSprite.MovementSpeed = speed; + /// + /// public bool AutomaticallyMoves { get { return _AutomaticallyMoves; } @@ -926,6 +941,22 @@ namespace SpriteLibrary /// 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 /// + /// + /// Here is a short bit of code, showing how PutBaseImageLocation is part of the bigger picture. You + /// may want to tell it to , + /// set the direction + /// (or use a function), as well + /// as setting the speed (). + /// + /// Sprite NewSprite = MySpriteController.DuplicateSprite("Dragon"); + /// NewSprite.AutomaticallyMoves = true; + /// NewSprite.CannotMoveOutsideBox = true; + /// NewSprite.SpriteHitsPictureBox += SpriteBounces; + /// NewSprite.SetSpriteDirectionDegrees(90); + /// NewSprite.PutBaseImageLocation(new Point(startx, starty)); + /// NewSprite.MovementSpeed = speed; + /// + /// /// The new point on the Image public void PutBaseImageLocation(Point NewLocationOnImage) { @@ -948,7 +979,7 @@ namespace SpriteLibrary /// 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 + /// doing something using mouse-click coordinates, you want to use /// /// The X location on the background image /// the Y location on the background image @@ -1219,7 +1250,17 @@ namespace SpriteLibrary /// /// Tell the sprite to kill itself. It will erase itself and then - /// be removed from the spritelist. Then it will be gone forever. + /// be removed from the spritelist. Then it will be gone forever. Sort-of. You see, so long as + /// you still have a variable that has the sprite, that variable will still be able to reference + /// the Sprite. The value will say that it is trying to be destroyed, + /// but you can still accidentally do something. You really want to set your variables to null once + /// you destroy something: + /// + /// + /// MySprite.Destroy(); + /// MySprite = null; + /// + /// /// public void Destroy() { @@ -1447,6 +1488,19 @@ namespace SpriteLibrary /// 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. /// + /// + /// In this example we are creating a "heat seaking" missile that will find the target sprite, regardless + /// of where it moves. The missile will move in a straight line from where it is to where the target sprite is, + /// regardless of where the target sprite moves to. It readjusts the movement direction quite often, so it + /// is very difficult to dodge. Use this only when you really want the thing to hit. + /// + /// Sprite NewSprite = MySpriteController.DuplicateSprite("Missile"); + /// NewSprite.AutomaticallyMoves = true; + /// NewSprite.PutBaseImageLocation(new Point(startx, starty)); + /// NewSprite.MoveTo(TargetSprite); + /// NewSprite.MovementSpeed = speed; + /// + /// /// The sprite we are trying to hit public void MoveTo(Sprite Destination) { @@ -1466,6 +1520,17 @@ namespace SpriteLibrary /// 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. /// + /// + /// In this example, we are creating a missile sprite and shooting it to where the target sprite + /// currently is. The target may move away and we might miss it entirely. + /// + /// Sprite NewSprite = MySpriteController.DuplicateSprite("Missile"); + /// NewSprite.AutomaticallyMoves = true; + /// NewSprite.PutBaseImageLocation(new Point(startx, starty)); + /// NewSprite.MoveTo(TargetSprite.BaseImageLocation); + /// NewSprite.MovementSpeed = speed; + /// + /// /// An image-point that the sprite will move to. public void MoveTo(Point Destination) { @@ -1481,6 +1546,23 @@ namespace SpriteLibrary /// event is triggered. While the sprite is moving, the SpriteReachedEndPoint attribute is set to false. When it has /// arrived, it is set to true. /// + /// + /// In this example, we are creating a missile sprite and giving it a path to follow to get where we want it + /// to go. The path is somewhat curved. The missile will fly straight between each of the different points listed. + /// + /// Sprite NewSprite = MySpriteController.DuplicateSprite("Missile"); + /// NewSprite.AutomaticallyMoves = true; + /// NewSprite.PutBaseImageLocation(new Point(100, 100)); + /// List<Point> MyWaypoints = new List<Point>(); + /// MyWaypoints.Add(new Point(100,100)); + /// MyWaypoints.Add(new Point(120, 90)); + /// MyWaypoints.Add(new Point(130, 80)); + /// MyWaypoints.Add(new Point(140, 90)); + /// MyWaypoints.Add(new Point(180,100)); + /// NewSprite.MoveTo(TargetSprite.BaseImageLocation); + /// NewSprite.MovementSpeed = speed; + /// + /// /// A list of Image-Points that the sprite will follow, one after the other public void MoveTo(List DestinationList) {