Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/apps/plugins/boomshine.lua b/apps/plugins/boomshine.lua
- index 2eb43de..cc3f5a6 100644
- --- a/apps/plugins/boomshine.lua
- +++ b/apps/plugins/boomshine.lua
- @@ -63,7 +63,7 @@ function Ball:new(o)
- color = random_color(),
- up_speed = Ball:generateSpeed(),
- right_speed = Ball:generateSpeed(),
- - explosion_size = math.random(2*self.size, 4*self.size),
- + explosion_size = math.random(2*self.size, 4*self.size) * 4/3,
- life_duration = math.random(rb.HZ, rb.HZ*5)
- }
- end
- @@ -82,6 +82,26 @@ function Ball:generateSpeed()
- return speed
- end
- +function drawCircle(x0, y0, radius)
- + x = radius
- + y = 0
- + radiusError = 1 - x
- + step = 0
- +
- + while x >= y do
- + y = y + 1
- + if radiusError < 0 then
- + radiusError = radiusError + 2 * y + 1
- + else
- + rb.lcd_fillrect(x0 - x, y0 - y, 1, 2 * y)
- + rb.lcd_fillrect(x0 + x, y0 - y, 1, 2 * y)
- + rb.lcd_fillrect(x0 - y, y0 - x, 2 * y, 2 * x)
- + x = x - 1
- + radiusError = radiusError + (y - x) + 1
- + end
- + end
- +end
- +
- function Ball:draw()
- --[[
- I know these aren't circles, but as there's no current circle
- @@ -89,7 +109,13 @@ function Ball:draw()
- circles from within Lua is far too slow).
- ]]--
- set_foreground(self.color)
- - rb.lcd_fillrect(self.x, self.y, self.size, self.size)
- +
- + xm = math.floor(self.x + self.size / 2)
- + ym = math.floor(self.y + self.size / 2)
- +
- + drawCircle(xm, ym, math.ceil(self.size / 2))
- +
- + --[[ rb.lcd_fillrect(self.x, self.y, self.size, self.size) ]]--
- end
- function Ball:step()
- @@ -119,8 +145,12 @@ function Ball:step()
- end
- function Ball:checkHit(other)
- - if (other.x + other.size >= self.x) and (self.x + self.size >= other.x) and
- - (other.y + other.size >= self.y) and (self.y + self.size >= other.y) the
- + dx = (other.x + other.size / 2) - (self.x + self.size / 2)
- + dy = (other.y + other.size / 2) - (self.y + self.size / 2)
- + ds = (other.size / 2 + self.size / 2)
- + if dx*dx + dy*dy -- Distance between centers, squared
- + <=
- + ds * ds then -- Sizes, squared
- assert(not self.exploded)
- self.exploded = true
- self.death_time = rb.current_tick() + self.life_duration
- @@ -212,7 +242,7 @@ function random_color()
- end
- function start_round(level, goal, nrBalls, total)
- - local player_added, score, exit, nrExpandedBalls = false, 0, false, 0
- + local player_added, score, exit, nrExpendedBalls = false, 0, false, 0
- local balls, explodedBalls = {}, {}
- local cursor = Cursor:new()
- @@ -257,7 +287,7 @@ function start_round(level, goal, nrBalls, total)
- for _, explodedBall in ipairs(explodedBalls) do
- if ball:checkHit(explodedBall) then
- score = score + 100*level
- - nrExpandedBalls = nrExpandedBalls + 1
- + nrExpendedBalls = nrExpendedBalls + 1
- table.insert(explodedBalls, ball)
- table.remove(balls, i)
- break
- @@ -280,7 +310,7 @@ function start_round(level, goal, nrBalls, total)
- rb.lcd_clear_display()
- set_foreground(DEFAULT_FOREGROUND_COLOR)
- - draw_positioned_string(0, 0, string.format("%d balls expanded", nrExpan
- + draw_positioned_string(0, 0, string.format("%d balls expended", nrExpen
- draw_positioned_string(0, 1, string.format("Level %d", level))
- draw_positioned_string(1, 1, string.format("%d level points", score))
- draw_positioned_string(1, 0, string.format("%d total points", total+sco
- @@ -309,7 +339,7 @@ function start_round(level, goal, nrBalls, total)
- end
- end
- - return exit, score, nrExpandedBalls
- + return exit, score, nrExpendedBalls
- end
- -- Helper function to display a message
- @@ -353,17 +383,19 @@ if HAS_TOUCHSCREEN then
- end
- rb.backlight_force_on()
- +math.randomseed(os.time())
- +
- local idx, highscore = 1, 0
- while levels[idx] ~= nil do
- local goal, nrBalls = levels[idx][1], levels[idx][2]
- display_message(rb.HZ*2, "Level %d: get %d out of %d balls", idx, goal, nrB
- - local exit, score, nrExpandedBalls = start_round(idx, goal, nrBalls, highsc
- + local exit, score, nrExpendedBalls = start_round(idx, goal, nrBalls, highsc
- if exit then
- break -- Exiting..
- else
- - if nrExpandedBalls >= goal then
- + if nrExpendedBalls >= goal then
- display_message(rb.HZ*2, "You won!")
- idx = idx + 1
- highscore = highscore + score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement