This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get currentScreenPx(): number { | |
const currentPointerSwipes = this.uiPosition / OREO_HEIGHT_PX; | |
const currentLevel = getCurrentLevelBySwipes(currentPointerSwipes); | |
const passedSwipes = currentPointerSwipes - currentLevel.swipes; | |
const startProgress = Math.min( | |
1, | |
passedSwipes / currentLevel.startSwipesRequired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TowerBlock | |
if (index === total) { | |
return oreos; // Rendering cookies | |
} | |
return ( | |
<Tower | |
style={{ | |
marginBottom: `${baseHeight / total + (index === 0 ? 50 : 0)}px`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@computed | |
get totalUiTowerBlocks(): number { | |
return Math.ceil(this.game.swipes / 1000000); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@computed | |
get invisibleHeight(): number { | |
const [minIndex] = this.cachedVisibleIndexes; | |
return minIndex * OREO_HEIGHT_PX; | |
} | |
<Tower | |
style={{ | |
marginBottom: `${gameUi.invisibleHeight}px`, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GameUi | |
export const OVERSCAN = 100; | |
export const OVERSCAN_THRESHOLD = OVERSCAN * 0.8; | |
@action.bound | |
_updateVisibleIndexesImmediately = (): void => { | |
const minVisibleIndex = Math.max( | |
0, | |
Math.floor(this.uiPosition / OREO_HEIGHT_PX) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [{ y }, set] = useSpring(() => ({ | |
y: gameUi.uiPosition, | |
})); | |
<Tower | |
style={{ | |
transform: y.to( | |
(v: number) => `translate3d(0, ${v}px, 0)` | |
), | |
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
get miniTowerPosition(): number { | |
if (this.towerHeight === 0) { | |
return 0; | |
} | |
const uiPositionPercent = this.uiPosition / this.towerHeight; | |
return uiPositionPercent * this.miniTowerHeight; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@action | |
moveGame(deltaY: number): void { | |
if (Math.abs(deltaY) > 0) { | |
this.uiPosition = Math.min( | |
Math.max(0, this.uiPosition + deltaY), | |
Math.max( | |
0, | |
this.game.swipes * OREO_HEIGHT_PX - | |
windowHeight / 3 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Oreo | |
isNew={ | |
(i + gameUi.newDiffCount >= gameStore.swipes) && gameUi.uiInteraction | |
} | |
/> | |
OreoWrapper = styled.div<{ isNew?: boolean }>` | |
transition: all ${NEW_OREO_ANIMATION_TIME}ms linear, | |
opacity ${NEW_OREO_ANIMATION_TIME / 3}ms linear; | |
opacity: 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GameStore | |
@action.bound | |
click(): void { | |
this.swipes += this.swipePower; // Amount of cookies per one swipe | |
this.rootStore.wsConnect | |
.sendMessage(WSSendEvent.swipe, { times: 1 }) | |
this.gameUI.update({ count: this.swipePower }); |
NewerOlder