-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
300 lines (234 loc) · 14 KB
/
Copy pathmain.lua
File metadata and controls
300 lines (234 loc) · 14 KB
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
--require "CiderDebugger";---------------------------------------------------------------------------------
--
-- main.lua
--
---------------------------------------------------------------------------------
local performance = require('objects.performance')
performance:newPerformanceMeter()
-- hide the status bar
display.setStatusBar( display.HiddenStatusBar )
_G._W = display.contentWidth
_G._H = display.contentHeight
_G.centerX = _W*.5
_G.centerY = _H*.5
_G.scale = _H/960
_G.width = 100*scale
_G.ballR = width*.375
_G.maxSpeed = _W
_G.font = "Dyslexie Regular"
--attempting to get font to work
--_G.font = "data\Dyslexie Regular LP129383 (1)"
--Colors { R = , G = , B = }
_G.Red = { R = 244/255, G = 060/255, B = 039/255 }
_G.Red100 = { R = 255/255, G = 205/255, B = 210/255 }
_G.Red300 = { R = 229/255, G = 115/255, B = 115/255 }
_G.Red700 = { R = 211/255, G = 047/255, B = 047/255 }
_G.Yellow = { R = 225/255, G = 196/255, B = 000/255 }
_G.Green = { R = 000/255, G = 148/255, B = 076/255 }
_G.Blue = { R = 000/255, G = 191/255, B = 165/255 }--{ R = 033/255, G = 150/255, B = 243/255 }
_G.Blue100 = { R = 187/255, G = 222/255, B = 251/255 }
_G.Blue300 = { R = 100/255, G = 181/255, B = 246/255 }
_G.Blue700 = { R = 025/255, G = 118/255, B = 210/255 }
_G.Purple = { R = 156/255, G = 039/255, B = 176/255 }
_G.BlueGrey = { R = 096/255, G = 125/255, B = 139/255 }
_G.Black = { R = 000/255, G = 000/255, B = 000/255 }
_G.White = { R = 255/255, G = 255/255, B = 255/255 }
_G.hlColor = { R = 244/255, G = 067/255, B = 054/255 }
_G.priColor = { R = Yellow.R, G = Yellow.G, B = Yellow.B}
_G.secColor = { R = Blue.R, G = Blue.G, B = Blue.B }
_G.outlineColor = { highlight = { r= 0, g=0, b=0 }, shadow = { r=0, g=0, b=0 } }
_G.fontSize = _W*.05
_G.phi = 1.618033988749894
_G.gRadius = { 1.000*ballR, 2.000*ballR, 2.155*ballR, 2.415*ballR, 2.702*ballR, 3.001*ballR, 3.001*ballR, 3.305*ballR, 3.614*ballR, 3.924*ballR, 4.000*ballR, 4.155*ballR}
_G.ballCoord = {
--1 Ball
{ 0, 0 },
--2 Balls
{ - ballR, 0, ballR, 0 },
--3 Balls
{ 1.155*ballR*math.cos(math.rad(-90)) , 1.155*ballR*math.sin(math.rad(-90)), 1.155*ballR*math.cos(math.rad(30)), 1.155*ballR*math.sin(math.rad(30)),
1.155*ballR*math.cos(math.rad(150)), 1.155*ballR*math.sin(math.rad(150)),},
--4 Balls
{ (gRadius[4] - ballR)*math.cos(math.rad(-90)), (gRadius[4] - ballR)*math.sin(math.rad(-90)), (gRadius[4] - ballR)*math.cos(math.rad(0)), (gRadius[4] - ballR)*math.sin(math.rad(0)),
(gRadius[4] - ballR)*math.cos(math.rad(90)), (gRadius[4] - ballR)*math.sin(math.rad(90)), (gRadius[4] - ballR)*math.cos(math.rad(180)), (gRadius[4] - ballR)*math.sin(math.rad(180))},
--5 Balls
{ (gRadius[5] - ballR)*math.cos(math.rad(-90)), (gRadius[5] - ballR)*math.sin(math.rad(-90)), (gRadius[5] - ballR)*math.cos(math.rad(-18)), (gRadius[5] - ballR)*math.sin(math.rad(-18)),
(gRadius[5] - ballR)*math.cos(math.rad(54)), (gRadius[5] - ballR)*math.sin(math.rad(54)), (gRadius[5] - ballR)*math.cos(math.rad(126)), (gRadius[5] - ballR)*math.sin(math.rad(126)),
(gRadius[5] - ballR)*math.cos(math.rad(198)), (gRadius[5] - ballR)*math.sin(math.rad(198)) },
{ (gRadius[6] - ballR)*math.cos(math.rad(-90)), (gRadius[6] - ballR)*math.sin(math.rad(-90)), (gRadius[6] - ballR)*math.cos(math.rad(-30)), (gRadius[6] - ballR)*math.sin(math.rad(-30)),
(gRadius[6] - ballR)*math.cos(math.rad(30)), (gRadius[6] - ballR)*math.sin(math.rad(30)), (gRadius[6] - ballR)*math.cos(math.rad(90)), (gRadius[6] - ballR)*math.sin(math.rad(90)),
(gRadius[6] - ballR)*math.cos(math.rad(150)), (gRadius[6] - ballR)*math.sin(math.rad(150)), (gRadius[6] - ballR)*math.cos(math.rad(210)), (gRadius[6] - ballR)*math.sin(math.rad(210)) },
{ (gRadius[7] - ballR)*math.cos(math.rad(-90)), (gRadius[7] - ballR)*math.sin(math.rad(-90)), (gRadius[7] - ballR)*math.cos(math.rad(-30)), (gRadius[7] - ballR)*math.sin(math.rad(-30)),
(gRadius[7] - ballR)*math.cos(math.rad(30)), (gRadius[7] - ballR)*math.sin(math.rad(30)), (gRadius[7] - ballR)*math.cos(math.rad(90)), (gRadius[7] - ballR)*math.sin(math.rad(90)),
(gRadius[7] - ballR)*math.cos(math.rad(150)), (gRadius[7] - ballR)*math.sin(math.rad(150)), (gRadius[7] - ballR)*math.cos(math.rad(210)), (gRadius[7] - ballR)*math.sin(math.rad(210)),
0, 0 },
{ (gRadius[8] - ballR)*math.cos(math.rad(-90)), (gRadius[8] - ballR)*math.sin(math.rad(-90)), (gRadius[8] - ballR)*math.cos(math.rad(-38.571)), (gRadius[8] - ballR)*math.sin(math.rad(-38.571)),
(gRadius[8] - ballR)*math.cos(math.rad(12.857)), (gRadius[8] - ballR)*math.sin(math.rad(12.857)), (gRadius[8] - ballR)*math.cos(math.rad(64.286)), (gRadius[8] - ballR)*math.sin(math.rad(64.286)),
(gRadius[8] - ballR)*math.cos(math.rad(115.714)), (gRadius[8] - ballR)*math.sin(math.rad(115.714)), (gRadius[8] - ballR)*math.cos(math.rad(167.143)), (gRadius[8] - ballR)*math.sin(math.rad(167.143)),
(gRadius[8] - ballR)*math.cos(math.rad(218.571)), (gRadius[8] - ballR)*math.sin(math.rad(218.571)), 0,0 },
{ (gRadius[9] - ballR)*math.cos(math.rad(-90)), (gRadius[9] - ballR)*math.sin(math.rad(-90)), (gRadius[9] - ballR)*math.cos(math.rad(-45)), (gRadius[9] - ballR)*math.sin(math.rad(-45)),
(gRadius[9] - ballR)*math.cos(math.rad(0)), (gRadius[9] - ballR)*math.sin(math.rad(0)), (gRadius[9] - ballR)*math.cos(math.rad(45)), (gRadius[9] - ballR)*math.sin(math.rad(45)),
(gRadius[9] - ballR)*math.cos(math.rad(90)), (gRadius[9] - ballR)*math.sin(math.rad(90)), (gRadius[9] - ballR)*math.cos(math.rad(135)), (gRadius[9] - ballR)*math.sin(math.rad(135)),
(gRadius[9] - ballR)*math.cos(math.rad(180)), (gRadius[9] - ballR)*math.sin(math.rad(180)), (gRadius[9] - ballR)*math.cos(math.rad(225)), (gRadius[9] - ballR)*math.sin(math.rad(225)),
0, 0 },
{ (gRadius[10] - ballR)*math.cos(math.rad(-90)), (gRadius[10] - ballR)*math.sin(math.rad(-90)), (gRadius[10] - ballR)*math.cos(math.rad(-50)), (gRadius[10] - ballR)*math.sin(math.rad(-50)),
(gRadius[10] - ballR)*math.cos(math.rad(-10)), (gRadius[10] - ballR)*math.sin(math.rad(-10)), (gRadius[10] - ballR)*math.cos(math.rad(30)), (gRadius[10] - ballR)*math.sin(math.rad(30)),
(gRadius[10] - ballR)*math.cos(math.rad(70)), (gRadius[10] - ballR)*math.sin(math.rad(70)), (gRadius[10] - ballR)*math.cos(math.rad(110)), (gRadius[10] - ballR)*math.sin(math.rad(110)),
(gRadius[10] - ballR)*math.cos(math.rad(150)), (gRadius[10] - ballR)*math.sin(math.rad(150)), (gRadius[10] - ballR)*math.cos(math.rad(190)), (gRadius[10] - ballR)*math.sin(math.rad(190)),
(gRadius[10] - ballR)*math.cos(math.rad(230)), (gRadius[10] - ballR)*math.sin(math.rad(230)), 0, 0 },
{ (gRadius[11] - ballR)*math.cos(math.rad(-90)), (gRadius[11] - ballR)*math.sin(math.rad(-90)), (gRadius[11] - ballR)*math.cos(math.rad(-50)), (gRadius[11] - ballR)*math.sin(math.rad(-50)),
(gRadius[11] - ballR)*math.cos(math.rad(-10)), (gRadius[11] - ballR)*math.sin(math.rad(-10)), (gRadius[11] - ballR)*math.cos(math.rad(30)), (gRadius[11] - ballR)*math.sin(math.rad(30)),
(gRadius[11] - ballR)*math.cos(math.rad(70)), (gRadius[11] - ballR)*math.sin(math.rad(70)), (gRadius[11] - ballR)*math.cos(math.rad(110)), (gRadius[11] - ballR)*math.sin(math.rad(110)),
(gRadius[11] - ballR)*math.cos(math.rad(150)), (gRadius[11] - ballR)*math.sin(math.rad(150)), (gRadius[11] - ballR)*math.cos(math.rad(190)), (gRadius[11] - ballR)*math.sin(math.rad(190)),
(gRadius[11] - ballR)*math.cos(math.rad(230)), (gRadius[11] - ballR)*math.sin(math.rad(230)), - ballR, 0,
ballR, 0 },
{ (gRadius[12] - ballR)*math.cos(math.rad(-90)), (gRadius[12] - ballR)*math.sin(math.rad(-90)), (gRadius[12] - ballR)*math.cos(math.rad(-50)), (gRadius[12] - ballR)*math.sin(math.rad(-50)),
(gRadius[12] - ballR)*math.cos(math.rad(-10)), (gRadius[12] - ballR)*math.sin(math.rad(-10)), (gRadius[12] - ballR)*math.cos(math.rad(30)), (gRadius[12] - ballR)*math.sin(math.rad(30)),
(gRadius[12] - ballR)*math.cos(math.rad(70)), (gRadius[12] - ballR)*math.sin(math.rad(70)), (gRadius[12] - ballR)*math.cos(math.rad(110)), (gRadius[12] - ballR)*math.sin(math.rad(110)),
(gRadius[12] - ballR)*math.cos(math.rad(150)), (gRadius[12] - ballR)*math.sin(math.rad(150)), (gRadius[12] - ballR)*math.cos(math.rad(190)), (gRadius[12] - ballR)*math.sin(math.rad(190)),
(gRadius[12] - ballR)*math.cos(math.rad(230)), (gRadius[12] - ballR)*math.sin(math.rad(230)), 1.155*ballR*math.cos(math.rad(-90)) , 1.155*ballR*math.sin(math.rad(-90)),
1.155*ballR*math.cos(math.rad(30)), 1.155*ballR*math.sin(math.rad(30)), 1.155*ballR*math.cos(math.rad(150)), 1.155*ballR*math.sin(math.rad(150)) }
}
_G.bg = display.newRect(centerX, centerY, _W, _H)
bg:setFillColor(1,1,1)
transition.callback = transition.to ;
function transition.fromtocolor(obj, colorFrom, colorTo, time, delay, ease)
local _obj = obj ;
local ease = ease or easing.linear
local fcolor = colorFrom or {255,255,255} ; -- defaults to white
local tcolor = colorTo or {0,0,0} ; -- defaults to black
local t = nil ;
local p = {} --hold parameters here
local rDiff = tcolor[1] - fcolor[1] ; --Calculate difference between values
local gDiff = tcolor[2] - fcolor[2] ;
local bDiff = tcolor[3] - fcolor[3] ;
--Set up proxy
local proxy = {step = 0} ;
local mt
if( obj and obj.setTextColor ) then
mt = {
__index = function(t,k)
--print("get") ;
return t["step"]
end,
__newindex = function (t,k,v)
--print("set")
--print(t,k,v)
if(_obj.setTextColor) then
_obj:setTextColor(fcolor[1] + (v*rDiff) ,fcolor[2] + (v*gDiff) ,fcolor[3] + (v*bDiff) )
end
t["step"] = v ;
end
}
else
mt = {
__index = function(t,k)
--print("get") ;
return t["step"]
end,
__newindex = function (t,k,v)
--print("set")
--print(t,k,v)
if(_obj.setFillColor) then
_obj:setFillColor(fcolor[1] + (v*rDiff) ,fcolor[2] + (v*gDiff) ,fcolor[3] + (v*bDiff) )
end
t["step"] = v ;
end
}
end
p.time = time or 1000 ; --defaults to 1 second
p.delay = delay or 0 ;
p.transition = ease ;
setmetatable(proxy,mt) ;
p.colorScale = 1 ;
t = transition.to(proxy,p , 1 ) ;
return t
end
transition.callback = transition.to ;
function transition.matTrans(obj, xt, yt, time, delay )
local delay = delay or 0
local function endMove ( obj )
transition.to( obj, { time=250, xScale = 1.0, yScale = 1.0 } )
end
local function move ( obj )
transition.to( obj, {x = xt, y = yt, onComplete = endMove, easing = easing.inOutCubic, time = time } )
end
transition.to( obj, { time=250, xScale = 1.1, yScale = 1.1, onComplete=move } )
end
local function convertDecToLat( number )
local text = "zero"
if number == 1 then text = "One"
elseif number == 2 then text = "Two"
elseif number == 3 then text = "Three"
elseif number == 4 then text = "Four"
elseif number == 5 then text = "Five"
elseif number == 6 then text = "Six"
elseif number == 7 then text = "Seven"
elseif number == 8 then text = "Eight"
elseif number == 9 then text = "Nine"
elseif number == 10 then text = "Ten"
elseif number == 11 then text = "Eleven"
elseif number == 12 then text = "Twelve"
elseif number == 13 then text = "Thirteen"
elseif number == 14 then text = "Fourteen"
elseif number == 15 then text = "Fifteen"
elseif number == 16 then text = "Sixteen"
elseif number == 17 then text = "Seventeen"
elseif number == 18 then text = "Eighteen"
elseif number == 19 then text = "Nineteen"
elseif number == 20 then text = "Twenty"
elseif number == 30 then text = "Thirty"
elseif number == 40 then text = "Forty"
elseif number == 50 then text = "Fifty"
elseif number == 60 then text = "Sixty"
elseif number == 70 then text = "Seventy"
elseif number == 80 then text = "Eighty"
elseif number == 90 then text = "Ninety"
elseif number == 100 then text = "One Hundred"
elseif number == 110 then text = "One Hundred Ten"
elseif number == 120 then text = "One Hundred Twenty"
elseif number == 130 then text = "One Hundred Thirty"
elseif number == 140 then text = "One Hundred Forty"
elseif number == 150 then text = "One Hundred Fifty"
elseif number == 160 then text = "One Hundred Sixty"
elseif number == 170 then text = "One Hundred Seventy"
elseif number == 180 then text = "One Hundred Eighty"
elseif number == 190 then text = "One Hundred Ninety"
elseif number == 200 then text = "Two Hundred"
elseif number == 0 then text = "Zero"
else text = " "
end
return text
end
_G.convertDecToLat = convertDecToLat
local function createGrid(w, h, size)
local p = Math.floor(w / size)
local q = Math.floor(h / size)
retval = {}
for i=1,p do
retval[i] = {}
for j=1,q do
retval[i][j] = false
end
end
end
local composer = require( "composer" )
composer.recycleOnSceneChange = true
--composer.gotoScene( "lessons.kCount_01" )
--composer.gotoScene( "lessons.kCount_02" )
--composer.gotoScene( "lessons.kCount_02_2" )
--composer.gotoScene( "lessons.kCount_03" )
--composer.gotoScene( "lessons.intro1" )
--composer.gotoScene( "lessons.lesson1" )
--composer.gotoScene( "lessons.lesson2" )
--composer.gotoScene( "lessons.lesson3" )
--composer.gotoScene( "lessons.lesson4" )
--composer.gotoScene( "lessons.lesson5" )
--composer.gotoScene( "lessons.lesson6" )
--composer.gotoScene( "lessons.lesson7" )
--composer.gotoScene( "lessons.lesson8" )
--composer.gotoScene( "lessons.lesson9" )
--composer.gotoScene( "lessons.lesson11" )
--composer.gotoScene( "lessons.lesson12" )
--composer.gotoScene( "lessons.lesson13" )
composer.gotoScene( "menu" )