mirror of https://github.com/espruino/BangleApps
Asteroids - improved collision detected for larger ship v astroid
parent
7b8cfeb6ed
commit
2e3ee8cbc3
|
@ -1,3 +1,4 @@
|
|||
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
|
||||
0.05: improve collision detect for larger ship v astroid
|
||||
|
|
|
@ -21,6 +21,9 @@ var H = g.getHeight();
|
|||
var SS = W/11; // ship back length
|
||||
var SL = W/15; // ship side length
|
||||
var AS = W/18; // asteroid radius
|
||||
// radius of ship, assumed a circle inside equilateral traingle of side SS
|
||||
// r = a / root 3 where a is length of equilateral triangle
|
||||
var SR = SS / Math.sqrt(3);
|
||||
|
||||
g.clear().setFontAlign(0,-1);
|
||||
|
||||
|
@ -45,7 +48,7 @@ var lastFrame;
|
|||
|
||||
function gameStop() {
|
||||
running = false;
|
||||
g.clear();
|
||||
//g.clear();
|
||||
g.setFont('Vector', W/7);
|
||||
g.setFontAlign(0,0);
|
||||
g.drawString("Game Over!", W/2, H/2);
|
||||
|
@ -172,7 +175,7 @@ function onFrame() {
|
|||
var dx = a.x-ship.x;
|
||||
var dy = a.y-ship.y;
|
||||
var d = Math.sqrt(dx*dx+dy*dy);
|
||||
if (d < a.rad) crashed = true;
|
||||
if (d < a.rad + SR) crashed = true;
|
||||
});
|
||||
ast=na;
|
||||
if (!ast.length) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "astroid",
|
||||
"name": "Asteroids!",
|
||||
"version": "0.03",
|
||||
"version": "0.05",
|
||||
"description": "Retro asteroids game",
|
||||
"icon": "asteroids.png",
|
||||
"screenshots": [{"url":"screenshot_asteroids.png"}],
|
||||
|
|
Loading…
Reference in New Issue