mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 12:15:06 -04:00
wip
This commit is contained in:
parent
581ee412d4
commit
ab3e4818db
5 changed files with 67 additions and 10 deletions
|
@ -23,9 +23,7 @@ There's also an easy mode for kids (slower ball).
|
||||||
|
|
||||||
# Next
|
# Next
|
||||||
|
|
||||||
- extract sound logic, only set the params as a gamestate object
|
- separate particles by type, reuse coins and particles
|
||||||
- separate particles by type
|
|
||||||
- reuse coins and particles
|
|
||||||
- sturdy bricks map of remaining hits
|
- sturdy bricks map of remaining hits
|
||||||
|
|
||||||
# bugs
|
# bugs
|
||||||
|
|
29
dist/index.html
vendored
29
dist/index.html
vendored
|
@ -2919,6 +2919,17 @@ function ballTick(gameState, ball, delta) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function append(makeItem, where) {
|
||||||
|
while(where.list[where.indexMin] && !where.list[where.indexMin].destroyed && where.indexMin < where.list.length)where.indexMin++;
|
||||||
|
if (where.indexMin < where.list.length) {
|
||||||
|
makeItem(where.list[where.indexMin]);
|
||||||
|
where.indexMin++;
|
||||||
|
} else where.list.push(makeItem(null));
|
||||||
|
}
|
||||||
|
function destroy(where, index) {
|
||||||
|
where.list[index].destroyed = true;
|
||||||
|
where.indexMin = Math.min(where.indexMin, index);
|
||||||
|
}
|
||||||
|
|
||||||
},{"./game_utils":"cEeac","./i18n/i18n":"eNPRm","./loadGameData":"l1B4x","./settings":"5blfu","./render":"9AS2t","./gameOver":"caCAf","./game":"edeGs","./recording":"godmD","./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"9AS2t":[function(require,module,exports,__globalThis) {
|
},{"./game_utils":"cEeac","./i18n/i18n":"eNPRm","./loadGameData":"l1B4x","./settings":"5blfu","./render":"9AS2t","./gameOver":"caCAf","./game":"edeGs","./recording":"godmD","./options":"d5NoS","@parcel/transformer-js/src/esmodule-helpers.js":"gkKU3"}],"9AS2t":[function(require,module,exports,__globalThis) {
|
||||||
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||||||
|
@ -3762,8 +3773,22 @@ function newGameState(params) {
|
||||||
balls: [],
|
balls: [],
|
||||||
ballsColor: "white",
|
ballsColor: "white",
|
||||||
bricks: [],
|
bricks: [],
|
||||||
flashes: [],
|
lights: {
|
||||||
coins: [],
|
indexMin: 0,
|
||||||
|
list: []
|
||||||
|
},
|
||||||
|
particles: {
|
||||||
|
indexMin: 0,
|
||||||
|
list: []
|
||||||
|
},
|
||||||
|
texts: {
|
||||||
|
indexMin: 0,
|
||||||
|
list: []
|
||||||
|
},
|
||||||
|
coins: {
|
||||||
|
indexMin: 0,
|
||||||
|
list: []
|
||||||
|
},
|
||||||
levelStartScore: 0,
|
levelStartScore: 0,
|
||||||
levelMisses: 0,
|
levelMisses: 0,
|
||||||
levelSpawnedCoins: 0,
|
levelSpawnedCoins: 0,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {Ball, BallLike, Coin, colorString, GameState, PerkId} from "./types";
|
import {Ball, BallLike, Coin, colorString, GameState, PerkId, ReusableArray} from "./types";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
brickCenterX,
|
brickCenterX,
|
||||||
|
@ -1244,3 +1244,23 @@ export function ballTick(gameState: GameState, ball: Ball, delta: number) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function append<T>(makeItem:(match:T|null)=>T,where:ReusableArray<T>){
|
||||||
|
while(where.list[where.indexMin] && !where.list[where.indexMin].destroyed
|
||||||
|
&& where.indexMin<where.list.length){
|
||||||
|
where.indexMin++
|
||||||
|
}
|
||||||
|
|
||||||
|
if(where.indexMin<where.list.length){
|
||||||
|
makeItem(where.list[where.indexMin])
|
||||||
|
where.indexMin++
|
||||||
|
}else{
|
||||||
|
where.list.push(makeItem(null))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function destroy<T>(where:ReusableArray<T>, index:number){
|
||||||
|
where.list[index].destroyed=true
|
||||||
|
where.indexMin = Math.min(where.indexMin, index)
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import {defaultSounds, getPossibleUpgrades, makeEmptyPerksMap, sumOfKeys,} from
|
||||||
import {dontOfferTooSoon, resetBalls} from "./gameStateMutators";
|
import {dontOfferTooSoon, resetBalls} from "./gameStateMutators";
|
||||||
import {isOptionOn} from "./options";
|
import {isOptionOn} from "./options";
|
||||||
|
|
||||||
|
|
||||||
export function newGameState(params: RunParams): GameState {
|
export function newGameState(params: RunParams): GameState {
|
||||||
const totalScoreAtRunStart = getTotalScore();
|
const totalScoreAtRunStart = getTotalScore();
|
||||||
const firstLevel = params?.level
|
const firstLevel = params?.level
|
||||||
|
@ -49,8 +50,10 @@ export function newGameState(params: RunParams): GameState {
|
||||||
balls: [],
|
balls: [],
|
||||||
ballsColor: "white",
|
ballsColor: "white",
|
||||||
bricks: [],
|
bricks: [],
|
||||||
flashes: [],
|
lights: {indexMin:0,list:[]},
|
||||||
coins: [],
|
particles: {indexMin:0,list:[]},
|
||||||
|
texts: {indexMin:0,list:[]},
|
||||||
|
coins: {indexMin:0,list:[]},
|
||||||
levelStartScore: 0,
|
levelStartScore: 0,
|
||||||
levelMisses: 0,
|
levelMisses: 0,
|
||||||
levelSpawnedCoins: 0,
|
levelSpawnedCoins: 0,
|
||||||
|
|
15
src/types.d.ts
vendored
15
src/types.d.ts
vendored
|
@ -150,6 +150,13 @@ export type PerksMap = {
|
||||||
[k in PerkId]: number;
|
[k in PerkId]: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO ensure T has a destroyed;boolean field
|
||||||
|
export type ReusableArray<T> = {
|
||||||
|
// All items below that index should not be destroyed
|
||||||
|
indexMin:number;
|
||||||
|
list:T[]
|
||||||
|
}
|
||||||
|
|
||||||
export type RunHistoryItem = RunStats & {
|
export type RunHistoryItem = RunStats & {
|
||||||
perks?: PerksMap;
|
perks?: PerksMap;
|
||||||
appVersion?: string;
|
appVersion?: string;
|
||||||
|
@ -213,8 +220,12 @@ export type GameState = {
|
||||||
// Array of bricks to display. 'black' means bomb. '' means no brick.
|
// Array of bricks to display. 'black' means bomb. '' means no brick.
|
||||||
bricks: colorString[];
|
bricks: colorString[];
|
||||||
|
|
||||||
flashes: Flash[];
|
|
||||||
coins: Coin[];
|
|
||||||
|
particles: ReusableArray<ParticleFlash>
|
||||||
|
texts: ReusableArray<TextFlash>
|
||||||
|
lights: ReusableArray<BallFlash>
|
||||||
|
coins: ReusableArray<Coin>;
|
||||||
levelStartScore: number;
|
levelStartScore: number;
|
||||||
levelMisses: number;
|
levelMisses: number;
|
||||||
levelSpawnedCoins: number;
|
levelSpawnedCoins: number;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue