How to move my square to the left..

Apr 20, 2013 at 9:38am
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.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
	// 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 Apr 20, 2013 at 9:43am
Apr 20, 2013 at 10:03am
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?
Apr 20, 2013 at 10:07am
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 Apr 20, 2013 at 10:07am
Topic archived. No new replies allowed.