mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 04:26:14 -04:00
See fixes in readme
This commit is contained in:
parent
92a0edabef
commit
9958717260
10 changed files with 210 additions and 89 deletions
|
@ -1,6 +1,7 @@
|
|||
import { Ball, GameState, Level, PerkId, PerksMap } from "./types";
|
||||
import { icons, upgrades } from "./loadGameData";
|
||||
import { t } from "./i18n/i18n";
|
||||
import {brickAt} from "./level_editor/levels_editor_util";
|
||||
|
||||
export function describeLevel(level: Level) {
|
||||
let bricks = 0,
|
||||
|
@ -131,6 +132,31 @@ export function currentLevelInfo(gameState: GameState) {
|
|||
return gameState.level;
|
||||
}
|
||||
|
||||
export function isPickyEatingPossible(gameState: GameState){
|
||||
return gameState.bricks.indexOf(gameState.ballsColor)!==-1
|
||||
}
|
||||
|
||||
export function reachRedRowIndex(gameState: GameState){
|
||||
if(!gameState.perks.reach) return -1
|
||||
const {size}=gameState.level
|
||||
let minY=-1, maxY=-1, maxYCount=-1;
|
||||
for(let y=0;y<size;y++)
|
||||
for(let x=0;x<size;x++)
|
||||
if(gameState.bricks[x+y*size]){
|
||||
if(minY==-1) minY=y
|
||||
if(maxY<y) {
|
||||
maxY = y
|
||||
maxYCount = 0
|
||||
}
|
||||
if(maxY==y) maxYCount++
|
||||
}
|
||||
|
||||
if(maxY<1) return -1
|
||||
if(maxY==minY) return -1
|
||||
if(maxYCount===size) return -1
|
||||
return maxY
|
||||
}
|
||||
|
||||
export function isTelekinesisActive(gameState: GameState, ball: Ball) {
|
||||
return gameState.perks.telekinesis && ball.vy < 0;
|
||||
}
|
||||
|
@ -206,28 +232,28 @@ export function shouldPierceByColor(
|
|||
return true;
|
||||
}
|
||||
|
||||
export function countBricksAbove(gameState: GameState, index: number) {
|
||||
const col = index % gameState.gridSize;
|
||||
const row = Math.floor(index / gameState.gridSize);
|
||||
let count = 0;
|
||||
for (let y = 0; y < row; y++) {
|
||||
if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
export function countBricksBelow(gameState: GameState, index: number) {
|
||||
const col = index % gameState.gridSize;
|
||||
const row = Math.floor(index / gameState.gridSize);
|
||||
let count = 0;
|
||||
for (let y = row + 1; y < gameState.gridSize; y++) {
|
||||
if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
// export function countBricksAbove(gameState: GameState, index: number) {
|
||||
// const col = index % gameState.gridSize;
|
||||
// const row = Math.floor(index / gameState.gridSize);
|
||||
// let count = 0;
|
||||
// for (let y = 0; y < row; y++) {
|
||||
// if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// return count;
|
||||
// }
|
||||
// export function countBricksBelow(gameState: GameState, index: number) {
|
||||
// const col = index % gameState.gridSize;
|
||||
// const row = Math.floor(index / gameState.gridSize);
|
||||
// let count = 0;
|
||||
// for (let y = row + 1; y < gameState.gridSize; y++) {
|
||||
// if (gameState.bricks[col + y * gameState.gridSize]) {
|
||||
// count++;
|
||||
// }
|
||||
// }
|
||||
// return count;
|
||||
// }
|
||||
export function highScoreForMode(mode: GameState["mode"]) {
|
||||
try {
|
||||
const score = parseInt(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue