[pongwars] clean up credits and stuff
This commit is contained in:
parent
513d6c230c
commit
3453efe5c8
@ -52,6 +52,12 @@
|
|||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#instr {
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
#made a {
|
#made a {
|
||||||
color: #172b36;
|
color: #172b36;
|
||||||
}
|
}
|
||||||
@ -62,9 +68,15 @@
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
<canvas id="pongCanvas" width="1200" height="800"></canvas>
|
<canvas id="pongCanvas" width="1200" height="800"></canvas>
|
||||||
<div id="score"></div>
|
<div id="score"></div>
|
||||||
|
<p id="instr">
|
||||||
|
balls can be controlled with number keys
|
||||||
|
</p>
|
||||||
<p id="made">
|
<p id="made">
|
||||||
made by <a href="https://koenvangilst.nl">Koen van Gilst</a> | source on
|
made by <a href="https://koenvangilst.nl">Koen van Gilst</a> | source on
|
||||||
<a href="https://github.com/vnglst/pong-wars">github</a>
|
<a href="https://github.com/vnglst/pong-wars">github</a>
|
||||||
|
<br>
|
||||||
|
patches from dogeystamp | patched source on
|
||||||
|
<a href="https://github.com/dogeystamp/garbage-monorepo/tree/main/pongwars">github</a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
@ -73,11 +85,14 @@
|
|||||||
// Based on: https://github.com/vnglst/pong-wars
|
// Based on: https://github.com/vnglst/pong-wars
|
||||||
// Idea for Pong wars: https://twitter.com/nicolasdnl/status/1749715070928433161
|
// Idea for Pong wars: https://twitter.com/nicolasdnl/status/1749715070928433161
|
||||||
|
|
||||||
|
// This code is patched: see https://github.com/dogeystamp/garbage-monorepo/tree/main/pongwars
|
||||||
|
// Main features added are controlling balls and colors being able to die
|
||||||
|
|
||||||
const canvas = document.getElementById("pongCanvas");
|
const canvas = document.getElementById("pongCanvas");
|
||||||
const ctx = canvas.getContext("2d");
|
const ctx = canvas.getContext("2d");
|
||||||
const scoreElement = document.getElementById("score");
|
const scoreElement = document.getElementById("score");
|
||||||
const startTime = new Date();
|
const startTime = new Date();
|
||||||
var suddenDeathCoeff = 0;
|
var suddenDeathCoeff = 0;
|
||||||
|
|
||||||
const teams = [
|
const teams = [
|
||||||
{
|
{
|
||||||
@ -111,7 +126,7 @@
|
|||||||
score: 0,
|
score: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "yellow",
|
name: "orange",
|
||||||
color: "#ffff55",
|
color: "#ffff55",
|
||||||
backgroundColor: "#aa5500",
|
backgroundColor: "#aa5500",
|
||||||
x: 768,
|
x: 768,
|
||||||
@ -288,7 +303,7 @@
|
|||||||
const coeff = Math.min((teams[color].score/(numSquaresX*numSquaresY/nTeams/mix(1.2, 4, suddenDeathCoeff))), 1.00);
|
const coeff = Math.min((teams[color].score/(numSquaresX*numSquaresY/nTeams/mix(1.2, 4, suddenDeathCoeff))), 1.00);
|
||||||
updatedDx *= coeff;
|
updatedDx *= coeff;
|
||||||
updatedDy *= coeff;
|
updatedDy *= coeff;
|
||||||
const speedLim = mix(30, 18, suddenDeathCoeff)
|
const speedLim = mix(30, 13, suddenDeathCoeff)
|
||||||
const norm = (updatedDx**2 + updatedDy**2)**(1/2)
|
const norm = (updatedDx**2 + updatedDy**2)**(1/2)
|
||||||
const scalar = Math.min(speedLim/norm, 1)
|
const scalar = Math.min(speedLim/norm, 1)
|
||||||
updatedDx *= scalar;
|
updatedDx *= scalar;
|
||||||
@ -328,7 +343,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
scoreElement.textContent = teams
|
scoreElement.textContent = teams
|
||||||
.map((t) => `${t.name} ${t.score}`)
|
.map((t, idx) => `(${idx}) ${t.name} ${t.score}`)
|
||||||
.join(" | ") + (suddenDeathCoeff > 0.1 ? " | sudden death!" : "");
|
.join(" | ") + (suddenDeathCoeff > 0.1 ? " | sudden death!" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user