Asteroids - increased ship, asteroids and font size

pull/2983/head
Hugh Barney 2023-08-19 18:48:03 +01:00
parent 918be9e7bb
commit 7b8cfeb6ed
2 changed files with 14 additions and 6 deletions

View File

@ -1,2 +1,3 @@
0.02: Add "ram" keyword to allow 2v06 Espruino builds to cache function that needs to be fast
0.03: Bangle 2 support
0.04: Increase size if ship, asteroids and fonts for better readability

View File

@ -18,6 +18,10 @@ if (process.env.HWVERSION==2) {
}
var W = g.getWidth();
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);
function newAst(x,y) {
@ -25,7 +29,7 @@ function newAst(x,y) {
x:x,y:y,
vx:Math.random()-0.5,
vy:Math.random()-0.5,
rad:3+Math.random()*5
rad:3+Math.random()*AS
};
return a;
}
@ -42,7 +46,9 @@ var lastFrame;
function gameStop() {
running = false;
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();
}
@ -104,12 +110,13 @@ function onFrame() {
}
g.clear();
g.drawString(score,W-20,0);
g.setFont('Vector', 16);
g.drawString(score,W-20,16);
var rs = Math.PI*0.8;
g.drawPoly([
ship.x+Math.cos(ship.r)*4, ship.y+Math.sin(ship.r)*4,
ship.x+Math.cos(ship.r+rs)*3, ship.y+Math.sin(ship.r+rs)*3,
ship.x+Math.cos(ship.r-rs)*3, ship.y+Math.sin(ship.r-rs)*3,
ship.x+Math.cos(ship.r)*SS, ship.y+Math.sin(ship.r)*SS,
ship.x+Math.cos(ship.r+rs)*SL, ship.y+Math.sin(ship.r+rs)*SL,
ship.x+Math.cos(ship.r-rs)*SL, ship.y+Math.sin(ship.r-rs)*SL,
],true);
var na = [];
ammo.forEach(function(a) {