VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
222 stars 16 forks source link

Suggestions for more turtle options: Orientation and Size of the turtle ... #24

Closed boa2145 closed 1 year ago

boa2145 commented 1 year ago

Hi Mohammad,

There are two options in the Python module "turtle" that are very useful and are sometimes needed when programming with the turtle. It would be nice if this was also possible with sVB:

  1. The turtle's east, north, south, and west orientation. Then you don't need any intermediate calculations if the orientation of the turtle has changed during the source code.

  2. It would also be fine if you could set the "size" of the turtle, i.e. make it bigger or smaller. But that is purely a question of beauty. I sometimes used it with Python's turtle.

Kind regards... Gregor

VBAndCs commented 1 year ago

@boa2145 Hi Gregor, I think you should extend the turtle yourself. The turtle has all necessary methods to do all you need, and you can write subroutines to do anymore actions. Furthermore, sVB made it easy to create libs, so, you can just add a global file and save it with a form (just a test form) in a same folder with the name "TurtleEx", and add this code to the global file:

' Extends the sVB Turtle

' Changes the Turtle angle to 135
Sub TurnNE()
   Turtle.Turn(135 - Turtle.Angle)
EndSub

Use the form to test the Global.TurnNE function, to make sure it works correctly. When you run the project, sVB will create the exe file. Terminate the project and go to the TurtleEx folder, open the bin folder, and delete all the files from the folder except the TurtleEx.exe and TurtleEx.xml files (we don't need the form here). Rename the bin folder to TurtleEx and copy it to the C:\Program Files\Small Visual Basic\sVB\Bin\Lib folder. Now you can use the new lib in sVB in the next time you open it (it needs a restart).

image

This way, you can add as many new actions to the turtle as you want, and share it with the community. You can publish your source code and the on GitHub. You can also zip the TurtleEx lib and publish in your repo as a release, or upload it on any valid file server. So, sVB allows the community to easily extend it.

For the second proposal, this needs to change the sVB source code, and I may look into it later, or a community developer can do it and send me a pull request to merge it in the source code. Thanks.

VBAndCs commented 1 year ago

Try this:

Turtle.Turn(100)
Turtle.Move(100)
TurtleEx.TurnNE()
Turtle.Move(100)

image

VBAndCs commented 1 year ago

Note also that I can include your TurtleEx in the sVB lib in the next release, and you can add you name in the lib description (the comments lines at the beginning of the global file), so it can appear in popup help:

image

boa2145 commented 1 year ago

Hi Mohammad,

Thank you for your detailed answer. For me, I program the turtle with three different languages: 1. Small Basic / Small Visual Basic, 2. Python and 3. TigerJython. All three languages ​​have different options for programming the turtle. SB and sVB have a built-in solution, Python and TigerJython have external modules, Python's "turtle" module is already large, but TigerJython's "gturtle" module is very large. So I'm always going back and forth. I had to translate the "flag of China" from Python to sVB, which also took some time.

But I understand your thoughts that I can either extend the capabilities of the turtle (SB or sVB) with my own procedures and functions, or I have to learn how to extend the sVB library. I've never done it before, but I can definitely learn. Is that only possible with sVB or also with SB?

With the modules for Python and TigerJython I can shrink and enlarge the size of the turtle, I can also expand and contract the shape. Sometimes that makes a lot of sense visually. There are also different tips for the turtle: arrows, circle, square, triangle and turtle. For example, for some drawings, arrows or circles are better than the shape of the turtle.

Yes, there are many ways to extend the capabilities of sVB's Turtle graphics as well. That sounds very interesting. I hope that I don't take up too much of your time, but I think that active participation in your sVB project is also positive and that further developments can take place as a result. Too bad that sVB has not been picked up by Microsoft. Your software might just be successful in the education sector, especially sVB is not as limited as SB.

Kind regards ... Gregor

VBAndCs commented 1 year ago

Is that only possible with sVB or also with SB?

SB libs must be written with C# or VB.NET. It can't create its own libs.

I hope that I don't take up too much of your time.

You are welcome. You feedback is very helpful.

Too bad that sVB has not been picked up by Microsoft

Let's hope that they at least don't shut it down!

VBAndCs commented 1 year ago

@boa2145 In sVB 2.8.5.6, you can change the Turtle size by using Turtle.Width or Turtle.Height. Also, you don't need any more to call Sound.Stop(soundFiile) before playing it, as the Sound.Play(soundFiile) method will make sure to stop the file first.

Ex:

Turtle.Width = 32
Turtle.Move(100)
Turtle.Turn(45)
Turtle.Move(100)

image

boa2145 commented 1 year ago

Hello Mohammad,

Thanks for your turtle improvement to change resp. set the width and height of the turtle.

Presently I am programming a tiny program (Guess The Number) again to study the differences between objects TextWindow and GraphicsWindow on SB: sequencial programming first and event handling second.

After that I want to translate it from GraphicsWindow on SB to the handling of a form in sVB. Want to say using the graphics mode on sVB without the object GraphicsWindow. I hope to understand the visual part of sVB a bit better.

Regards ... Gregor

Mohammad Hamdy Ghanem @.***> schrieb am Mo., 12. Juni 2023, 11:20:

Closed #24 https://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/24 as completed.

— Reply to this email directly, view it on GitHub https://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/24#event-9499895168, or unsubscribe https://github.com/notifications/unsubscribe-auth/A3D5YMRWET2ZC6EA4D6NDM3XK3NNRANCNFSM6AAAAAAYXAS6N4 . You are receiving this because you were mentioned.Message ID: @.*** com>