|
| 1 | +rem licence: https://opensource.org/licenses/GPL-3.0 |
| 2 | +option predef load modules |
| 3 | +import android |
| 4 | +w = window():w.setFont(2,"em",true,false) |
| 5 | +const pop=35 |
| 6 | +const c1=97 |
| 7 | +const c2=122 |
| 8 | +const xm = xmax - txtw("z")*2 |
| 9 | +const ym = ymax - txth("z")*2 |
| 10 | +const vowel=["a","e","i","o","u"] |
| 11 | +const words =["anyway", "well", "what", "hello", "hmmmm", "today"] |
| 12 | +def mkatr = 10 + int(rnd * 140) |
| 13 | +func mk_char() |
| 14 | + local r |
| 15 | + if (rnd < .2) then |
| 16 | + r.ch = vowel[rnd*len(vowel)] |
| 17 | + else |
| 18 | + r.ch = chr(c1 + ((rnd*1000) % (c2-c1))) |
| 19 | + endif |
| 20 | + r.x = int(rnd * xmax) |
| 21 | + r.y = int(rnd * ymax) |
| 22 | + r.c = 1 + int(rnd * 14) |
| 23 | + r.atr = mkatr() |
| 24 | + mk_char=r |
| 25 | +end |
| 26 | +sub create(byref d, size) |
| 27 | + local i |
| 28 | + for i = 0 to size |
| 29 | + d[i] = mk_char() |
| 30 | + next i |
| 31 | +end |
| 32 | +func update(byref d, size, xo, yo) |
| 33 | + local i,x_chg,y_chg |
| 34 | + local rtn="" |
| 35 | + for i = 0 to size |
| 36 | + if (xo != 0) then d[i].x += (xo * d[i].atr) |
| 37 | + if (yo != 0) then d[i].y += (yo * d[i].atr) |
| 38 | + x_chg = true: y_chg = true |
| 39 | + if d[i].x < 0 then |
| 40 | + d[i].x = 0 |
| 41 | + elif d[i].x > xm then |
| 42 | + d[i].x = xm |
| 43 | + else |
| 44 | + x_chg = false |
| 45 | + endif |
| 46 | + if d[i].y < 0 then |
| 47 | + d[i].y = 0 |
| 48 | + elif d[i].y > ym then |
| 49 | + d[i].y = ym |
| 50 | + else |
| 51 | + y_chg = false |
| 52 | + endif |
| 53 | + if (x_chg or y_chg) then |
| 54 | + d[i].atr = mkatr() |
| 55 | + endif |
| 56 | + if ((d[i].y == 0 or d[i].y == ym) and d[i].x > 5) then rtn += d[i].ch |
| 57 | + next i |
| 58 | + update = rtn |
| 59 | +end |
| 60 | +sub show(byref d, size) |
| 61 | + local i |
| 62 | + for i = 0 to size |
| 63 | + at d[i].x, d[i].y |
| 64 | + color d[i].c |
| 65 | + print d[i].ch |
| 66 | + next i |
| 67 | +end |
| 68 | +android.sensor_on(0) |
| 69 | +randomize timer:cls |
| 70 | +dim d(pop) |
| 71 | +create(d, pop) |
| 72 | +show(d, pop) |
| 73 | +spk = "" |
| 74 | +android.tts_pitch(2) |
| 75 | +android.speak("tilt the screen") |
| 76 | +android.tts_pitch(.1) |
| 77 | +android.speak("DO It !") |
| 78 | +landscape=xmax>ymax |
| 79 | +while 1 |
| 80 | + s=android.sensor |
| 81 | + xo = iff(s.x < -1 or s.x > 1, s.x, 0) |
| 82 | + yo = iff(s.y < -1 or s.y > 1, s.y, 0) |
| 83 | + if (landscape) then swap xo,yo |
| 84 | + if (xo != 0 or yo != 0) then |
| 85 | + nspk = update(d, pop, xo, yo) |
| 86 | + if (nspk != spk) then |
| 87 | + spk = nspk |
| 88 | + android.tts_pitch(.5 + 1 * rnd) |
| 89 | + if (rnd < .2) then |
| 90 | + android.speak(words[rnd*len(words)]) |
| 91 | + else |
| 92 | + android.speak(spk) |
| 93 | + endif |
| 94 | + endif |
| 95 | + endif |
| 96 | + cls:show(d, pop) |
| 97 | + showpage:delay 50 |
| 98 | +wend |
0 commit comments