public void Load(string exampleDir, Bitmap spriteBitmap) { misilBitmap = spriteBitmap; sprite = new Sprite(); sprite.Bitmap = misilBitmap; }
public void Load(string exampleDir, Bitmap spriteSheet) { asteroidBitmap = spriteSheet; sprites = new List<Sprite>(); spriteSize = new Vector2(SpriteWidth, SpriteHeight); size = 1.0f; angle = 0.0f; Sprite newSprite; //Creo 64 sprites asignando distintos clipping rects a cada uno. for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { newSprite = new Sprite(); newSprite.Bitmap = asteroidBitmap; newSprite.SrcRect = new Rectangle(j * (int)spriteSize.X, i * (int)spriteSize.Y, (int)spriteSize.X, (int)spriteSize.Y); newSprite.Scaling = new Vector2(size, size); newSprite.Rotation = angle; sprites.Add(newSprite); } } currentSprite = 0; GenerateRandomPosition(); }
public void Load(string exampleDir, Bitmap bitmap) { spaceshipBitmap = bitmap; sprites = new List<Sprite>(); spriteSize = new Vector2(41, 44); size = 2.0f; Sprite newSprite; for (int i = 0; i < 3; i++) { newSprite = new Sprite(); newSprite.Bitmap = spaceshipBitmap; newSprite.SrcRect = new Rectangle(i * (int)spriteSize.X, 0, (int)spriteSize.X, (int)spriteSize.Y); newSprite.Scaling = new Vector2(size, size); sprites.Add(newSprite); } currentSprite = 0; state = StateEnum.Idle; Position = new Vector2(100, 100); speed = new Vector2(0, 0); angleToMousePointer = 0; RestartPosition(); GuiController.Instance.UserVars.addVar("elapsed"); GuiController.Instance.UserVars.addVar("speedX"); GuiController.Instance.UserVars.addVar("speedY"); GuiController.Instance.UserVars.addVar("PosX"); GuiController.Instance.UserVars.addVar("PosY"); GuiController.Instance.UserVars.addVar("MousePosX"); GuiController.Instance.UserVars.addVar("MousePosY"); GuiController.Instance.UserVars.addVar("AngleMouse"); GuiController.Instance.UserVars.addVar("Misiles"); }
/// <summary> /// Draws a sprite on the screen. /// </summary> /// <param name="sprite">The sprite.</param> public void DrawSprite(Sprite sprite) { DxSprite.Transform = sprite.TransformationMatrix; DxSprite.Draw(sprite.Bitmap.Texture, sprite.SrcRect, Vector3.Empty, Vector3.Empty, sprite.Color); }