Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 windshield wipers
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fab42




PostPosted: Wed Feb 25, 2004 7:22 pm   Post subject: windshield wipers

this is what i got so far
how do i get the lines to move together in a curve and when i wipe the dots how do i keep making it rain while its still wiping.
i'm not sure how to move the lines together this is what i tryed

var x, y, c : int
for i : 1 .. 1500
randint (x, 0, maxx)
randint (y, 0, maxy)
randint (c, 0, maxcolor)
drawdot (x, y, c)
end for
var t := 45
var reply : string (1)
var arm := 250
var d := 379
var e := 378
var w := 100
var p := 260
var px, py : real
px := 200 + arm * cosd (t)
py := arm * sind (t)
locate (12, 10)
put "Press any key to start ..." ..
locate (12, 55)
put "then press a key to stop" ..
drawline (200, 0, round (px), round (py), black)
drawfillbox (379, 100, 378, 260, black)
getch (reply)
loop
for i : 1 .. 90
drawfillbox (d, w, e, p, black)
delay (50)
drawfillbox (d, w, e, p, white)
d -= 2
e -= 2
drawline (200, 0, round (px), round (py), black)
delay (50)
drawline (200, 0, round (px), round (py), white)
t += 1
px := 200 + arm * cosd (t)
py := arm * sind (t)
end for
for i : 1 .. 90
drawline (200, 0, round (px), round (py), black)
delay (50)
drawline (200, 0, round (px), round (py), white)
t -= 1
px := 200 + arm * cosd (t)
py := arm * sind (t)
end for
end loop
Sponsor
Sponsor
Sponsor
sponsor
jonos




PostPosted: Wed Feb 25, 2004 8:11 pm   Post subject: (No subject)

this must be a project or something because i have seen this before. search around this forum (or use the search) and you will find it, it has the source.

anyways to have them move at the same time, you make both of the mo0vements in the same loop. im not quite sure what you mean by all what you said.
Cervantes




PostPosted: Thu Feb 26, 2004 5:23 pm   Post subject: (No subject)

There are two ways in which you can do good graphics. Both use View.Update

1.) clear the screen then redraw everything
2.) draw the object, view.update, delay, then draw the same object only in the background colour

For this problem I suggest going with the first option.


Here's a simple bit of code of how I would make winsheild wipers.

code:

var x, y, c : int
for i : 1 .. 1500
    randint (x, 0, maxx)
    randint (y, 0, maxy)
    randint (c, 0, maxcolor)
    drawdot (x, y, c)
end for
var rain : int := Pic.New (0, 0, maxx, maxy)
var px1, py1, px2, py2 : real
var armlegnth : int := 150
var t : int := 45
var forth : boolean := true
var back : boolean := false
setscreen ("offscreenonly")
loop
    cls
    if forth = true then
        t += 1
    end if
    if back = true then
        t -= 1
    end if
    if t > 180 then
        forth := false
        back := true
    end if
    if t < 0 then
        back := false
        forth := true
    end if
    px1 := 200 + armlegnth * cosd (t)
    py1 := armlegnth * sind (t)
    px2 := maxx - 200 + armlegnth * cosd (t)
    py2 := armlegnth * sind (t)
    Pic.Draw (rain, 0, 0, picCopy)
    drawline (200, 0, round (px1), round (py1), black)
    drawline (maxx - 200, 0, round (px2), round (py2), black)
    View.Update
    delay (5)
end loop
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: