mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-05-04 18:59:13 -04:00
wip
This commit is contained in:
parent
258d578ad3
commit
9731d694f3
8 changed files with 791 additions and 722 deletions
|
@ -14,6 +14,8 @@ Break colourful bricks, catch bouncing coins and select powerful upgrades !
|
||||||
# Changelog
|
# Changelog
|
||||||
## To do
|
## To do
|
||||||
|
|
||||||
|
- loosing ball is ok if in win timeout period
|
||||||
|
-
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
- delayed start on mobile
|
- delayed start on mobile
|
||||||
|
|
1392
dist/index.html
vendored
1392
dist/index.html
vendored
File diff suppressed because it is too large
Load diff
|
@ -8,7 +8,6 @@
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@purple: #6262ea;
|
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -648,8 +647,12 @@ h2.histogram-title strong {
|
||||||
left: 50vw;
|
left: 50vw;
|
||||||
top: 50vh;
|
top: 50vh;
|
||||||
font-size: 60px;
|
font-size: 60px;
|
||||||
opacity: 0.9;
|
font-weight: bold;
|
||||||
|
opacity: 0.8;
|
||||||
background: none;
|
background: none;
|
||||||
|
text-shadow: 2px 0 #000, -2px 0 #000, 0 2px #000, 0 -2px #000,
|
||||||
|
1px 1px #000, -1px -1px #000, 1px -1px #000, -1px 1px #000;
|
||||||
|
transform: translate(-50%,-50%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +712,7 @@ h2.histogram-title strong {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
> div {
|
> div {
|
||||||
background: @purple;
|
background: @palette_b;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
transform-origin: top left;
|
transform-origin: top left;
|
||||||
|
@ -729,7 +732,7 @@ h2.histogram-title strong {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
background: linear-gradient(-45deg, @purple, transparent);
|
background: linear-gradient(-45deg, @palette_b, transparent);
|
||||||
mix-blend-mode: screen;
|
mix-blend-mode: screen;
|
||||||
opacity: 0.3;
|
opacity: 0.3;
|
||||||
}
|
}
|
||||||
|
@ -739,3 +742,25 @@ h2.histogram-title strong {
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
color: #8a8a8a;
|
color: #8a8a8a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@palette_B:black;
|
||||||
|
@palette_W:#FFFFFF;
|
||||||
|
@palette_g:#231f20;
|
||||||
|
@palette_y:#FFD300;
|
||||||
|
@palette_b:#6262EA;
|
||||||
|
@palette_t:#5DA3EA;
|
||||||
|
@palette_s:#E67070;
|
||||||
|
@palette_r:#e32119;
|
||||||
|
@palette_R:#ab0c0c;
|
||||||
|
@palette_c:#59EEA3;
|
||||||
|
@palette_G:#A1F051;
|
||||||
|
@palette_v:#A664E8;
|
||||||
|
@palette_p:#E869E8;
|
||||||
|
@palette_a:#5BECEC;
|
||||||
|
@palette_C:#53EE53;
|
||||||
|
@palette_S:#F44848;
|
||||||
|
@palette_P:#E66BA8;
|
||||||
|
@palette_O:#F29E4A;
|
||||||
|
@palette_k:#618227;
|
||||||
|
@palette_e:#e1c8b4;
|
||||||
|
@palette_l:#9b9fa;
|
|
@ -82,7 +82,7 @@ import { monitorLevelsUnlocks } from "./monitorLevelsUnlocks";
|
||||||
import { levelEditorMenuEntry } from "./levelEditor";
|
import { levelEditorMenuEntry } from "./levelEditor";
|
||||||
import { categories } from "./upgrades";
|
import { categories } from "./upgrades";
|
||||||
import { reasonLevelIsLocked } from "./get_level_unlock_condition";
|
import { reasonLevelIsLocked } from "./get_level_unlock_condition";
|
||||||
import { toast } from "./toast";
|
import {clearToasts, toast} from "./toast";
|
||||||
|
|
||||||
export async function play() {
|
export async function play() {
|
||||||
if (await applyFullScreenChoice()) return;
|
if (await applyFullScreenChoice()) return;
|
||||||
|
@ -263,8 +263,12 @@ function startPlayCountDown() {
|
||||||
play();
|
play();
|
||||||
}, 3000),
|
}, 3000),
|
||||||
);
|
);
|
||||||
|
timers.push(setTimeout(() => clearToasts(), 3500));
|
||||||
|
|
||||||
}
|
}
|
||||||
function stopPlayCountDown() {
|
function stopPlayCountDown() {
|
||||||
|
if(!timers.length) return
|
||||||
|
clearToasts()
|
||||||
timers.forEach((id) => clearTimeout(id));
|
timers.forEach((id) => clearTimeout(id));
|
||||||
timers.length = 0;
|
timers.length = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {
|
||||||
|
|
||||||
import {
|
import {
|
||||||
brickCenterX,
|
brickCenterX,
|
||||||
brickCenterY,
|
brickCenterY, canvasCenterX,
|
||||||
currentLevelInfo,
|
currentLevelInfo,
|
||||||
distance2,
|
distance2,
|
||||||
distanceBetween,
|
distanceBetween,
|
||||||
|
@ -27,7 +27,7 @@ import {
|
||||||
reachRedRowIndex,
|
reachRedRowIndex,
|
||||||
shouldPierceByColor,
|
shouldPierceByColor,
|
||||||
telekinesisEffectRate,
|
telekinesisEffectRate,
|
||||||
yoyoEffectRate,
|
yoyoEffectRate, zoneLeftBorderX, zoneRightBorderX,
|
||||||
} from "./game_utils";
|
} from "./game_utils";
|
||||||
import { t } from "./i18n/i18n";
|
import { t } from "./i18n/i18n";
|
||||||
|
|
||||||
|
@ -1184,7 +1184,7 @@ export function gameStateTick(
|
||||||
if (
|
if (
|
||||||
gameState.perks.wrap_right > 1 &&
|
gameState.perks.wrap_right > 1 &&
|
||||||
hitBorder % 2 &&
|
hitBorder % 2 &&
|
||||||
coin.previousX > gameState.offsetX + gameState.gameZoneWidth / 2
|
coin.previousX > canvasCenterX(gameState)
|
||||||
) {
|
) {
|
||||||
schedulGameSound(gameState, "plouf", coin.x, 1);
|
schedulGameSound(gameState, "plouf", coin.x, 1);
|
||||||
coin.x = gameState.offsetX + gameState.coinSize;
|
coin.x = gameState.offsetX + gameState.coinSize;
|
||||||
|
@ -1395,7 +1395,7 @@ export function gameStateTick(
|
||||||
if (gameState.perks.wind) {
|
if (gameState.perks.wind) {
|
||||||
const windD =
|
const windD =
|
||||||
((gameState.puckPosition -
|
((gameState.puckPosition -
|
||||||
(gameState.offsetX + gameState.gameZoneWidth / 2)) /
|
canvasCenterX(gameState)) /
|
||||||
gameState.gameZoneWidth) *
|
gameState.gameZoneWidth) *
|
||||||
2 *
|
2 *
|
||||||
gameState.perks.wind;
|
gameState.perks.wind;
|
||||||
|
@ -1529,7 +1529,7 @@ export function gameStateTick(
|
||||||
) {
|
) {
|
||||||
makeParticle(
|
makeParticle(
|
||||||
gameState,
|
gameState,
|
||||||
gameState.offsetXRoundedDown,
|
zoneLeftBorderX(gameState),
|
||||||
Math.random() * gameState.gameZoneHeight,
|
Math.random() * gameState.gameZoneHeight,
|
||||||
5,
|
5,
|
||||||
(Math.random() - 0.5) * 10,
|
(Math.random() - 0.5) * 10,
|
||||||
|
@ -1546,7 +1546,7 @@ export function gameStateTick(
|
||||||
) {
|
) {
|
||||||
makeParticle(
|
makeParticle(
|
||||||
gameState,
|
gameState,
|
||||||
gameState.offsetXRoundedDown + gameState.gameZoneWidth,
|
zoneRightBorderX(gameState),
|
||||||
Math.random() * gameState.gameZoneHeight,
|
Math.random() * gameState.gameZoneHeight,
|
||||||
-5,
|
-5,
|
||||||
(Math.random() - 0.5) * 10,
|
(Math.random() - 0.5) * 10,
|
||||||
|
@ -1694,20 +1694,21 @@ export function ballTick(gameState: GameState, ball: Ball, frames: number) {
|
||||||
|
|
||||||
if (gameState.perks.steering) {
|
if (gameState.perks.steering) {
|
||||||
const delta = gameState.puckPosition - gameState.lastPuckPosition;
|
const delta = gameState.puckPosition - gameState.lastPuckPosition;
|
||||||
const angle =
|
if(Math.abs(delta)>1) {
|
||||||
Math.atan2(ball.vy, ball.vx) +
|
const angle =
|
||||||
((((delta / gameState.gameZoneWidth) * Math.PI) / 2) *
|
Math.atan2(ball.vy, ball.vx) +
|
||||||
gameState.perks.steering *
|
((((delta / gameState.gameZoneWidth) * Math.PI) / 2) *
|
||||||
frames) /
|
gameState.perks.steering *
|
||||||
2;
|
frames) /
|
||||||
const d = Math.sqrt(ball.vy * ball.vy + ball.vx * ball.vx);
|
2;
|
||||||
ball.vy = Math.sin(angle) * d;
|
const d = Math.sqrt(ball.vy * ball.vy + ball.vx * ball.vx);
|
||||||
ball.vx = Math.cos(angle) * d;
|
ball.vy = Math.sin(angle) * d;
|
||||||
console.log({
|
ball.vx = Math.cos(angle) * d;
|
||||||
delta,
|
if (Math.random() < frames && !isOptionOn('basic')) {
|
||||||
angle,
|
makeParticle(gameState, ball.x, ball.y, -ball.vx / 10, -ball.vy / 10,
|
||||||
d,
|
'#6262EA', true, 8, 500)
|
||||||
});
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bounces
|
// Bounces
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { t } from "./i18n/i18n";
|
||||||
import { clamp } from "./pure_functions";
|
import { clamp } from "./pure_functions";
|
||||||
import { getSettingValue, getTotalScore } from "./settings";
|
import { getSettingValue, getTotalScore } from "./settings";
|
||||||
import { isOptionOn } from "./options";
|
import { isOptionOn } from "./options";
|
||||||
|
import {gameCanvas} from "./render";
|
||||||
|
|
||||||
export function describeLevel(level: Level) {
|
export function describeLevel(level: Level) {
|
||||||
let bricks = 0,
|
let bricks = 0,
|
||||||
|
@ -345,3 +346,14 @@ export function escapeAttribute(str: String) {
|
||||||
.replace(/"/gi, """)
|
.replace(/"/gi, """)
|
||||||
.replace(/'/gi, "'");
|
.replace(/'/gi, "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canvasCenterX(gameState:GameState){
|
||||||
|
return gameState.canvasWidth/2
|
||||||
|
}
|
||||||
|
export function zoneLeftBorderX(gameState:GameState){
|
||||||
|
|
||||||
|
return gameState.offsetXRoundedDown - 1
|
||||||
|
}
|
||||||
|
export function zoneRightBorderX(gameState:GameState){
|
||||||
|
return gameCanvas.width - gameState.offsetXRoundedDown + 1
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ import {
|
||||||
max_levels,
|
max_levels,
|
||||||
reachRedRowIndex,
|
reachRedRowIndex,
|
||||||
telekinesisEffectRate,
|
telekinesisEffectRate,
|
||||||
yoyoEffectRate,
|
yoyoEffectRate, zoneLeftBorderX, zoneRightBorderX,
|
||||||
} from "./game_utils";
|
} from "./game_utils";
|
||||||
import { colorString, GameState } from "./types";
|
import { colorString, GameState } from "./types";
|
||||||
import { t } from "./i18n/i18n";
|
import { t } from "./i18n/i18n";
|
||||||
|
@ -517,9 +517,9 @@ export function render(gameState: GameState) {
|
||||||
ctx,
|
ctx,
|
||||||
gameState,
|
gameState,
|
||||||
(redLeftSide && "#FF0000") || "#FFFFFF",
|
(redLeftSide && "#FF0000") || "#FFFFFF",
|
||||||
gameState.offsetXRoundedDown - 1,
|
zoneLeftBorderX(gameState),
|
||||||
0,
|
0,
|
||||||
gameState.offsetXRoundedDown - 1,
|
zoneLeftBorderX(gameState),
|
||||||
height,
|
height,
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
@ -528,9 +528,9 @@ export function render(gameState: GameState) {
|
||||||
ctx,
|
ctx,
|
||||||
gameState,
|
gameState,
|
||||||
(redRightSide && "#FF0000") || "#FFFFFF",
|
(redRightSide && "#FF0000") || "#FFFFFF",
|
||||||
width - gameState.offsetXRoundedDown + 1,
|
zoneRightBorderX(gameState),
|
||||||
0,
|
0,
|
||||||
width - gameState.offsetXRoundedDown + 1,
|
zoneRightBorderX(gameState),
|
||||||
height,
|
height,
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
@ -565,9 +565,9 @@ export function render(gameState: GameState) {
|
||||||
ctx,
|
ctx,
|
||||||
gameState,
|
gameState,
|
||||||
"#FF0000",
|
"#FF0000",
|
||||||
gameState.offsetXRoundedDown,
|
zoneLeftBorderX(gameState),
|
||||||
1,
|
1,
|
||||||
width - gameState.offsetXRoundedDown,
|
zoneRightBorderX(gameState),
|
||||||
1,
|
1,
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
11
src/toast.ts
11
src/toast.ts
|
@ -3,13 +3,16 @@ div.classList = "hidden toast";
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
let timeout: NodeJS.Timeout | undefined;
|
let timeout: NodeJS.Timeout | undefined;
|
||||||
export function toast(html: string, className = "") {
|
export function toast(html: string, className = "") {
|
||||||
|
clearToasts()
|
||||||
div.classList = "toast visible " + className;
|
div.classList = "toast visible " + className;
|
||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
|
timeout = setTimeout(clearToasts, 1500);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearToasts(){
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
|
timeout = undefined
|
||||||
}
|
}
|
||||||
timeout = setTimeout(() => {
|
div.classList = "hidden toast";
|
||||||
timeout = undefined;
|
|
||||||
div.classList = "hidden toast";
|
|
||||||
}, 1500);
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue