Zoing! Another fine Canadian product. Alonzo Gariepy 620 Christie St. Toronto, Ontario CANADA M6G 3E5 Here's something I have been thinking about for several weeks. This program simulates a system of rebounding balls. Zoing! I hope you enjoy playing with it as much as I did designing and tuning it. Please include this file in any distribution of the source code! Usage: zoing [ BALLS [ GRAVITY [ LEVITY ] ] ] where 1 <= BALLS <= 7, default 7 0 <= GRAVITY <= 9, default 0 0 <= LEVITY <= 5, default 0 You can run it from the workbench, but you can only get the defaults. Some explanation is necessary. General Description =================== The bouncing balls are all perfectly elastic. This means they don't lose energy when they collide. When the Zoing! window is active the cursor becomes a ball. This ball is infinitely massive and fairly inelastic. This means that other balls cannot impart velocity to the cursor and that collisions with it entail a loss of energy. The window comes up inactive so that the balls do not start to lose energy through cursor collisions. The cursor is inelastic as a convenient means of removing excess energy from the system. The balls can be slowed by performing a "catching" operation with the cursor, but this is difficult especially at high speeds. You may slide the cursor into a ball to create a collison and speed it up. You may vary the number of balls by giving a number between 1 and 7 as the first parameter on the command line. Gravity may be added to the system in the same way. I suggest you try all the values. Gravity of one or two is very pleasing to watch. You will find that the energy of the system will slowly decline under the influence of gravity. Stir it up. Levity is just like gravity except that the system slowly gains energy over time. A levity of one is probably all you will want. The gravitational effect will be the sum of the gravity and levity. With gravitation, there is a higher density of balls toward the bottom of the screen. If you add some levity and park the cursor in the middle of the screen, the energizing of the levity and de-energizing of the cursor will reach an equilibrium based on how high the cursor is from the bottom of the screen. This produces a very nice effect as balls occasionally roll over the top of the cursor or soar way above. If you are clever you can make a ledge with the cursor and the side of the screen to trap balls. You can raise them slowly using the amiga and cursor keys. Suggested Values ================ zoing zoing 3 zoing 7 1 1 zoing 7 2 zoing 4 3 zoing 1 About The Program ================= The best part is that Zoing! uses no floating point variables or calculations. The positions and velocities are represented internally using an integer coordinate system. The collision calculations require no trig functions or square roots and are only limited by the accuracy of the coordinate representation. Accurately including gravity would require the extraction of square roots. I chose a simple fudge. The gravitational field is made up of the gravity and levity parameters. Gravity is applied to the velocity before calculating wall collisions and levity is applied afterwards. The name levity comes from the observation that this post-application tends to slowly increase the energy in the system. I could explain why, but I won't. I was going to add sound effects but I couldn't get a recording of Schostakowitsch's 5th symphony, that was as good as the live performance by the Toronto Symphony last year. I will remember the first movement all my life (and I'm not a flake). It would be nice to add some sound effects. Collisions with the walls should be silent and those with the cursor lower pitched than the ones between balls. The velocity should also modify the pitch and volume. It is truly not worth the work. The accuracy of the simulation should be proportional to the number of simulation steps per frame. You could probably make this greater than 2, but since the number of fraction bits has to stay at 6 (with more than that you get overflow on some of the calculations), you would increase your minimum gravity and lose some nice effects.