Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Next I made a function to insert balls into my ramp machine, called ramp_animate. This function takes three parameters: the list of ramp shapes from earlier, a frame number, and the name of the window it will draw the picture in. When I ultimately call this function to draw my ball factory, do so in a for loop which calls ramp_animate for 100 consecutive frames, and each frame produces the next step in the animation. The ramp_animate function works like this: first it takes every element in the shapes list after the first two ( the ramps) and moves them relative to their current position using a set of if statements. Then ramp_animate produces draws two balls at the starting locations, the top of the first ramp and the bottom of the 2nd, and adds them to the list of shapes. Once the number of balls hits a certain point the function produces no more which I control with an if statement.

So ramp_animate runs something like this: it starts off trying to move the third shape on the list and all shapes thereafter, finding none it moves on a draws a pair of balls at the starting locations. For the next frame it runs again, this time moving that pair of balls and then drawing another pair. This continues until there are 11 balls at various places on the ramps. For the next frame it moves the first balls it created, now at the bottom of ramp one an the top of ramp 2, back to their starting locations, thus recycling the balls so the factory runs ad infinutum. The function knows when to move the ball back to its starting location, as opposed to moving it further up or down it's ramp, with an if statement conditional on the ball's location.