box moving across screen help
Author |
Message |
paintking
|
Posted: Tue Nov 06, 2007 1:11 pm Post subject: box moving across screen help |
|
|
hey i need help making my box move across the screen and then when it gets to the end of the screen it needs to come back to the starting location altho i have no clue how to do that can any one help please this is what i have so far
code: | var box1_x1, box1_y1, box1_x2, box1_y2 : int
var box2_x1, box2_y1, box2_x2, box2_y2 : int
setscreen ("graphics: 500;300")
box1_x1 := 100
box1_y1 := 100
box1_x2 := 200
box1_y2 := 200
locate (18,40)
box2_x1 :=100
box2_y1 :=100
box2_x2 :=300
box2_y2 :=200
loop
cls
drawbox (box1_x1, box1_y1, box1_x2, box1_y2, 9)
delay (20)
box1_x1 += 1
box1_x2 += 1
end loop
|
thanx for the help if i get any |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
HeavenAgain

|
Posted: Tue Nov 06, 2007 3:21 pm Post subject: RE:box moving across screen help |
|
|
seems like everyone is doing this assignment, well stop and think for a second there. if (keyword) let say the box x reaches the maxx (keyword), instead of adding 1, you should subtract 1, correct? so use an if statement. |
|
|
|
|
 |
CodeMonkey2000
|
Posted: Tue Nov 06, 2007 4:00 pm Post subject: RE:box moving across screen help |
|
|
Before you make a new topic,please look at the first few threads, and make sure that you read through the Turing Walkthrough. |
|
|
|
|
 |
Zampano

|
Posted: Tue Nov 06, 2007 4:48 pm Post subject: Re: box moving across screen help |
|
|
Don't use a separate variable for each coordinate in the location of the box. Instead have one corner be related to the others by a small addition statement.
Also, use an increment to change the location of the x and y of the box, when the box reaches the end of the screen, an if will make the increment the negative of what it already is, thereby reversing the motion of the box.
EDIT: The posters above are correct, simple problems like these are done to death. Is there any way we could have a visible link to the complete tutorial on the home page? |
|
|
|
|
 |
|
|