Click here to Skip to main content
14,423,178 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello, I am a Searcher in the Postgraduate level at faculty of Information Computing, and my graduation project involves a simulation for a movement of multiple trains, i am trying to stop a point on a specified (x,y), then i want to rotate its heading and change the (angle) of its heading.
i have watched all of this videos on your youtube channel about :
"Basic C# Game Programming Moving Object on the form " here : https://www.youtube.com/watch?v=3eIzmcTe0mg[^]
which illustrates how to control the movement of the point using the KeyDown Event in the .NET, but i want to enter different locations at different times ( it will be stored in a variable and entered by a textbox or whatever ) , so if you please, guide and tell me how to rotate the heading of the point when arrived to a specified (x,y) and also how to stop it on its station (another (x,y)) in the railway network .
and if that is related to "grid networking" ??
------------------
i have found that system.Drawing has a function, which can be overloaded such as :
e.Graphics.RotateTransform(30.0F); , but i found that it is not only rotate the transform, but also changes its location, you can check it by yourself.
------------------
also i tried this method :
----------------
int x_ex = 60, y_ex = 60;
        private void increase_distance(PaintEventArgs e)
        {
            // draw a rectangl  
            e.Graphics.FillRectangle(Brushes.Blue, x_ex, y_ex, 20, 20);
            // increase or decrease it's movement
            x_ex = x_ex + (int)2.5;
            y_ex = y_ex + (int)2.5;
            // try to stop and rotate it 
            if (x_ex == 90)
            {
                 
                 //x_ex = (int)e.Graphics.Transform.RotateAt(30.0F, search on google
                // (RotateTransform method) not only rotate the object but also change the location and its coordinates 
                e.Graphics.RotateTransform(30.0F);
                // you can notice that its color will be changed for a fraction of moment when (x_ex=90)
                e.Graphics.FillRectangle(Brushes.Green, 90, 90, 20, 20);



                //x_ex = 0;
                //y_ex = 0;
                
            }
        }

help me if you please, your help & response already will be appreciated.

Thank you.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100