Computer Science Canada

need help in making a diagonal line move back and forth.

Author:  khanguy_99 [ Fri Feb 20, 2004 5:43 pm ]
Post subject:  need help in making a diagonal line move back and forth.

hi guys, i am writing a turing program to represent winshield wipers of a car.
I have made the arms and the wiper blades of the car but how do i make both the arms(along with the wiper blades) rotate back and forth???
Please help.....

Author:  Cervantes [ Fri Feb 20, 2004 6:53 pm ]
Post subject: 

yeah I know its prolly not that efficiant Confused

code:

setscreen ("offscreenonly")
var a : real := 0
var x, y : real
var back : boolean := false
var forth : boolean := true
loop
    if a < 0 then
        forth := true
        back := false
    end if
    if a > 180 then
        a -= 1
        back := true
        forth := false
    end if
    if forth = true then
        a += 1
    end if
    if back = true then
        a -= 1
    end if
    x := 320 + (100 * cosd (a))
    y := 240 + (100 * sind (a))
    drawline (320, 240, round (x), round (y), black)
    View.Update
    drawline (320, 240, round (x), round (y), white)
end loop


credit to shorthair for the forumulas Razz

Author:  Andy [ Fri Feb 20, 2004 6:56 pm ]
Post subject: 

use a process or just have them move in the same loop

Author:  recneps [ Fri Feb 20, 2004 8:38 pm ]
Post subject: 

you could use pic.rotate, make the wipers pics and rotate them over the base of the wiper (part that does not move)


: