Пример #1
0
 public GameObject()
 {
     LocalPosition = Engine.Point.Zero;
     velocity      = Engine.Point.Zero;
     speed         = 0;
     Visible       = true;
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="width">The new width of the ViewPort (PaintualCanvas)</param>
        /// <param name="height">The new height of the ViewPort (PaintualCanvas)</param>
        /// <remarks>Called by PaintualCanvas consequence of a request from Workflow.DrawingBoardSizeRequested event</remarks>
        public void DrawingBoardSizeChanged(int width, int height)
        {
            t_drawingBoardSize = new Engine.Size(width, height);
            t_boardCenterPoint = new Engine.Point(t_drawingBoardSize.Width / 2, t_drawingBoardSize.Height / 2);


            SetOriginToZeroIfNeeded();

            // for first display of image zoomed to fit the viewport, see SetViewPortSize()
        }
Пример #3
0
        public FallowingEnemy(Level level, Engine.Point startPosition)
        {
            this.level         = level;
            this.startPosition = startPosition;
            Path = new Stack <MatrixNode>();

            LoadAnimation(Resources.test, "idle", true, 0.1f);

            this.Reset();
        }
        private void UpdateMousePosition()
        {
            System.Drawing.Point mousePos = Cursor.Position;
            mousePos = _openGLControl.PointToClient(mousePos);

            // Now use our point definition,
            Engine.Point adjustedMousePoint = new Engine.Point();
            adjustedMousePoint.X = (float)mousePos.X - ((float)_parentForm.ClientSize.Width / 2);
            adjustedMousePoint.Y = ((float)_parentForm.ClientSize.Height / 2) - (float)mousePos.Y;
            Position             = adjustedMousePoint;
        }
        private Point GetMousePosition(Vector origin, double width, double height)
        {
            System.Drawing.Point mousePos = Cursor.Position;
            mousePos = _openGLControl.PointToClient(mousePos);

            double x = (double)mousePos.X / ((double)_openGLControl.ClientSize.Width);
            double y = (double)mousePos.Y / ((double)_openGLControl.ClientSize.Height);

            Engine.Point adjustedMousePoint = new Engine.Point();
            adjustedMousePoint.X = (float)Interpolation.Lerp(x, 0, 1, origin.X - (width / 2), origin.X + (width / 2));
            adjustedMousePoint.Y = (float)Interpolation.Lerp(y, 0, 1, origin.Y + (height / 2), origin.Y - (height / 2));
            return(adjustedMousePoint);
        }
Пример #6
0
        public Player(Level level, Engine.Point startPosition)
            : base()
        {
            this.level         = level;
            this.startPosition = startPosition;

            // load all animations
            LoadAnimation(Resources.test, "idle", true, 0.1f); //TODO change path to general

            this.Rectangle = new Rectangle(0, 0, 32, 32);

            Reset();
        }
Пример #7
0
        public void Draw(Graphics graphics, Engine.Point position)
        {
            PointF pos = new PointF(position.X, position.Y);

            graphics.DrawImage(bitmaps[sheetIndex], pos);
        }
Пример #8
0
 public ImagePositionChangedEventArgs(Engine.Point originPoint)
 {
     OriginPoint = originPoint;
 }
Пример #9
0
 public void RepositionImage(double newX, double newY)
 {
     t_originPoint = new Engine.Point((int)newX, (int)newY);
 }
Пример #10
0
 internal bool Intersects(Engine.Point mousePosition)
 {
     return(Intersects(mousePosition.X, mousePosition.Y));
 }
Пример #11
0
        private Point GetMousePosition(Vector origin, double width, double height)
        {
            System.Drawing.Point mousePos = Cursor.Position;
            mousePos = _openGLControl.PointToClient(mousePos);

            double x = (double)mousePos.X / ((double)_openGLControl.ClientSize.Width);
            double y = (double)mousePos.Y / ((double)_openGLControl.ClientSize.Height);

            Engine.Point adjustedMousePoint = new Engine.Point();
            adjustedMousePoint.X = (float)Interpolation.Lerp(x, 0, 1, origin.X - (width / 2), origin.X + (width / 2));
            adjustedMousePoint.Y = (float)Interpolation.Lerp(y, 0, 1, origin.Y + (height / 2),origin.Y - (height / 2));
            return adjustedMousePoint;
        }
Пример #12
0
 public virtual void Reset()
 {
     velocity = Engine.Point.Zero;
 }
Пример #13
0
        private void UpdateMousePosition()
        {
            System.Drawing.Point mousePos = Cursor.Position;
            mousePos = openGLControl.PointToClient(mousePos);

            // Now use our point definition
            Engine.Point adjustedMousePoint = new Engine.Point();
            adjustedMousePoint.X = (float)mousePos.X - ((float)parentForm.ClientSize.Width / 2);
            adjustedMousePoint.Y = ((float)parentForm.ClientSize.Height / 2) - (float)mousePos.Y;

            Position = adjustedMousePoint;
        }
Пример #14
0
        public override void Update(float currentFps)
        {
            Engine.Point previousPosition = LocalPosition;

            if (UserInputController.KeyPressed(Keys.D))
            {
                this.MoveRight();
            }
            if (UserInputController.KeyPressed(Keys.A))
            {
                this.MoveLeft();
            }
            if (UserInputController.KeyPressed(Keys.W))
            {
                this.MoveUp();
            }
            if (UserInputController.KeyPressed(Keys.S))
            {
                this.MoveDown();
            }

            foreach (var item in level.GetChildrens())
            {
                if (item is FallowingEnemy)
                {
                    if (this.BoundingBox.IntersectsWith(item.Rectangle))
                    {
                        this.Die();
                    }
                }

                if (item is Tile)
                {
                    if (this.velocity.X > 0 && Collision.IsTouchingLeft(this.velocity, this.BoundingBox, item))
                    {
                        this.velocity.X = 0;
                    }

                    if (this.velocity.X < 0 && Collision.IsTouchingRight(this.velocity, this.BoundingBox, item))
                    {
                        this.velocity.X = 0;
                    }

                    if (this.velocity.Y < 0 && Collision.IsTouchingBottom(this.velocity, this.BoundingBox, item))
                    {
                        this.velocity.Y = 0;
                    }

                    if (this.velocity.Y > 0 && Collision.IsTouchingTop(this.velocity, this.BoundingBox, item))
                    {
                        this.velocity.Y = 0;
                    }
                }
            }

            base.Update(currentFps);

            if (IsAlive)
            {
                LocalPosition += (velocity * walkingSpeed) * (1 / currentFps);
                velocity       = Engine.Point.Zero;

                this.gun.Update(this.level, this);
            }
        }
Пример #15
0
 void SetOriginToBottomCenter()
 {
     Origin = new Engine.Point(sprite.Width / 2, sprite.Height);
 }