A
A
ALmA113_032020-11-30 22:45:32
C++ / C#
ALmA113_03, 2020-11-30 22:45:32

Why does the drawing stretch and not move?

Hello. The essence of the program is to draw the cosine and sine so that the arrows can move the drawing, that is, the norm moves up and down, but it does not move it to the sides, but stretches it. You can see it on the screenshots: 5fc54ba1cbb29041859933.png5fc54ba6bb8ea621528750.png


My button code:

if (Keyboard.IsKeyPressed(Keyboard.Key.Left))
                {
                    lambda--;
                    window.Clear();
                    window.Draw(GetVertexArray(50, y, lambda));
                    window.Draw(GetVertexArraySin(50, y, lambda));
                    window.Display();
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.Right))
                {
                    lambda++;
                    window.Clear();
                    window.Draw(GetVertexArray(50, y, lambda));
                    window.Draw(GetVertexArraySin(50, y, lambda));
                    window.Display();
                }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Codebaker, 2020-11-30
@Codebaker

Well, probably because you are changing the lambda, but it would be worth changing some variable x and rewriting the code a little to this:

x--; // ну и соотвественно x++ в альтернативном случае
                    window.Draw(x + GetVertexArray(50, y, lambda));
                    window.Draw(x + GetVertexArraySin(50, y, lambda));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question