🐒 B4XTurtle - Library for teachers and parents

Erel

B4X founder
Staff member
Licensed User
Longtime User
B4XTurtle is a library inspired by classic Logo programming language and TKP project: http://teachingkidsprogramming.org/
It is a cross platform library.
The purpose of B4XTurtle is to help with teaching programming. Drawing with the turtle is fun and it provides a simple visual feedback to the student.

Presentation about B4XTurtle:



You are welcome to try it and provide feedback.
Examples: https://www.b4x.com/android/forum/threads/-b4xturtle-examples-for-teachers-and-parents.116979/

Updates:

v1.06 - New StartPolygon and FillPolygon methods - better alternative, in most cases, to the Fill method.
v1.05 - Fixes an issue where the turtle could disappear when moving outside of the visible area, instead of appearing on the other side.
v1.04 - Fixes an issue with Fill which can cause the program to hang.
v1.03 - Multiple layers, DrawBitmap and other improvements.
v1.02 - Fill, Arc and RandomColor
v1.01 - RabbitMode and other improvements.

B4XTurtle is an internal library.
 

Attachments

  • 1587567435075.png
    25.8 KB · Views: 4,239
  • Example.zip
    133.8 KB · Views: 763
Last edited:

walterf25

Expert
Licensed User
Longtime User
Who can draw this star:



?
Multiple Star:
    For i = 1 To 5
        canvas.SetPenColor(Rnd(xui.Color_Black, xui.Color_White))
        For j = 1 To 5
            canvas.SetPenColor(Rnd(xui.Color_Black, xui.Color_White))
            canvas.MoveForward(30).TurnLeft(144)
        Next
        canvas.MoveForward(100).TurnLeft(144)
    Next





Easy
 

ilan

Expert
Licensed User
Longtime User
hi,

i have a question please. when i start the program the turtle starts immediately to run.
but in appstart event (b4j) there is no command for that.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("Main")
    MainForm.Show
End Sub

so it means that when the custom view is added it calles immediately the turtle_start event. is it possible to control that?

thanx
 
Reactions: DMW

barx

Well-Known Member
Licensed User
Longtime User
I don't think Turtles can 'run'. I've never seen one run anyway
 

ilan

Expert
Licensed User
Longtime User
actually this lib has a lot potential. i would like to just get positions from the turtle and draw what ever i want like a sprite in a loop.
i will opwn the bas file and see how i can edit it.

like in this event:

B4X:
    If State.PenDown Then
        MainLayer.DrawLine(UserToCanvas(State.UserX), UserToCanvas(State.UserY), UserToCanvas(X), UserToCanvas(Y), State.PenColor, UserToCanvas(State.PenThickness))
    End If

instead of drawing a line i can draw a sprite in a loop.

will check it later when i have more time

thanx, erel

EDIT: and also the DrawTurtle event can be used to draw the animated sprite.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
so it means that when the custom view is added it calles immediately the turtle_start event. is it possible to control that?
Nothing special. Just raises an event with CallSub.

I don't think Turtles can 'run'. I've never seen one run anyway
It will soon have a rabbit mode...



There is a use case for this which needs some explanation.
 

ilan

Expert
Licensed User
Longtime User
if the code does not need to be in the for...next loop then it could be done like this:

B4X:
Sub Circle (r As Float)
    For i = 1 To 360
        Turtle.MoveForward(((r*2)*cPI)/360).TurnLeft(1)
    Next
    Turtle.TurnLeft(90).MoveForward(r*2)
    Turtle.PenUp.TurnLeft(180).MoveForward(r)
    Turtle.PenDown.TurnLeft(90).MoveForward(r)
    Turtle.PenUp.TurnLeft(180).MoveForward(r)
    Turtle.PenDown.MoveForward(r)
End Sub

i am sure there is a better and shorter way
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…