mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-21 12:36:15 -04:00
wip
This commit is contained in:
parent
581ee412d4
commit
ab3e4818db
5 changed files with 67 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
import {Ball, BallLike, Coin, colorString, GameState, PerkId} from "./types";
|
||||
import {Ball, BallLike, Coin, colorString, GameState, PerkId, ReusableArray} from "./types";
|
||||
|
||||
import {
|
||||
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)
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue