Windmill Is a Quick and Dirty zx81 Animation


A simple
[ZX81]

Still Celebrating Programing, Elsewhere!

Iíve paused updating this site to focus instead on my primary domain over at https://www.reids4fun.com. You can still read what crazy program Iíve published this month. Even better, read a few other articles!

Windmill, ZX81 screen shot, by Steven Reid, 1985There are a ton of windmills in Idaho. Mostly big ones for power, but you see a few smaller ones used for irrigation and wells. But, when I wrote this month’s programs I don’t remember any around where I lived in Indiana. No matter. I still wrote a simple windmill animation, and today is the day to share it.

Prep work.
Although planning to share another program, as I started to type it in I had this feeling I already had. After a quick save and a search of my hard drive, I soon discovered I had. Yet, to my surprise, I found not one, but a dozen more programs.

Going through this stash from ’98, I realized I'd meant them for my original ZX81 site. Not only were there programs, but I’d printed screenshots and listings. None, of course, found their way to my site. Heck, some I’d even typed in again. Oops. The cool part, though, is I now have a few more programs to share.

Windmill power.
As for windmill itself, the animation is straight forward. The program starts by asking you to enter in a speed and duration. In then, the program uses them to animate two blades, given an illusion the windmill is moving.

Also, there is a power turbine that rotates along with the blades. The original idea was to show dots of electricity flowing, but I didn’t add it. I still think it would have been a nice feature, but otherwise looks fine.

To be honest, the effect works better than I expected. The two animations, as simple as they are, are pleasing to watch. The blades have a bit of a lag to them that adds a bit to the effect. Although, I find the faster speeds look better.

Problems and fixes.
Yet, although the animation works, as does duration, the speed doesn’t. When you enter it in, the program uses it in a FOR loop to slow down the animation. The problem, though, is the formula doesn’t work. Here is the original version.

 130 LET S=S-(S-(SGN S*20))+
(S=1 OR S=20)

To be honest, the math is broke. No matter what you enter the answer is 20, except if you enter 1 or 20. In that case, you get 21. Of course, if the number doesn’t change, neither does the animation. I'm sure I tested it, but must not of bothered to dig deeper once I found it worked.

Sure, I could have left the original version, but it bugged me having a broken program. It is already pretty short, so leaving such an obvious bug in it was problematic. Time for a fix.

 130 LET S=(20-S)*2

In this version, the larger the number is, the smaller the delay. Perfect. This is exactly what I wanted. Now, if you enter in a speed it will change the rotation rate of the blades. To widen the difference between speeds, I multiplied the result by two. Not required, I found it worked best while testing.

Future improvements.
The animation is nice, but I could have done much better. Looking at what windmills look like today, I wish I’d made the blades longer and reduced the width of the base. Plus, that turbine doesn’t make sense. You can store the power generated from the blades without an intervening system.

But, this was 1985. Not having the references I do today, I can forgive my vision. Yet, I’m confused by the interactive nature of the program. If I were to change something, it would be how you interact with the Windmill.

First, I’d remove the the duration. Having a set time for the animation to run is silly and unnecessary. The abrupt ending to the animation is jarring. Removing it would look much better.

Second, I could have removed the INPUT for the speed. Instead, I could use an INKEY$ command to let the user speed up, or slow down the speed. Doing so makes the program more interactive. And, married with the above change, would streamline the look and feel of the program.

Removing the INPUT statements would provide one other benefit. Although I offer a range to enter, I don’t test that the user stayed within those bounds. Changing the program as noted above would remove the need to do so.

To be honest, the program still works well enough. The changes offered would make it better, they aren’t required. Yet, if you decide to try them, I’d sure like to see the result.

Originally published at www.reids4fun.com on October 30, 2017.



Comments on this article:

No comments so far.

Write a comment:

Type The Letters You See.
[captcha image][captcha image][captcha image][captcha image][captcha image][captcha image]
not case sensitive