diff --git a/lib/demo/bowling.lua b/lib/demo/bowling.lua index 0735096..53e0d18 100644 --- a/lib/demo/bowling.lua +++ b/lib/demo/bowling.lua @@ -34,7 +34,7 @@ function setupStars() stars = ag.startList() local dist = 500 for i = 1, 500 do - local rx = math.random() * math.pi * 2 + local rx = math.random() * math.pi local ry = (math.random() - 0.5) * math.pi * 0.8 local x = dist * math.cos(ry) * math.cos(rx) local y = dist * math.cos(ry) * math.sin(rx) @@ -147,11 +147,19 @@ function drawFrameScore(width, height, frame, fs) local_width = 80 end local base_x = size / 2 + size * (frame - 1) - local base_y = height - size / 2 - size - ag.drawRect(1, 0.6, 0, local_width, size, base_x + local_width / 2, base_y + size / 2) - ag.drawRect(1, 0.6, 0, ball_size, ball_size, base_x + local_width - ball_size / 2, base_y + size - ball_size / 2) + local base_y = height - 2 * size + local str = string.format("%d", frame) + local w, h = ag.getTextSize(str, 16) + ag.drawText(str, 1, 0.6, 0, 16, + base_x + local_width / 2 - w / 2, base_y + size + 5) + ag.drawRect(1, 0.6, 0, local_width, size, + base_x + local_width / 2, base_y + size / 2) + ag.drawRect(1, 0.6, 0, ball_size, ball_size, + base_x + local_width - ball_size / 2, base_y + size - ball_size / 2) if (frame == 10) then - ag.drawRect(1, 0.6, 0, ball_size, ball_size, base_x + local_width - ball_size * 1.5, base_y + size - ball_size / 2) + ag.drawRect(1, 0.6, 0, ball_size, ball_size, + base_x + local_width - ball_size * 1.5, + base_y + size - ball_size / 2) end local balls = 2 @@ -197,6 +205,15 @@ function update_overlay_event(width, height) local score_str = string.format("Score: %d", score[10]["tot"]) w, h = ag.getTextSize(score_str, 56) ag.drawText(score_str, 1, 1, 0, 56, width / 2 - w / 2, height * 0.7 - 20 - h / 2) + else + local str = string.format("%d", current_frame) + local w, h = ag.getTextSize(str, 72) + ag.drawText(str, 1, 0.6, 0, 72, 20, 20) + ag.drawText("Frame:", 1, 0.6, 0, 24, 20, 40 + h) + str = string.format("%d", current_ball) + w, h = ag.getTextSize(str, 72) + ag.drawText(str, 1, 0.6, 0, 72, 200, 20) + ag.drawText("Ball:", 1, 0.6, 0, 24, 200, 40 + h) end end