mirror of https://github.com/espruino/BangleApps
add readme, remove impurity
parent
35470a151e
commit
e03d33edc1
|
@ -0,0 +1,28 @@
|
|||
# Pong
|
||||
|
||||
A clone of the Atari game Pong
|
||||
|
||||
<img src="https://user-images.githubusercontent.com/702227/79855656-2a507a00-83c3-11ea-9162-65732729b992.png" height="384" width="384" />
|
||||
|
||||
## Features
|
||||
|
||||
- Play against a dumb AI
|
||||
- Play local Multiplayer against your friends
|
||||
|
||||
## Controls
|
||||
|
||||
Player's controls:
|
||||
- UP: BTN1
|
||||
- DOWN: BTN2
|
||||
long press to move faster
|
||||
|
||||
Restart a game:
|
||||
- RESET: BTN3
|
||||
|
||||
Buttons for player 2:
|
||||
- UP: BTN4
|
||||
- DOWN: BTN5
|
||||
|
||||
## Creator
|
||||
|
||||
<https://twitter.com/fredericrous>
|
|
@ -38,12 +38,12 @@ const constrain = (n, low, high) => Math.max(Math.min(n, high), low);
|
|||
const random = (min, max) => Math.random() * (max - min) + min;
|
||||
const intersects = (circ, rect, right) => {
|
||||
var c = circ.pos;
|
||||
c.r = circ.r;
|
||||
if (c.y - c.r < rect.pos.y + rect.height && c.y + c.r > rect.pos.y) {
|
||||
var r = circ.r;
|
||||
if (c.y - r < rect.pos.y + rect.height && c.y + r > rect.pos.y) {
|
||||
if (right) {
|
||||
return c.x + c.r > rect.pos.x - rect.width*2 && c.x < rect.pos.x + rect.width
|
||||
return c.x + r > rect.pos.x - rect.width*2 && c.x < rect.pos.x + rect.width
|
||||
} else {
|
||||
return c.x - c.r < rect.pos.x + rect.width*2 && c.x > rect.pos.x - rect.width
|
||||
return c.x - r < rect.pos.x + rect.width*2 && c.x > rect.pos.x - rect.width
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue