public void GetMousePosition(HTMLCanvasElement c, Event e)
        {
            var rect  = (ClientRect)c.GetBoundingClientRect();
            var mouse = (MouseEvent)e;
            var px    = (int)(mouse.ClientX - rect.Left);
            var py    = (int)(mouse.ClientY - rect.Top);

            OnClick((MouseEvent)e, px, py);
        }
Exemple #2
0
        public void GetMousePosition(HTMLCanvasElement c, Event e)
        {
            var rect  = (ClientRect)c.GetBoundingClientRect();
            var mouse = (MouseEvent)e;
            var px    = (int)(mouse.ClientX - rect.Left);
            var py    = (int)(mouse.ClientY - rect.Top);

            var destX = player.PosX + px - camera.camOffsetX;
            var destY = player.PosY + py - camera.camOffsetY;

            if (destX < map.width - player.width && destY < map.height - player.height &&
                destX > 0 + player.width && destY > 0 + player.height)
            {
                player.SetDestination(destX, destY);
            }
        }
Exemple #3
0
 public float GetY(float y) => y - (float)Canvas.GetBoundingClientRect().Top;