0
\$\begingroup\$

Okay I'm trying to find a way to not have to hard code in my values for the x and y coordinates. so far I have hard coded these in when you press certain numbers on num-pad it'll move the camera to that area.

        if(Keyboard.GetState().IsKeyDown(Keys.NumPad1))
        {
            x = 100;
                y = 100;
            spritePosition = new Vector2(x,y);
        }
        if (Keyboard.GetState().IsKeyDown(Keys.NumPad2))
        {
            x = 200;
            y = 200;
            spritePosition = new Vector2(x, y);
        }
        if (Keyboard.GetState().IsKeyDown(Keys.NumPad3))
        {
            x = 300;
            y = 300;
            spritePosition = new Vector2(x, y);
        }

What I'm trying to accomplish is to make a textbox or to be able to input x and y coordinates whilst the application is running

        if (Keyboard.GetState().IsKeyDown(Keys.Enter))
        {
            x = 100;
            y = 100;
            spritePosition = new Vector2(x, y);
        }

so have something like this but allow the user to change the coordinate values whilst the application is running, when the user presses Enter, of course Console.WriteLine and Readline do not work, so I was wondering how to implement this sort of changes to make it work.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

I think what you want to do is to change variables faster while the game is running, so that way you don't have to restart the game from time to time again.
This can be done with a breakpoint. If you put a breakpoint inside the draw method, you're able to change the variables while the game is on break. If you disable the breakpoint and press continue again, then the game will continue with the newly inserted variables. This is what I've use as well for debugging/testing.

Though, it's also possible that you're basically asking how to use text/textbox input. In that case, I've found this answer from Stackoverflow, hopefully that'll be relevant to you.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .