Any better ways?

08/27/2012 08:35 I don't have a username#1
I know this is not CO related, but since there is quite a few c# programmers here and people actually speak English here then I thought I'd ask here.

Is there any better ways to calculate a movement for mouseclick?

Like when I click a spot the player should move there?

My code just seem to have so much for so little.

Current code:
Code:
        /// <summary>
        /// This method is called whenever a mouse button is lifted.
        /// </summary>
        /// <param name="e">The MouseButtonEventArgs.</param>
        public static void OnMouseUp(SdlDotNet.Input.MouseButtonEventArgs e)
        {
            if (e.X >= Program.GameClient.ScreenX && e.Y >= Program.GameClient.ScreenY)
            {
                Program.GameClient.movedX = (400);
                Program.GameClient.movedY = (300);
                MouseSyncEvent.runEvent = true;

                MouseSyncEvent.Add(e.Position, () =>
                {
                    Movement_DR(e.Position);
                }, 10);
            }
            else if (e.X <= Program.GameClient.ScreenX && e.Y >= Program.GameClient.ScreenY)
            {
                Program.GameClient.movedX = (400);
                Program.GameClient.movedY = (300);
                MouseSyncEvent.runEvent = true;

                MouseSyncEvent.Add(e.Position, () =>
                {
                    Movement_DL(e.Position);
                }, 10);
            }
            else if (e.X >= Program.GameClient.ScreenX && e.Y <= Program.GameClient.ScreenY)
            {
                Program.GameClient.movedX = (400);
                Program.GameClient.movedY = (300);
                MouseSyncEvent.runEvent = true;

                MouseSyncEvent.Add(e.Position, () =>
                {
                    Movement_UR(e.Position);
                }, 10);
            }
            else if (e.X <= Program.GameClient.ScreenX && e.Y <= Program.GameClient.ScreenY)
            {
                Program.GameClient.movedX = (400);
                Program.GameClient.movedY = (300);
                MouseSyncEvent.runEvent = true;

                MouseSyncEvent.Add(e.Position, () =>
                {
                    Movement_UL(e.Position);
                }, 10);
            }
        }

        private static void Movement_DR(Point point)
        {
            if (Program.GameClient.movedX > 0 && Program.GameClient.movedY > 0)
            {
                Graphics.GraphicsLabel.ClearPermLabels();
                Graphics.GraphicsLabel.Create("[" + Program.GameClient.movedX + ", " + point.X + "], [" + Program.GameClient.movedY + ", " + point.Y + "]", Color.White, "Verdana", 18, 0, new Point(5, 5), true);

                if (Program.GameClient.movedX != point.X && Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(2);
                    Mapping.GameMap.SwitchMapPosition(1);
                }
                else if (Program.GameClient.movedX != point.X)
                {
                    Mapping.GameMap.SwitchMapPosition(2);
                }
                else if (Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(1);
                }
                else if (Program.GameClient.movedX == point.X)
                {
                    Program.GameClient.movedX = 0;
                }
                else if (Program.GameClient.movedY == point.Y)
                {
                    Program.GameClient.movedY = 0;
                }
            }
            else
                MouseSyncEvent.Clear();
        }

        private static void Movement_DL(Point point)
        {
            if (Program.GameClient.movedX > 0 && Program.GameClient.movedY > 0)
            {
                Graphics.GraphicsLabel.ClearPermLabels();
                Graphics.GraphicsLabel.Create("[" + Program.GameClient.movedX + ", " + point.X + "], [" + Program.GameClient.movedY + ", " + point.Y + "]", Color.White, "Verdana", 18, 0, new Point(5, 5), true);

                if (Program.GameClient.movedX != point.X && Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(3);
                    Mapping.GameMap.SwitchMapPosition(1);
                }
                else if (Program.GameClient.movedX != point.X)
                {
                    Mapping.GameMap.SwitchMapPosition(3);
                }
                else if (Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(1);
                }
                else if (Program.GameClient.movedX == point.X)
                {
                    Program.GameClient.movedX = 0;
                }
                else if (Program.GameClient.movedY == point.Y)
                {
                    Program.GameClient.movedY = 0;
                }
            }
            else
                MouseSyncEvent.Clear();
        }

        private static void Movement_UR(Point point)
        {
            if (Program.GameClient.movedX > 0 && Program.GameClient.movedY > 0)
            {
                Graphics.GraphicsLabel.ClearPermLabels();
                Graphics.GraphicsLabel.Create("[" + Program.GameClient.movedX + ", " + point.X + "], [" + Program.GameClient.movedY + ", " + point.Y + "]", Color.White, "Verdana", 18, 0, new Point(5, 5), true);

                if (Program.GameClient.movedX != point.X && Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(2);
                    Mapping.GameMap.SwitchMapPosition(0);
                }
                else if (Program.GameClient.movedX != point.X)
                {
                    Mapping.GameMap.SwitchMapPosition(2);
                }
                else if (Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(0);
                }
                else if (Program.GameClient.movedX == point.X)
                {
                    Program.GameClient.movedX = 0;
                }
                else if (Program.GameClient.movedY == point.Y)
                {
                    Program.GameClient.movedY = 0;
                }
            }
            else
                MouseSyncEvent.Clear();
        }

        private static void Movement_UL(Point point)
        {
            if (Program.GameClient.movedX > 0 && Program.GameClient.movedY > 0)
            {
                Graphics.GraphicsLabel.ClearPermLabels();
                Graphics.GraphicsLabel.Create("[" + Program.GameClient.movedX + ", " + point.X + "], [" + Program.GameClient.movedY + ", " + point.Y + "]", Color.White, "Verdana", 18, 0, new Point(5, 5), true);

                if (Program.GameClient.movedX != point.X && Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(3);
                    Mapping.GameMap.SwitchMapPosition(0);
                }
                else if (Program.GameClient.movedX != point.X)
                {
                    Mapping.GameMap.SwitchMapPosition(3);
                }
                else if (Program.GameClient.movedY != point.Y)
                {
                    Mapping.GameMap.SwitchMapPosition(0);
                }
                else if (Program.GameClient.movedX == point.X)
                {
                    Program.GameClient.movedX = 0;
                }
                else if (Program.GameClient.movedY == point.Y)
                {
                    Program.GameClient.movedY = 0;
                }
            }
            else
                MouseSyncEvent.Clear();
        }
But as you can see it works.