Computer Science Canada

I need some help to crash cars...

Author:  CrazyTiger [ Tue May 08, 2007 8:40 am ]
Post subject:  I need some help to crash cars...

Can someone help me fix/edit my program so that the two cars can crash into each other at the center of the screen?
Pls help, i'm stuck!

code:
var y : int

for i : 0 .. maxx
    y := maxy - i

    drawfillbox (i - 30, 250, i + 80, 200, 5)
    drawfilloval (i, 200, 15, 15, 255)
    drawfilloval (i + 50, 200, 15, 15, 255)

    delay (15)

    drawfillbox (i - 30, 250, i + 80, 200, 0)
    drawfilloval (i, 200, 15, 15, 0)
    drawfilloval (i + 50, 200, 15, 15, 0)

    drawfillbox (y - 30, 250, y + 80, 200, 5)
    drawfilloval (y, 200, 15, 15, 255)
    drawfilloval (y + 50, 200, 15, 15, 255)

    delay (5)

    drawfillbox (y - 30, 250, y + 80, 200, 0)
    drawfilloval (y, 200, 15, 15, 0)
    drawfilloval (y + 50, 200, 15, 15, 0)
end for


I really need to know who to change the above program to get the two cars coming from opposite directions and crashing in the middle.

Author:  Cervantes [ Tue May 08, 2007 6:58 pm ]
Post subject:  RE:I need some help to crash cars...

There are a variety of ways of doing this. The easiest would be to just make your for loop step for i from 1 to half the width of the screen (you can incriment by more than 1 at a time, if you feel like speeding it up). Then draw one car at i, and the other at maxx - i. Then when that for loop is done, draw some crashing animation.


: