[pongwars]: misc improvements
- use tab instead of space - warp out of bound balls
This commit is contained in:
parent
32dba49a50
commit
2b6e9ec330
@ -93,7 +93,7 @@
|
|||||||
{
|
{
|
||||||
name: "blue",
|
name: "blue",
|
||||||
color: "#5555ff",
|
color: "#5555ff",
|
||||||
backgroundColor: "#0000aa",
|
backgroundColor: "#200199",
|
||||||
x: 768,
|
x: 768,
|
||||||
y: 256,
|
y: 256,
|
||||||
dx: -8,
|
dx: -8,
|
||||||
@ -164,7 +164,6 @@
|
|||||||
|
|
||||||
var state = teams.map((team) => ({
|
var state = teams.map((team) => ({
|
||||||
elim: false,
|
elim: false,
|
||||||
boost: 1,
|
|
||||||
boostEnabled: false,
|
boostEnabled: false,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
@ -234,6 +233,23 @@
|
|||||||
function updateSquareAndBounce(x, y, dx, dy, color) {
|
function updateSquareAndBounce(x, y, dx, dy, color) {
|
||||||
if (state[color].elim) return
|
if (state[color].elim) return
|
||||||
if (Math.max(Math.abs(dx), Math.abs(dy)) < 0.02) state[color].elim = true
|
if (Math.max(Math.abs(dx), Math.abs(dy)) < 0.02) state[color].elim = true
|
||||||
|
|
||||||
|
if (Math.min(x, y) < 0 || isNaN(x) || isNaN(y)) {
|
||||||
|
console.log(`warped ${teams[color].name}`)
|
||||||
|
teams[color].x = canvas.width * 0.1;
|
||||||
|
teams[color].y = canvas.height * 0.1;
|
||||||
|
dx = 4;
|
||||||
|
dy = 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x > canvas.width || y > canvas.height) {
|
||||||
|
console.log(`warped ${teams[color].name}`)
|
||||||
|
teams[color].x = canvas.width * 0.9;
|
||||||
|
teams[color].y = canvas.height * 0.9;
|
||||||
|
dx = -4;
|
||||||
|
dy = -4;
|
||||||
|
}
|
||||||
|
|
||||||
let updatedDx = dx;
|
let updatedDx = dx;
|
||||||
let updatedDy = dy;
|
let updatedDy = dy;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user