Exemple #1
0
 public override void Init()
 {
     this.Texture = new Texture("Resources/1.png");
     Moving       = true;
     this.Scale   = new SFML.System.Vector2f(0.2f, 0.2f);
     Position     = new SFML.System.Vector2f(PositionX, PositionY);
 }
Exemple #2
0
 public TextObject(Font newFont, SFML.System.Vector2f WindowSize)
 {
     Font         = newFont;
     Text.Font    = Font;
     windowHeight = WindowSize.Y;
     windowWidth  = WindowSize.X;
 }
Exemple #3
0
        public void DrawRectangle(int x1, int y1, int x2, int y2, Color color, Color color2, int thickness)
        {
            if (!IsObjectOnScreen(x1, y1, x2 - x1, y2 - y1))
            {
                return;
            }

            var zoom = GetZoom();

            int real_x1 = (int)(x1 * zoom);
            int real_x2 = (int)(x2 * zoom);
            int real_y1 = (int)(y1 * zoom);
            int real_y2 = (int)(y2 * zoom);

            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x1, real_y1);
            SFML.System.Vector2f size     = new SFML.System.Vector2f(real_x2 - real_x1, real_y2 - real_y1);

            SFML.Graphics.RectangleShape rect = new SFML.Graphics.RectangleShape();
            rect.OutlineThickness = thickness;
            rect.OutlineColor     = new SFML.Graphics.Color(color2.R, color2.G, color2.B, color2.A);
            rect.FillColor        = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);
            rect.Position         = position;
            rect.Size             = size;
            RenderWindow.Draw(rect);
        }
Exemple #4
0
        public void DrawQuad(int x, int y, int width, int height, Color color, Color color2, int thickness)
        {
            var zoom = GetZoom();

            int real_x      = (int)(x * zoom);
            int real_y      = (int)(y * zoom);
            int real_width  = (int)(width * zoom);
            int real_height = (int)(height * zoom);

            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x, real_y);
            SFML.System.Vector2f size     = new SFML.System.Vector2f(real_width, real_height);

            float offset_x = 0;
            float offset_y = 0;

            SFML.Graphics.ConvexShape rect = new SFML.Graphics.ConvexShape(4);
            rect.OutlineThickness = thickness;
            rect.OutlineColor     = new SFML.Graphics.Color(color2.R, color2.G, color2.B, color2.A);
            rect.FillColor        = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);
            rect.Position         = position;
            rect.SetPoint(0, new SFML.System.Vector2f(offset_x, offset_y));
            rect.SetPoint(1, new SFML.System.Vector2f(offset_x + size.X, offset_y));
            rect.SetPoint(2, new SFML.System.Vector2f(offset_x + size.X - size.Y, offset_y + size.Y));
            rect.SetPoint(3, new SFML.System.Vector2f(offset_x - size.Y, offset_y + size.Y));
            RenderWindow.Draw(rect);
        }
Exemple #5
0
 public override void Init()
 {
     Texture  = Resources.bonus;
     Moving   = true;
     Position = new SFML.System.Vector2f(PositionX, PositionY);
     Scale    = new SFML.System.Vector2f(0.01f, 0.01f);
 }
Exemple #6
0
        //Rendering function
        public void frame(RenderWindow window, GameObject[,] objArray, int[] numObj)
        {
            window.Clear(clearColor);
            setWindowDimension(window);
            Vector2f halfSize = (Vector2f)screenSize / 2;
            Vector2f halfSpriteSize;

            for (int i = 0; i < numObj.Length; i++)
            {
                for (int j = 0; j < numObj[i]; j++)
                {
                    if (objArray[i, j].Visible && objArray[i, j].ImageExists)
                    {
                        Sprite sprite = new Sprite();
                        sprite.Texture  = new Texture(objArray[i, j].Img);
                        sprite.Scale    = multiplyVector(objArray[i, j].scale, resolutionScale);
                        halfSpriteSize  = multiplyVector((Vector2f)sprite.Texture.Size / 2, objArray[i, j].scale);
                        sprite.Position = multiplyVector(objArray[i, j].position - camera.position - halfSpriteSize, resolutionScale) + halfSize;
                        window.Draw(sprite);
                        sprite.Texture.Dispose();
                        sprite.Dispose();
                    }
                }
            }
            window.Display();
        }
        /// <summary>
        /// Draws a Rectangle
        /// </summary>
        /// <param name="rect"> Rectangle to draw </param>
        public void Draw(Rectangle rect)
        {
            // scale the sprite to fit in the given rectangle.
            Vector2 oldScale    = Scale;
            Vector2 oldPosition = base.Position;

            base.Position = new Vector2(rect.Left, rect.Top);
            Scale         = new SFML.System.Vector2f((float)rect.Width / (float)TextureRect.Width, (float)rect.Height / (float)TextureRect.Height);

            if (_renderTarget != null)
            {
                _renderTarget.Draw(this);
            }
            else
            {
                CluwneLib.CurrentRenderTarget.Draw(this);
            }
            if (CluwneLib.Debug.RenderingDelay > 0)
            {
                CluwneLib.Screen.Display();
                System.Threading.Thread.Sleep(CluwneLib.Debug.RenderingDelay);
            }

            base.Position = oldPosition;
            Scale         = oldScale;
        }
Exemple #8
0
 public void moveShip(int direction)
 {
     if (direction == 0)
     {
         movingDirection = new SFML.System.Vector2f(this.Position.X - 100.0f, this.Position.Y);
         if (this.Position.X - 100 >= 0)
         {
             this.Position = movingDirection;
         }
         else if (this.Position.X - 100 < 0)
         {
             this.Position = new SFML.System.Vector2f(0, this.Position.Y);
         }
     }
     else if (direction == 1)
     {
         movingDirection = new SFML.System.Vector2f(this.Position.X + 100.0f, this.Position.Y);
         if (this.Position.X + 100 <= 720)
         {
             this.Position = movingDirection;
         }
         else if (this.Position.X + 100 > 720)
         {
             this.Position = new SFML.System.Vector2f(700, this.Position.Y);
         }
     }
 }
Exemple #9
0
 public EndindText(Font newFont, SFML.System.Vector2f WindowSize) : base(newFont, WindowSize)
 {
     ListOfEndingTexts.Add("Congratulations! You won! \n \t Press Enter to continue");
     ListOfEndingTexts.Add("You lost! Bacteria started mutating! \n \t Press Enter to continue");
     Text.Scale = new SFML.System.Vector2f(.5f, .5f);
     Text.Style = Text.Styles.Bold;
 }
Exemple #10
0
        /// <summary>
        /// Processes an area and applies a gradient calculation to each part of the area.
        /// </summary>
        /// <param name="position">The center of the gradient.</param>
        /// <param name="strength">The width of the gradient spread.</param>
        /// <param name="angle">The angle to apply the gradient.</param>
        /// <param name="area">The area to calculate.</param>
        /// <param name="applyAction">The callback called for each part of the area.</param>
        public static void GradientFill(Point cellSize, Point position, int strength, int angle, Rectangle area, ColorGradient gradient, Action <int, int, Color> applyAction)
        {
            double radians = angle * Math.PI / 180; // = Math.Atan2(x1 - x2, y1 - y2);

            Vector2 angleVector = new Vector2((float)(Math.Sin(radians) * strength), (float)(Math.Cos(radians) * strength)) / 2;
            Vector2 location    = new Vector2(position.X, position.Y);

            if (cellSize.X > cellSize.Y)
            {
                angleVector.Y *= cellSize.X / cellSize.Y;
            }

            else if (cellSize.X < cellSize.Y)
            {
                angleVector.X *= cellSize.Y / cellSize.X;
            }

            Vector2 endingPoint   = location + angleVector;
            Vector2 startingPoint = location - angleVector;

            double x1 = (startingPoint.X / (double)area.Width) * 2.0f - 1.0f;
            double y1 = (startingPoint.Y / (double)area.Height) * 2.0f - 1.0f;
            double x2 = (endingPoint.X / (double)area.Width) * 2.0f - 1.0f;
            double y2 = (endingPoint.Y / (double)area.Height) * 2.0f - 1.0f;

            double start = x1 * angleVector.X + y1 * angleVector.Y;
            double end   = x2 * angleVector.X + y2 * angleVector.Y;

            for (int x = area.Left; x < area.Width; x++)
            {
                for (int y = area.Top; y < area.Height; y++)
                {
                    // but we need vectors from (-1, -1) to (1, 1)
                    // instead of pixels from (0, 0) to (width, height)
                    double u = (x / (double)area.Width) * 2.0f - 1.0f;
                    double v = (y / (double)area.Height) * 2.0f - 1.0f;

                    double here = u * angleVector.X + v * angleVector.Y;

                    double lerp = (start - here) / (start - end);

                    //lerp = Math.Abs((lerp - (int)lerp));

                    lerp = MyMathHelper.Clamp((float)lerp, 0f, 1.0f);

                    int counter;
                    for (counter = 0; counter < gradient.Stops.Length && gradient.Stops[counter].Stop < (float)lerp; counter++)
                    {
                        ;
                    }

                    counter--;
                    counter = (int)MyMathHelper.Clamp(counter, 0, gradient.Stops.Length - 2);

                    float newLerp = (gradient.Stops[counter].Stop - (float)lerp) / (gradient.Stops[counter].Stop - gradient.Stops[counter + 1].Stop);

                    applyAction(x, y, ColorHelper.Lerp(gradient.Stops[counter].Color, gradient.Stops[counter + 1].Color, newLerp));
                }
            }
        }
Exemple #11
0
        public View setCameraToPlayer(RenderTarget target)
        {
            SFML.System.Vector2f defaultSize = target.DefaultView.Size;
            View v = new View(new SFML.System.Vector2f(ConvertUnits.ToDisplayUnits(player.body.Position.X), ConvertUnits.ToDisplayUnits(player.body.Position.Y)), defaultSize);

            background.Update(new SFML.System.Vector2f(ConvertUnits.ToDisplayUnits(player.body.Position.X) - target.Size.X * .5f, ConvertUnits.ToDisplayUnits(player.body.Position.Y) - target.Size.Y * .5f));
            return(v);
        }
Exemple #12
0
        public Pill(string path, SFML.System.Vector2f WindowSize) : base(path)
        {
            Sprite.Position = new SFML.System.Vector2f(WindowSize.X / 2, WindowSize.Y / 2);
            Sprite.Rotation = 90;
            speed           = initialSpeed;

            this.WindowSize = WindowSize;
        }
Exemple #13
0
        private void SetTexts(SFML.System.Vector2f WindowSize)
        {
            ListOfMenuOptions.ForEach(el => ListOfMenuTexts.Add(new Text(el, Font)));

            for (int i = 0; i < ListOfMenuTexts.Count(); i++)
            {
                ListOfMenuTexts[i].Position = new SFML.System.Vector2f(WindowSize.X / 2 - ListOfMenuTexts[i].GetGlobalBounds().Width / 2, WindowSize.Y / ListOfMenuTexts.Count() + i * 100 - 30);
            }
        }
Exemple #14
0
        public override void Init()
        {
            Moving = true;
            rdn    = new Random();
            BossCount++;
            if (BossCount > 5)
            {
                BossCount = 1;
            }
            s.Start();
            Bosses.Add("Boss1", new Texture("Resources/Boss1.png"));
            Bosses.Add("Boss2", new Texture("Resources/Boss2.png"));
            Bosses.Add("Boss3", new Texture("Resources/Boss3.png"));
            Bosses.Add("Boss4", new Texture("Resources/Boss4.png"));
            Bosses.Add("Boss5", new Texture("Resources/Boss5.png"));

            Scale = new SFML.System.Vector2f(0.2f, 0.2f);
            Count++;
            switch (BossCount)
            {
            case 1:
            {
                this.Texture = new Texture(Bosses["Boss1"]);
                break;
            }

            case 2:
            {
                this.Texture = new Texture(Bosses["Boss2"]);
                break;
            }

            case 3:
            {
                this.Texture = new Texture(Bosses["Boss3"]);
                break;
            }

            case 4:
            {
                this.Texture = new Texture(Bosses["Boss4"]);
                break;
            }

            case 5:
            {
                this.Texture = new Texture(Bosses["Boss5"]);
                break;
            }

            default:
                break;
            }
            Origin    = new SFML.System.Vector2f(Texture.Size.X / 2, Texture.Size.Y / 2);
            Collided += Boss_Collided;
        }
Exemple #15
0
        public static double DistanceTo(this SFML.System.Vector2f obj, SFML.System.Vector2f other)
        {
            var x = other.X - obj.X;

            x *= x;
            var y = other.Y - obj.Y;

            y *= y;
            return(Math.Sqrt(x + y));
        }
        static bool isInside(double x, double y, SFML.System.Vector2f v2f, double radius)
        {
            double distance = Math.Pow(Math.Pow(v2f.X - x, 2) + Math.Pow(v2f.Y - y, 2), 0.5);

            if (distance > radius)
            {
                return(false);
            }
            return(true);
        }
 //TODO can't compare float values..
 public void MoveEdges(SFML.System.Vector2f v2f, SFML.System.Vector2f v2ff)
 {
     for (uint i = 0; i < e.VertexCount; i++)
     {
         if (e[i].Position == v2f)
         {
             e[i] = new Vertex(v2ff);
         }
     }
 }
Exemple #18
0
 public Player()
 {
     //    texture = new SFML.Graphics.Texture() do uzupełnienia
     gravityForce   = new SFML.System.Vector2f(0f, 0.00005f);
     texture        = new SFML.Graphics.Texture(800, 800);
     shape          = new SFML.Graphics.CircleShape(30f);
     shape.Position = new SFML.System.Vector2f(20, 400);
     // shape.Texture = texture;
     shape.FillColor = SFML.Graphics.Color.Cyan;
 }
Exemple #19
0
 public override void Init()
 {
     s.Start();
     cooldown  = 1000;
     Moving    = true;
     Texture   = new SFML.Graphics.Texture("Resources/Final.png");
     Scale     = new SFML.System.Vector2f(0.1f, 0.1f);
     Position  = new SFML.System.Vector2f(0, 0);
     Origin    = new SFML.System.Vector2f(Texture.Size.X / 2, Texture.Size.Y / 2);
     Collided += FinalBoss_Collided;
 }
Exemple #20
0
 public Bullets(SFML.System.Vector2f shootAngle)
 {
     this.bulletShape = new SFML.Graphics.CircleShape(5)
     {
         FillColor = SFML.Graphics.Color.White
     };
     this.thrown               = false;
     this.Position             = new SFML.System.Vector2f(shootAngle.X + 35, shootAngle.Y - 20);
     this.bulletShape.Position = this.Position;
     this.startingPosition     = this.Position;
     this.done = false;
 }
Exemple #21
0
        public Button(string textToShow, SFML.Graphics.Font font, SFML.System.Vector2f position, SFML.Graphics.Texture normal, SFML.Graphics.Texture highlighted, SFML.Graphics.Texture pressed)
        {
            text     = textToShow;
            sfmlText = new SFML.Graphics.Text(text, font);
            sfmlText.OutlineThickness = 1;
            sfmlText.OutlineColor     = SFML.Graphics.Color.Black;
            normalTXT      = normal;
            highlightedTXT = highlighted;
            pressedTXT     = pressed;

            sprite          = new SFML.Graphics.Sprite(normalTXT);
            sprite.Position = position;
        }
        /// <summary>
        /// Check if a point is inside a window.
        /// </summary>
        /// <param name="point">Point to test.</param>
        /// <returns>True if the point is in a window.</returns>
        public bool PointOnWindow(SFML.System.Vector2f point)
        {
            bool result = false;

            foreach (var window in windows)
            {
                if (window.GetBounds().Contains(point) && window.IsOpen)
                {
                    result = true;
                }
            }
            return(result);
        }
Exemple #23
0
        public void Append2(SFML.System.Vector2f x, SFML.System.Vector2f y, float number)
        {
            Append(new Vertex(y));
            Append(new Vertex(x));

            Text tmp = new Text(number.ToString("000"), f, 20);

            tmp.Color    = Color.White;
            tmp.Position = new SFML.System.Vector2f((x.X + y.X) / 2, (x.Y + y.Y) / 2);
            FloatRect ftmp = tmp.GetLocalBounds();

            tmp.Origin = tmp.Origin + new SFML.System.Vector2f(ftmp.Width / 2 + ftmp.Left, ftmp.Height / 2 + ftmp.Top);
            tList.Add(tmp);
        }
Exemple #24
0
 public override void Init()
 {
     AttackType = 1;
     Texture    = Resources.Texture[1];
     PlayerLife = 10;
     life       = PlayerLife;
     Program.window.KeyPressed  += Window_KeyPressed;
     Program.window.KeyReleased += Window_KeyReleased;
     Position   = new SFML.System.Vector2f(Program.window.Size.X / 2, Program.window.Size.Y - 60);
     this.Scale = new SFML.System.Vector2f(0.5f, 0.5f);
     Origin     = new SFML.System.Vector2f(Texture.Size.X / 2, Texture.Size.Y / 2);
     lastShoot  = Environment.TickCount;
     Collided  += Player_Collided;
 }
Exemple #25
0
        public void DrawTexture(SFML.Graphics.Texture image, int x, int y, int rect_x, int rect_y, int rect_width, int rect_height, int width, int height, bool selected, int Transparency, bool fliph = false, bool flipv = false, int rotation = 0, Color?color = null)
        {
            if (!IsObjectOnScreen(x, y, width, height) || image == null)
            {
                return;
            }

            var zoom = GetZoom();

            int real_x = (int)(x * zoom);
            int real_y = (int)(y * zoom);

            SFML.System.Vector2f size     = new SFML.System.Vector2f(rect_width, rect_height);
            SFML.System.Vector2f center   = new SFML.System.Vector2f(size.X / 2, size.Y / 2);
            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x + center.X, real_y + center.Y);


            var textureRect = new IntRect(rect_x, rect_y, width, height);



            if (fliph || flipv)
            {
                if (fliph)
                {
                    var temp = textureRect.Left;
                    textureRect.Left  = temp + textureRect.Width;
                    textureRect.Width = -textureRect.Width;
                }
                if (flipv)
                {
                    var temp = textureRect.Top;
                    textureRect.Top    = temp + textureRect.Height;
                    textureRect.Height = -textureRect.Height;
                }
            }



            SFML.Graphics.RectangleShape rect = new SFML.Graphics.RectangleShape();
            rect.Position    = position;
            rect.Origin      = center;
            rect.Rotation    = rotation;
            rect.Size        = size;
            rect.Texture     = image;
            rect.FillColor   = GetTransparency(color, Transparency);
            rect.TextureRect = textureRect;
            RenderWindow.Draw(rect);
        }
Exemple #26
0
        public Game(uint x, uint y)
        {
            WindowSize = new SFML.System.Vector2f(x, y);
            RenderWindow window = new RenderWindow(new VideoMode(x, y), "Bacteria", SFML.Window.Styles.Close);

            window.Closed      += new EventHandler(OnClose);
            window.KeyReleased += OnKeyReleased;

            Font = new Font(pathToFont);

            SetBackground();
            SetLevels();

            OpenMenu(window);
        }
Exemple #27
0
        protected void Fill(IntRect tile, int x, int y, int w, int h)
        {
            var tex = new SFML.System.Vector2f[4];
            int wm  = w % tile.Width;
            int hm  = h % tile.Height;

            tex[0] = new SFML.System.Vector2f(tile.Left, tile.Top);
            tex[1] = new SFML.System.Vector2f(tile.Left + tile.Width, tile.Top);
            tex[2] = new SFML.System.Vector2f(tile.Left + tile.Width, tile.Top + tile.Height);
            tex[3] = new SFML.System.Vector2f(tile.Left, tile.Top + tile.Height);

            for (int i = 0; i < Math.Ceiling((float)w / tile.Width); i++)
            {
                for (int j = 0; j < Math.Ceiling((float)h / tile.Height); j++)
                {
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + i * tile.Width, y + j * tile.Height), tex[0]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + (i + 1) * tile.Width, y + j * tile.Height), tex[1]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + (i + 1) * tile.Width, y + (j + 1) * tile.Height), tex[2]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + i * tile.Width, y + (j + 1) * tile.Height), tex[3]));
                }
                if (hm != 0)
                {
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + i * tile.Width, y + h - hm), tex[0]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + (i + 1) * tile.Width, y + h - hm), tex[1]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + (i + 1) * tile.Width, y + h), new SFML.System.Vector2f(tile.Left + tile.Width, tile.Top + hm)));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + i * tile.Width, y + h), new SFML.System.Vector2f(tile.Left, tile.Top + hm)));
                }
            }

            if (wm != 0)
            {
                for (int j = 0; j < Math.Ceiling((float)h / tile.Height); j++)
                {
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w - wm, y + j * tile.Height), tex[0]));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w, y + j * tile.Height), new SFML.System.Vector2f(tile.Left + wm, tile.Top)));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w, y + (j + 1) * tile.Height), new SFML.System.Vector2f(tile.Left + wm, tile.Top + tile.Height)));
                    VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w - wm, y + (j + 1) * tile.Height), tex[3]));
                }
            }

            if (wm != 0 && hm != 0)
            {
                VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w - wm, y + h - hm), tex[0]));
                VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w, y + h - hm), new SFML.System.Vector2f(tile.Left + wm, tile.Top)));
                VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w, y + h), new SFML.System.Vector2f(tile.Left + wm, tile.Top + hm)));
                VertArray.Append(new Vertex(new SFML.System.Vector2f(x + w - wm, y + h), new SFML.System.Vector2f(tile.Left, tile.Top + hm)));
            }
        }
Exemple #28
0
        public void DrawEllipse(int x1, int y1, int radiusX, int radiusY, Color color, float thickness = 1)
        {
            var zoom = GetZoom();

            int   real_x       = (int)(x1 * zoom);
            int   real_y       = (int)(y1 * zoom);
            float real_radiusX = (int)(radiusX * zoom);
            float real_radiusY = (int)(radiusY * zoom);

            SFML.System.Vector2f position = new SFML.System.Vector2f(real_x - real_radiusX, real_y - real_radiusY);
            SFML.System.Vector2f radius   = new SFML.System.Vector2f(real_radiusX, real_radiusY);

            Classes.Rendering.EllipseShape rect = new Classes.Rendering.EllipseShape();
            rect.OutlineThickness = thickness;
            rect.OutlineColor     = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);
            rect.FillColor        = SFML.Graphics.Color.Transparent;
            rect.Position         = position;
            rect.SetRadius(radius);
            RenderWindow.Draw(rect);
        }
Exemple #29
0
        public void DrawLine(int x1, int y1, int x2, int y2, Color color = new Color(), float thickness = 1)
        {
            if (!ArePointsOnScreen(x1, y1, x2, y2))
            {
                return;
            }

            var zoom = GetZoom();

            int real_x1 = (int)(x1 * zoom);
            int real_x2 = (int)(x2 * zoom);
            int real_y1 = (int)(y1 * zoom);
            int real_y2 = (int)(y2 * zoom);

            var point1    = new SFML.System.Vector2f(real_x1, real_y1);
            var point2    = new SFML.System.Vector2f(real_x2, real_y2);
            var sfmlColor = new SFML.Graphics.Color(color.R, color.G, color.B, color.A);

            Classes.Rendering.SelbaWardLine line = new Classes.Rendering.SelbaWardLine(point1, point2, sfmlColor, thickness);
            RenderWindow.Draw(line);
        }
Exemple #30
0
        public override void Update()
        {
            if (delta < 80)
            {
                Position = new SFML.System.Vector2f(300, delta++);
            }
            if (s.ElapsedMilliseconds > 1000)
            {
                s.Restart();
                World.AddObject(new Missile(Position, 90)
                {
                    Speed = 3, Damage = 2, EnemySpawned = true
                });
            }
            if (Life <= 0)

            {
                Destroy();
                Score.score += 100;
            }
            if (Moving)
            {
                Position = new SFML.System.Vector2f(Position.X + speed, Position.Y);
            }
            else
            {
                Position = new SFML.System.Vector2f(Position.X - speed, Position.Y);
            }
            if (Position.X >= 600)
            {
                Moving = false;
            }
            else
            if (Position.X <= 100)
            {
                Moving = true;
            }
        }
        public void Draw(IntRect rect)
        {
            // scale the sprite to fit in the given rectangle.
            Vector2 oldScale=Scale;
            Vector2 oldPosition = base.Position;
            base.Position = new Vector2(rect.Left, rect.Top);
            Scale = new SFML.System.Vector2f( rect.Width / TextureRect.Width, rect.Height / TextureRect.Height );

            if (_renderTarget != null)
                _renderTarget.Draw(this);
            else
                CluwneLib.CurrentRenderTarget.Draw(this);
            {
                CluwneLib.Screen.Display();
                System.Threading.Thread.Sleep(CluwneLib.Debug.RenderingDelay);
            }
            base.Position = oldPosition;
            Scale=oldScale;
        }