### How to move my square to the left..

Having trouble getting my square to move to the left my code and instructions of what i am suppose to do is below. No sure how to move my square or if I am even going in the right direction as to writing code to do so. Note that it is only part of my code ( part 2 of project)

Part 2:

Write a graphical application that draws a square and then moves it.

Get the x and y coordinates for the top left corner of the square from the user using the get_int() member function of cwin. Get the length of a side of the square from the user using get_int() as well. Now draw the square to cwin according to the user input.Ask the user how many units to the left they want to move it using get_int() again. Then move the square, clear the screen, and draw it again.

 ``123456789101112131415161718192021222324252627282930313233`` `````` // Part 2 // /* command output to declare the x,y value and 1 side length of a square through user interaction( Has user input intergers) */ int x_value = cwin.get_int("What is the x_value of the top left of the square?"); int y_value = cwin.get_int("What is the y_value of the top left of the square?"); int side_length = cwin.get_int("Input the length for one side of the square:"); /* Data type for the 4 corners of the square */ Point e; Point f; Point g; Point i; /* Lines to create square(connects lines using points of square from information user inputs) */ Line t(e,i); Line n(e,f); Line t1(f,g); Line n1(i,g); /* command to connect lines to form square */ cwin << h << v << h1 << v1; /* allow user to input how many units for square to move to the left */ int shift_left = cwin.get_int("How many units would you like to move the square to the left?"); t.move(-5,5); n.move(-5,-5); t1.move(-5,-5); n1.move(-5,-5); cwin << t << n << t1 << n1; ``````

Last edited on
you didn't clear the screen before re-drawing, did you? and do the new lines form a square after t being moved up instead of down like the others?
after square is drawn through user input the screen is not cleared square remains on screen to be moved through user input. I did not clear because
I was not suppose to till after I get square to move then clear and redraw square. no new lines show up at all. square doesn't even budge. only thing that moves is the point on the screen
Last edited on
Topic archived. No new replies allowed.