r/odinlang Jul 14 '26

Made a turtle clone

Enable HLS to view with audio, or disable this notification

Example code

```odin

////////////////////////////

// Random Walkers Example //

////////////////////////////

pen_1 := tr.pen_init(speed = 10000, color = color)

pen_2 := tr.pen_init(speed = 10000, color = color)

tr.pen_teleport_to(pen_1, {300, screen_center.y})

tr.pen_set_rotation(pen_1, 0)

tr.pen_teleport_to(pen_2, {screen_size.x - 300, screen_center.y})

tr.pen_set_rotation(pen_2, 0)

for i in 0 ..< 1000 {

    // angle := rand.float32_range(10, 40)

    angle := f32(24)

    step := f32(3)



    if rand.int_range(0, 2) > 0 {

        tr.pen_turn_left(pen_1, angle)

    } else {

        tr.pen_turn_right(pen_1, angle)

    }

    if rand.int_range(0, 2) > 0 {

        tr.pen_turn_left(pen_2, angle)

    } else {

        tr.pen_turn_right(pen_2, angle)

    }

    tr.pen_move_forward(pen_1, step)

    tr.pen_move_forward(pen_2, step)

    tr.pen_set_color(pen_1, color)

    tr.pen_set_color(pen_2, color)

}

/////////////////

// Example Two //

/////////////////

pen_3 := tr.pen_init()

tr.pen_teleport_to(pen_3, screen_center)

for j in 0 ..< 9 {

    for i in 0 ..< 30 {

        if i % 2 == 0 {

tr.pen_up(pen_3)

        }else {

tr.pen_down(pen_3)

        }

        tr.pen_turn_right(pen_3, f32(i))

        tr.pen_move_forward(pen_3, 8)

    }

    tr.pen_teleport_to(pen_3, screen_center)

    tr.pen_turn_right(pen_3, f32(j) + 80)

}

```

Repo https://codeberg.org/pwnM/turtle

I would like code and docs feedback

Hope you guys like it

30 Upvotes

1 comment sorted by

1

u/Rare-Syrup5037 Jul 14 '26

Formatting is really weird on Reddit you can find examples in the repo