diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/boomshine.lua | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/apps/plugins/boomshine.lua b/apps/plugins/boomshine.lua index ab00c52e2b..c160fddf0d 100644 --- a/apps/plugins/boomshine.lua +++ b/apps/plugins/boomshine.lua | |||
@@ -58,8 +58,8 @@ local Ball = { | |||
58 | function Ball:new(o) | 58 | function Ball:new(o) |
59 | if o == nil then | 59 | if o == nil then |
60 | o = { | 60 | o = { |
61 | x = math.random(self.size, rb.LCD_WIDTH - self.size), | 61 | x = math.random(0, rb.LCD_WIDTH - self.size), |
62 | y = math.random(self.size, rb.LCD_HEIGHT - self.size), | 62 | y = math.random(0, rb.LCD_HEIGHT - self.size), |
63 | color = random_color(), | 63 | color = random_color(), |
64 | up_speed = Ball:generateSpeed(), | 64 | up_speed = Ball:generateSpeed(), |
65 | right_speed = Ball:generateSpeed(), | 65 | right_speed = Ball:generateSpeed(), |
@@ -108,20 +108,19 @@ function Ball:step() | |||
108 | 108 | ||
109 | self.x = self.x + self.right_speed | 109 | self.x = self.x + self.right_speed |
110 | self.y = self.y + self.up_speed | 110 | self.y = self.y + self.up_speed |
111 | if (self.x + self.size) >= rb.LCD_WIDTH or self.x <= self.size then | 111 | if (self.right_speed > 0 and self.x + self.size >= rb.LCD_WIDTH) or |
112 | self.right_speed = self.right_speed * (-1) | 112 | (self.right_speed < 0 and self.x <= 0) then |
113 | elseif (self.y + self.size) >= rb.LCD_HEIGHT or self.y <= self.size then | 113 | self.right_speed = -self.right_speed |
114 | self.up_speed = self.up_speed * (-1) | 114 | end |
115 | if (self.up_speed > 0 and self.y + self.size >= rb.LCD_HEIGHT) or | ||
116 | (self.up_speed < 0 and self.y <= 0) then | ||
117 | self.up_speed = -self.up_speed | ||
115 | end | 118 | end |
116 | end | 119 | end |
117 | 120 | ||
118 | function Ball:checkHit(other) | 121 | function Ball:checkHit(other) |
119 | local x_dist = math.abs(other.x - self.x) | 122 | if (other.x + other.size >= self.x) and (self.x + self.size >= other.x) and |
120 | local y_dist = math.abs(other.y - self.y) | 123 | (other.y + other.size >= self.y) and (self.y + self.size >= other.y) then |
121 | local x_size = self.x > other.x and other.size or self.size | ||
122 | local y_size = self.y > other.y and other.size or self.size | ||
123 | |||
124 | if (x_dist <= x_size) and (y_dist <= y_size) then | ||
125 | assert(not self.exploded) | 124 | assert(not self.exploded) |
126 | self.exploded = true | 125 | self.exploded = true |
127 | self.death_time = rb.current_tick() + self.life_duration | 126 | self.death_time = rb.current_tick() + self.life_duration |