Computer Science Canada Car help |
Author: | mikeelio [ Sun Dec 08, 2013 2:27 pm ] |
Post subject: | Car help |
I found how to make a car on turing and i need help on how to make it automatically move this is the example code i used to make my own but plz help how to make it look like its traveling across the screen ive been at this for 2 days now plz use this example i used to make my own car to help make the movement drawline (0, 20, 0, 40, 7) %back of the car drawline (0, 40, 40, 40, 7) drawline (40, 40, 60, 60, 7) drawline (60, 60, 120, 60, 7) drawline (120, 60, 140, 40, 7) drawline (140, 40, 180, 40, 7) drawline (180, 40, 180, 20, 7) drawline (180, 20, 140, 20, 7) drawoval (120, 20, 20, 20, 7) %front tire drawline (100, 20, 80, 20, 7) drawoval (60, 20, 20, 20, 7) %back tire drawline (40, 20, 0, 20, 7) drawfill (110, 50, 40, 7) %fills the car drawfill (120, 20, 7, 7) %fills front tire drawfill (60, 20, 7, 7) %fills back tire drawfilloval (120, 20, 10, 10, 0) %front tire inner ring drawfilloval (60, 20, 10, 10, 0) %back tire inner ring %%%mirror drawline (55, 45, 65, 55, 7) drawline (65, 55, 115, 55, 7) drawline (115, 55, 125, 45, 7) drawline (125, 45, 55, 45, 7) drawfill (90, 52, 54, 7) %fills the mirror |
Author: | Zren [ Sun Dec 08, 2013 2:49 pm ] | ||||||
Post subject: | RE:Car help | ||||||
Let's simplify things first. How do you get a single circle to animate from left to right across the screen? You draw it in one position, clear the screen then draw it in another position. Example: Stop motion animation. With programming though, we can simplify things, but we'll get to that. Now before you try to draw each frame like so (This is WRONG WAY to do it):
Now, to do this for a compicated picture would be very aggrevating and take quite a while. You might notice a pattern though, with the first parameter in the Draw.Oval procedure. You could replace those numbers with a variable and use a loop. A for loop to be precise in this case, as only the x coordinate is changing for each frame. Eg:
Now it's just a matter of making the circle more complicated. If you've learnt about procedures and passing them arguments, I suggest doing something like so:
|
Author: | mikeelio [ Wed Dec 11, 2013 11:33 am ] |
Post subject: | Re: Car help |
Thx |