# SVN user name (lower case, without space) SPACE full name # this file is used by automated scripts or humans that wants to know the full # name of individual committers in the svn commit log adam Adam Boot agashlin Adam Gashlin aliask Will Robertson amiconn Jens Arnold andy Andy bagder Daniel Stenberg barrywardell Barry Wardell benbasha Ben Basha bertrik Bertrik Sikken bger Hristo Kovachev bluebrother Dominik Riebeling breaker Uwe Freese bryant Dave Bryant buschel Andree Buschmann christi Christi Scarborough christian Christian Gmeiner dan Dan Everton dan_a Daniel Ankers dave Dave Chapman dionoea Antoine Cellerier domonoky Dominik Wenger eigma Catalin Patulea gevaerts Frank Gevaerts gotthardt Steve Gotthardt gwhite Greg White hardeeps Hardeep Sidhu hbacke Henrik Backe hcl Michiel Van Der Kolk hohensoh Jörg Hohensohn james83 James Espinoza jdgordon Jonathan Gordon jethead71 Mike Sevakis jyp Jean-Philippe Bernardy kevin Kevin Ferrare kjer Kjell Ericson kkurbjun Karl Kurbjun lamed Shachar Liberman learman Magnus Holmgren len0x Anton Oleynikov lenzone10 Alessio Lenzi linus Linus Nielsen Feltzing llorean Paul Louden lostlogic Brandon Low lowlight Mark Arigo markun Marcoen Hirschberg matsl Mats Lidell mcuelenaere Maurus Cuelenaere medifebbo Michael DiFebbo midgey34 Tom Ross midkay Zakk Roberts miipekk Miika Pekkarinen mmmm Martin Scarratt moos Mustapha Senhaji nicolasp Nicolas Pennequin niobos Niels Laukens nls Nils Wallménius pbv Pedro Vasconcelos peter Peter D'Hoye phaedrus961 Frank Dischner pixelma Marianne Arnold pondlife Steve Bavin preglow Thom Johansen quelsaruk Jose Maria Garcia-Valdecasas Bernal raenye Rani Hod rasher Jonas Häggqvist rdjackso Ryan Jackson rob Rob Purchase robert Robert Keevil roolku Robert Kukla saratoga Michael Giacomelli scorche Austin Appel sdoyon Stephane Doyon stevenm Stepan Moskovchenko theli Anton Romanov tomal Tomasz Malesinski tomas Tomas Salfischberger toni Antonius Hellmann tpdiffenbach TP Diffenbach tucoz Martin Arver zagor Björn Stenberg gins/boomshine.lua'>
path: root/apps/plugins/boomshine.lua
blob: c160fddf0d4be5ee5bc7ca698faf04616b054f95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
--[[
             __________               __   ___.
   Open      \______   \ ____   ____ |  | _\_ |__   _______  ___
   Source     |       _//  _ \_/ ___\|  |/ /| __ \ /  _ \  \/  /
   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
                     \/            \/     \/    \/            \/
 $Id$

 Port of Chain Reaction (which is based on Boomshine) to Rockbox in Lua.
 See http://www.yvoschaap.com/chainrxn/ and http://www.k2xl.com/games/boomshine/

 Copyright (C) 2009 by Maurus Cuelenaere

 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.

 This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 KIND, either express or implied.

]]--

require "actions"

local CYCLETIME = rb.HZ / 50
local HAS_TOUCHSCREEN = rb.action_get_touchscreen_press ~= nil
local DEFAULT_BALL_SIZE = rb.LCD_HEIGHT > rb.LCD_WIDTH and rb.LCD_WIDTH  / 30
                                                       or  rb.LCD_HEIGHT / 30
local MAX_BALL_SPEED = DEFAULT_BALL_SIZE / 2
local DEFAULT_FOREGROUND_COLOR = rb.lcd_get_foreground ~= nil
                                                     and rb.lcd_get_foreground()
                                                     or  0

local levels = {
            --  {GOAL, TOTAL_BALLS},
                {1,   5},
                {2,  10},
                {4,  15},
                {6,  20},
                {10, 25},
                {15, 30},
                {18, 35},
                {22, 40},
                {30, 45},
                {37, 50},
                {48, 55},
                {55, 60}
           }

local Ball = {
                size = DEFAULT_BALL_SIZE,
                exploded = false,
                implosion = false
             }

function Ball:new(o)
    if o == nil then
        o = {
                x = math.random(0, rb.LCD_WIDTH - self.size),
                y = math.random(0, rb.LCD_HEIGHT - self.size),
                color = random_color(),
                up_speed = Ball:generateSpeed(),
                right_speed = Ball:generateSpeed(),
                explosion_size = math.random(2*self.size, 4*self.size),
                life_duration = math.random(rb.HZ, rb.HZ*5)
            }
    end

    setmetatable(o, self)
    self.__index = self
    return o
end

function Ball:generateSpeed()
    local speed = math.random(-MAX_BALL_SPEED, MAX_BALL_SPEED)
    if speed == 0 then
        speed = 1       -- Make sure all balls move
    end

    return speed
end

function Ball:draw()
    --[[
         I know these aren't circles, but as there's no current circle
         implementation in Rockbox, rectangles will just do fine (drawing
         circles from within Lua is far too slow).
    ]]--
    set_foreground(self.color)
    rb.lcd_fillrect(self.x, self.y, self.size, self.size)
end

function Ball:step()
    if self.exploded then
        if self.implosion and self.size > 0 then
            self.size = self.size - 2
            self.x = self.x + 1 -- We do this because we want to stay centered
            self.y = self.y + 1
        elseif self.size < self.explosion_size then
            self.size = self.size + 2
            self.x = self.x - 1 -- We do this for the same reasons as above
            self.y = self.y - 1
        end
        return
    end

    self.x = self.x + self.right_speed
    self.y = self.y + self.up_speed
    if (self.right_speed > 0 and self.x + self.size >= rb.LCD_WIDTH) or
       (self.right_speed < 0 and self.x <= 0) then
        self.right_speed = -self.right_speed
    end
    if (self.up_speed > 0 and self.y + self.size >= rb.LCD_HEIGHT) or
       (self.up_speed < 0 and self.y <= 0) then
        self.up_speed = -self.up_speed
    end
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) then
        assert(not self.exploded)
        self.exploded = true
        self.death_time = rb.current_tick() + self.life_duration
        if not other.exploded then
            other.exploded = true
            other.death_time = rb.current_tick() + other.life_duration
        end
        return true
    end

    return false
end

local Cursor = {
                size = DEFAULT_BALL_SIZE*2,
                x = rb.LCD_WIDTH/2,
                y = rb.LCD_HEIGHT/2
             }

function Cursor:new()
    return self
end

function Cursor:do_action(action)
    if action == rb.actions.ACTION_TOUCHSCREEN and HAS_TOUCHSCREEN then
        _, self.x, self.y = rb.action_get_touchscreen_press()
        return true
    elseif action == rb.actions.ACTION_KBD_SELECT then
        return true
    elseif (action == rb.actions.ACTION_KBD_RIGHT) then
        self.x = self.x + self.size
    elseif (action == rb.actions.ACTION_KBD_LEFT) then
        self.x = self.x - self.size
    elseif (action == rb.actions.ACTION_KBD_UP) then
        self.y = self.y - self.size
    elseif (action == rb.actions.ACTION_KBD_DOWN) then
        self.y = self.y + self.size
    end

    if self.x > rb.LCD_WIDTH then
        self.x = 0
    elseif self.x < 0 then
        self.x = rb.LCD_WIDTH
    end

    if self.y > rb.LCD_HEIGHT then
        self.y = 0
    elseif self.y < 0 then
        self.y = rb.LCD_HEIGHT
    end

    return false
end

function Cursor:draw()
    set_foreground(DEFAULT_FOREGROUND_COLOR)

    rb.lcd_hline(self.x - self.size/2, self.x - self.size/4, self.y - self.size/2)
    rb.lcd_hline(self.x + self.size/4, self.x + self.size/2, self.y - self.size/2)
    rb.lcd_hline(self.x - self.size/2, self.x - self.size/4, self.y + self.size/2)
    rb.lcd_hline(self.x + self.size/4, self.x + self.size/2, self.y + self.size/2)
    rb.lcd_vline(self.x - self.size/2, self.y - self.size/2, self.y - self.size/4)
    rb.lcd_vline(self.x - self.size/2, self.y + self.size/4, self.y + self.size/2)
    rb.lcd_vline(self.x + self.size/2, self.y - self.size/2, self.y - self.size/4)
    rb.lcd_vline(self.x + self.size/2, self.y + self.size/4, self.y + self.size/2)