Live coding with Löve

My earlier screencasts have shown live coding with simple Lua scripts and debugging of Löve scripts; the video below demonstrates live coding with Löve scripts using ZeroBrane Studio (you may need to switch the video to 720p to make the text more readable):

For those visiting for the first time, Löve is a simple and powerful framework for developing 2D games in Lua, and ZeroBrane Studio is a lightweight Lua IDE that provides code completion, syntax highlighting, live coding, remote debugger, code analyzer, and much more.

You may notice in the screencast that the paddle is moving quite slowly; you can run this without the debugger and the speed is likely to be about ten times faster. This may be okay for some situations, but in many cases when the game is complex, things can get very slow. How can you speed it up?

The debugger provides two methods that allow you to temporarily turn the debugging on and off. If you turn it on/off right around where the changes need to be applied, you can get almost the same performance you see without the debugger.

function love.update()
  require("mobdebug").on() --<-- turn the debugger on
  local angle = 45
  local speed = 75
  require("mobdebug").off() --<-- turn the debugger off
  points = calcTrajectoryPoints(speed, angle, 0.4)
  position = (position or 0) + 2
  if position > width-25 then position = 0 end
end

The code used in the screencast is available here. This is an experimental feature and may not work for some types of variables; for example, those local variables that are initialized outside of your draw and update methods (upvalues) may not be handled correctly. Right now your best bet is to store those variables you want to preserve as global variables.

You should get a copy of my slick ZeroBrane Studio IDE and follow me on twitter here.

Leave a comment

what will you say?
(required)
(required)

About

I am Paul Kulchenko.
I live in Kirkland, WA with my wife and three kids.
I do consulting as a software developer.
I study robotics and artificial intelligence.
I write books and open-source software.
I teach introductory computer science.
I develop a slick Lua IDE and debugger.

Recommended

Close