New version after 3 months, and turtle graphics


This version may matter a lot to some people. I massively sped up `print` calls in Carousel. So if you are in the habit of printing a lot to the lower half of the screen, you'll want this.

Someone asked me if LÖVE or other languages support Turtle graphics like in Logo. The answer is: no, but it's easy to build. Then of course I had to build it in Carousel:

X, Y = Safe_width/2, 200
angle = 90
state = 'down'
color(0,0,1)
function up()
  state = 'up'
end
function down()
  state = 'down'
end
function forward(d)
  local a = angle*pi/180
  local x2 = boundx(X+d*cos(a))
  local y2 = boundy(Y+d*sin(a))
  if state == 'down' then
    line(X,Y, x2,y2)
    local a2 = 15*pi/180
    line(x2,y2, x2-10*cos(a-a2), y2-10*sin(a-a2))
    line(x2,y2, x2-10*cos(a+a2), y2-10*sin(a+a2))
  end
  X,Y = x2,y2
end
function left()
  turn(-90)
end
function right()
  turn(90)
end
function turn(da)
  angle = angle+da
end
function boundx(x)
  return max(0, min(Safe_width, x))
end
function boundy(y)
  return max(0, min(Safe_height, y))
end
forward(100)
turn(120)
forward(100)
turn(120)
forward(100)

If you try pasting this program into Lua Carousel, remember to first run the abbreviations on one of the example screens. Or if you've deleted that screen, here are the abbreviations I used in this post:

g = love.graphics
line = g.line
color = g.setColor
min, max = math.min, math.max
pi, cos, sin = math.pi, math.cos, math.sin

Files

carousel-bj.love 118 kB
24 days ago
carousel-bj-safe.love 118 kB
24 days ago

Get Lua Carousel

Leave a comment

Log in with itch.io to leave a comment.