mirror of https://github.com/espruino/BangleApps
Asteroids - increased ship, asteroids and font size
parent
918be9e7bb
commit
7b8cfeb6ed
|
@ -1,2 +1,3 @@
|
||||||
0.02: Add "ram" keyword to allow 2v06 Espruino builds to cache function that needs to be fast
|
0.02: Add "ram" keyword to allow 2v06 Espruino builds to cache function that needs to be fast
|
||||||
0.03: Bangle 2 support
|
0.03: Bangle 2 support
|
||||||
|
0.04: Increase size if ship, asteroids and fonts for better readability
|
||||||
|
|
|
@ -18,6 +18,10 @@ if (process.env.HWVERSION==2) {
|
||||||
}
|
}
|
||||||
var W = g.getWidth();
|
var W = g.getWidth();
|
||||||
var H = g.getHeight();
|
var H = g.getHeight();
|
||||||
|
var SS = W/11; // ship back length
|
||||||
|
var SL = W/15; // ship side length
|
||||||
|
var AS = W/18; // asteroid radius
|
||||||
|
|
||||||
g.clear().setFontAlign(0,-1);
|
g.clear().setFontAlign(0,-1);
|
||||||
|
|
||||||
function newAst(x,y) {
|
function newAst(x,y) {
|
||||||
|
@ -25,7 +29,7 @@ function newAst(x,y) {
|
||||||
x:x,y:y,
|
x:x,y:y,
|
||||||
vx:Math.random()-0.5,
|
vx:Math.random()-0.5,
|
||||||
vy:Math.random()-0.5,
|
vy:Math.random()-0.5,
|
||||||
rad:3+Math.random()*5
|
rad:3+Math.random()*AS
|
||||||
};
|
};
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +46,9 @@ var lastFrame;
|
||||||
function gameStop() {
|
function gameStop() {
|
||||||
running = false;
|
running = false;
|
||||||
g.clear();
|
g.clear();
|
||||||
g.drawString("Game Over!",120,(H-6)/2);
|
g.setFont('Vector', W/7);
|
||||||
|
g.setFontAlign(0,0);
|
||||||
|
g.drawString("Game Over!", W/2, H/2);
|
||||||
g.flip();
|
g.flip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,12 +110,13 @@ function onFrame() {
|
||||||
}
|
}
|
||||||
|
|
||||||
g.clear();
|
g.clear();
|
||||||
g.drawString(score,W-20,0);
|
g.setFont('Vector', 16);
|
||||||
|
g.drawString(score,W-20,16);
|
||||||
var rs = Math.PI*0.8;
|
var rs = Math.PI*0.8;
|
||||||
g.drawPoly([
|
g.drawPoly([
|
||||||
ship.x+Math.cos(ship.r)*4, ship.y+Math.sin(ship.r)*4,
|
ship.x+Math.cos(ship.r)*SS, ship.y+Math.sin(ship.r)*SS,
|
||||||
ship.x+Math.cos(ship.r+rs)*3, ship.y+Math.sin(ship.r+rs)*3,
|
ship.x+Math.cos(ship.r+rs)*SL, ship.y+Math.sin(ship.r+rs)*SL,
|
||||||
ship.x+Math.cos(ship.r-rs)*3, ship.y+Math.sin(ship.r-rs)*3,
|
ship.x+Math.cos(ship.r-rs)*SL, ship.y+Math.sin(ship.r-rs)*SL,
|
||||||
],true);
|
],true);
|
||||||
var na = [];
|
var na = [];
|
||||||
ammo.forEach(function(a) {
|
ammo.forEach(function(a) {
|
||||||
|
|
Loading…
Reference in New Issue