Skip to content

Commit e0c1c63

Browse files
committed
Merge branch 'master' of github.com:espruino/BangleApps
2 parents 729ad7e + 5a46508 commit e0c1c63

File tree

144 files changed

+3757
-263
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+3757
-263
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ appdates.csv
99
_config.yml
1010
tests/Layout/bin/tmp.*
1111
tests/Layout/testresult.bmp
12-
apps.json
12+
apps.local.json

apps.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
# Otherwise nothing has changed. GitHub Pages will automatically
88
# create apps.json as your site is hosted, or if you're hosting
99
# yourself you can run bin/create_apps_json.sh
10-
#
10+
#
11+
# If you serve the store from localhost for development/testing,
12+
# the loader looks for apps.local.json instead, you can run
13+
# `bin/create_apps_json.sh apps.local.json` to create that file.
1114
# =================================================================
1215

1316
# Uncomment the following line if you only want explicitly listed

apps/ballmaze/app.js

+16-10
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
(() => {
1+
(() => {
2+
BANGLEJS2 = process.env.HWVERSION==2;
23
Bangle.setLCDTimeout(0);
34
let intervalID;
45
let settings = require("Storage").readJSON("ballmaze.json",true) || {};
56

67
// density, elasticity of bounces, "drag coefficient"
78
const rho = 100, e = 0.3, C = 0.01;
89
// screen width & height in pixels
9-
const sW = 240, sH = 160;
10+
const sW = g.getWidth();
11+
const sH = g.getHeight()*2/3;
12+
const bgColour ="#f00"; // only for Bangle.js 2
1013
// gravity constant (lowercase was already taken)
1114
const G = 9.80665;
1215

@@ -17,14 +20,16 @@
1720
// The play area is 240x160, sizes are the ball radius, so we can use common
1821
// denominators of 120x80 to get square rooms
1922
// Reverse the order to show the easiest on top of the menu
20-
const sizes = [1, 2, 4, 5, 8, 10, 16, 20, 40].reverse(),
21-
// even size 1 actually works, but larger mazes take forever to generate
22-
minSize = 4, defaultSize = 10;
2323
const sizeNames = {
2424
1: "Insane", 2: "Gigantic", 4: "Enormous", 5: "Huge", 8: "Large",
2525
10: "Medium", 16: "Small", 20: "Tiny", 40: "Trivial",
2626
};
27-
27+
// even size 1 actually works, but larger mazes take forever to generate
28+
if (!BANGLEJS2) {
29+
const sizes = [1, 2, 4, 5, 8, 10, 16, 20, 40].reverse(), minSize = 4, defaultSize = 10;
30+
} else {
31+
const sizes = [1, 2, 4, 5, 8, 10, 16, 20 ].reverse(), minSize = 4, defaultSize = 10;
32+
}
2833
/**
2934
* Draw something to all screen buffers
3035
* @param draw {function} Callback which performs the drawing
@@ -45,17 +50,17 @@
4550

4651
// use unbuffered graphics for UI stuff
4752
function showMessage(message, title) {
48-
Bangle.setLCDMode();
53+
if (!BANGLEJS2) Bangle.setLCDMode();
4954
return E.showMessage(message, title);
5055
}
5156

5257
function showPrompt(prompt, options) {
53-
Bangle.setLCDMode();
58+
if (!BANGLEJS2) Bangle.setLCDMode();
5459
return E.showPrompt(prompt, options);
5560
}
5661

5762
function showMenu(menu) {
58-
Bangle.setLCDMode();
63+
if (!BANGLEJS2) Bangle.setLCDMode();
5964
return E.showMenu(menu);
6065
}
6166

@@ -105,7 +110,7 @@
105110
generateMaze(); // this shows unbuffered progress messages
106111
if (settings.cheat && r>1) findRoute(); // not enough memory for r==1 :-(
107112

108-
Bangle.setLCDMode("doublebuffered");
113+
if (!BANGLEJS2) Bangle.setLCDMode("doublebuffered");
109114
clearAll();
110115
drawAll(drawMaze);
111116
intervalID = setInterval(tick, 100);
@@ -307,6 +312,7 @@
307312
const range = {top: 0, left: 0, bottom: rows, right: cols};
308313
const w = sW/cols, h = sH/rows;
309314
g.clear();
315+
if (BANGLEJS2) g.setBgColor(bgColour);
310316
g.setColor(0.76, 0.60, 0.42);
311317
for(let row = range.top; row<=range.bottom; row++) {
312318
for(let col = range.left; col<=range.right; col++) {

apps/balltastic/ChangeLog

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
0.01: Initial version of Balltastic released! Happy!
2-
0.02: Set LCD timeout for Espruino 2v10 compatibility
2+
0.02: Set LCD timeout for Espruino 2v10 compatibility
3+
0.03: Now also works on Bangle.js 2

apps/balltastic/app.js

+18-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
BANGLEJS2 = process.env.HWVERSION==2;
12
Bangle.setLCDBrightness(1);
2-
Bangle.setLCDMode("doublebuffered");
3+
if (!BANGLEJS2) Bangle.setLCDMode("doublebuffered");
34
Bangle.setLCDTimeout(0);
45

56
let points = 0;
67
let level = 1;
78
let levelSpeedStart = 0.8;
8-
let nextLevelPoints = 20;
9+
let nextLevelPoints = 10;
910
let levelSpeedFactor = 0.2;
1011
let counterWidth = 10;
1112
let gWidth = g.getWidth() - counterWidth;
@@ -81,19 +82,31 @@ function drawLevelText() {
8182
g.setColor("#26b6c7");
8283
g.setFontAlign(0, 0);
8384
g.setFont("4x6", 5);
84-
g.drawString("Level " + level, 120, 80);
85+
g.drawString("Level " + level, g.getWidth()/2, g.getHeight()/2);
86+
}
87+
88+
function drawPointsText() {
89+
g.setColor("#26b6c7");
90+
g.setFontAlign(0, 0);
91+
g.setFont("4x6", 2);
92+
g.drawString("Points " + points, g.getWidth()/2, g.getHeight()-20);
8593
}
8694

8795
function draw() {
8896
//bg
89-
g.setColor("#71c6cf");
97+
if (!BANGLEJS2) {
98+
g.setColor("#71c6cf");
99+
} else {
100+
g.setColor("#002000");
101+
}
90102
g.fillRect(0, 0, g.getWidth(), g.getHeight());
91103

92104
//counter
93105
drawCounter();
94106

95107
//draw level
96108
drawLevelText();
109+
drawPointsText();
97110

98111
//dot
99112
g.setColor("#ff0000");
@@ -152,7 +165,7 @@ function count() {
152165
if (counter <= 0) {
153166
running = false;
154167
clearInterval(drawInterval);
155-
setTimeout(function(){ E.showMessage("Press Button 1\nto restart.", "Gameover!");},50);
168+
setTimeout(function(){ E.showMessage("Press Button 1\nto restart.", "Game over!");},50);
156169
}
157170
}
158171

Loading

apps/balltastic/metadata.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"id": "balltastic",
33
"name": "Balltastic",
4-
"version": "0.02",
4+
"version": "0.03",
55
"description": "Simple but fun ball eats dots game.",
66
"icon": "app.png",
7+
"screenshots": [{"url":"bangle2-balltastic-screenshot.png"}],
78
"type": "app",
89
"tags": "game,fun",
9-
"supports": ["BANGLEJS"],
10+
"supports": ["BANGLEJS","BANGLEJS2"],
1011
"storage": [
1112
{"name":"balltastic.app.js","url":"app.js"},
1213
{"name":"balltastic.img","url":"app-icon.js","evaluate":true}

apps/bthrm/ChangeLog

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@
55
0.03: Prevent readings from internal sensor mixing into BT values
66
Mark events with src property
77
Show actual source of event in app
8+
0.04: Automatically reconnect BT sensor
9+
App buzzes if no BTHRM events for more than 3 seconds

0 commit comments

Comments
 (0)