Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Proposed enhancements to CMM2 Turtle Graphics
Author | Message | ||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
I have been experimenting with Turtle Graphics on the CMM2. It reminds me of learning UCSD Pascal on the Terak 8510 as a teenager. They had them at the University. Later on they replaced them with Apple][e computers and I bought one as "surplus" I am noticing that MMBasic seems to have some odd limitations as compared to other implementations. I keep needing to find work-arounds for these limitations. Based on this experience and looking at some examples online, I would like to suggest the following enhancements. I believe these modest enhancements can be made without "breaking" any existing functionality. "TURTLE TURN RIGHT" and "TURTLE TURN LEFT" should accept floating point angles as their parameters. "TURTLE HEADING" already accepts a floating point angle as it's parameter. It appears that position and heading are tracked as float (type TFLOAT) internally in MMBasic. There is no reason to restrict the heading to an integer. One degree of resolution is really not sufficient. In fact, everything should be able to track position and heading as floating point and only need to be integers when plotted to the screen. The following seem to have limits of 0-360 for the angle parameter: TURTLE HEADING TURTLE TURN LEFT TURTLE TURN RIGHT While it may seem conceptually odd to "Turn Right" by 734.2 degrees, In principle there is no reason that this shouldn't work. We are using a computer after all! This makes more sense if the angle is calculated rather than input as a constant. I propose removing the limits to the parameter for these functions. There is really no reason that these commands shouldn't accept negative angles as well (see below) Similarly: TURTLE FORWARD TURTLE BACKWARD Are limited to 0-MM.HRES as the number of pixels to move. This means you can't even move diagonally across the full screen in one move. Again it might seem odd to move forward by -327 pixels but why shouldn't it work? I would potentially like the following sub-commands added. Before anyone freaks out about the limit on new keywords, "TURTLE" is the only tokenized keyword used. The sub-commands are implemented as options to the "TURTLE" command. TURTLE GO n (Move is already used) This would move forward if n is positive and backward if n is negative. Note that this would be somewhat redundant if the "Turtle Forward" command would accept a negative number. It might be conceptually easier for beginners not to use TURTLE FORWARD 0 - Distance for example. TURTLE TURN deg This would make a relative change to the heading right (clockwise) if deg is positive and left (counter-clockwise) if deg is negative. Again this is potentially redundant if TURTLE TURN RIGHT would accept a negative angle. Regards, -Carl |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Oh, and TURTLE PEN WIDTH would be nice too, but that's likely a little more involved than the changes outlined above. -Carl |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8578 |
Try the latest beta V5.05.05b4 Floats for turns and any angle for turns and heading negative numbers for forward and backward and range increased to +/- SQRT(MM.HRES^2 + MM.VRES^2) Edited 2020-08-04 01:32 by matherp |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Thanks Peter, I'll flash the latest Beta version and check it out! -Carl |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
I updated to Beta V5.05.05b4. The good news is that all my little demos still work fine, so nothing got broken as far as I have tested. The TURTLE TURN RIGHT and TURTLE TURN LEFT are now working great with floating point angles and negative angles. The TURTLE FORWARD and TURTLE BACKWARD are still giving an error message that the valid range is 1-1000 (Mode 1,8) when passing a negative number. No rush on this, I can wait for the next Beta to test it. Edited 2020-08-04 06:47 by Sasquatch -Carl |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Also, I can't seem to get the TURTLE FILL commands to work properly? At first I thought It was just triangles that didn't work, but it doesn't seem to work as expected on n sided polygons either. I could be missing something? It almost seems like the coordinates for the fill algorithm are mirrored around screen center? I am using V5.05.05b4 Try this sample: ' Test for Filling Turtle Polygons Mode 1,8 ' Try a Square Turtle Reset Turtle Begin Fill For X = 1 to 4 Turtle Forward 100 Turtle Turn Right 90 Next X Turtle End Fill Pause(10000) ' How 'Bout an Octogon Turtle Reset Turtle Begin Fill For X = 1 to 8 Turtle Forward 100 Turtle Turn Right 45 Next X Turtle End Fill Pause(10000) ' Or a 36-o-gon Turtle Reset Turtle Begin Fill For X = 1 to 36 Turtle Forward 20 Turtle Turn Right 10 Next X Turtle End Fill Pause(10000) 'Try a square without the For/Next Loop Turtle Reset Turtle Begin Fill Turtle Forward 100 Turtle Turn Right 90 Turtle Forward 100 Turtle Turn Right 90 Turtle Forward 100 Turtle Turn Right 90 Turtle Forward 100 Turtle Turn Right 90 Turtle End Fill -Carl |
||||
vegipete Guru Joined: 29/01/2013 Location: CanadaPosts: 1082 |
With turtle fill, it looks like each x-coordinate is mistakenly set to the corresponding y-coordinate. Visit Vegipete's *Mite Library for cool programs. |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8578 |
Fill fixed in V5.05.05b5 just posted |
||||
Sasquatch Senior Member Joined: 08/05/2020 Location: United StatesPosts: 296 |
Thanks again Peter, everything looks good! All the demo/test programs working great. -Carl |
||||
Print this page |