Skip to content

Instantly share code, notes, and snippets.

@jessefreeman
Created May 20, 2018 18:55
Show Gist options
  • Select an option

  • Save jessefreeman/af449c9dcde71c3c754a5362d4e8b463 to your computer and use it in GitHub Desktop.

Select an option

Save jessefreeman/af449c9dcde71c3c754a5362d4e8b463 to your computer and use it in GitHub Desktop.
PV8 example of drawing a score to the display.
local score = 0
local scoreDisplay = -1
local pos = NewVector(101, 123)
function DrawScore()
-- Update score
if(scoreDisplay ~= score) then
local diff = math.floor((score - scoreDisplay) / 4)
if(diff < 1) then
scoreDisplay = score
else
scoreDisplay = scoreDisplay + diff
end
if(scoreDisplay < 0) then
scoreDisplay = 0
end
DrawRect(pos.x, pos.y, 48, 8, BackgroundColor(), DrawMode.TilemapCache)
DrawText(string.format("%06d", scoreDisplay), pos.x, pos.y, DrawMode.TilemapCache, "default", 0, 0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment