From 474a7253b6b67e2ed33936f6b633587d5d304b66 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Thu, 26 Dec 2024 14:24:53 +0100 Subject: hello kitty stage 1 and 2 done --- src/anticheese.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/anticheese.js (limited to 'src/anticheese.js') diff --git a/src/anticheese.js b/src/anticheese.js new file mode 100644 index 0000000..fc88b8f --- /dev/null +++ b/src/anticheese.js @@ -0,0 +1,25 @@ +import { boshy } from "./main.js" +import { Engine } from "./engine.js" +import { BigDump } from "./entities/bigdump.js" + +const maxTime = 200 +const margin = 30 +let timeH = 0 +let timeV = 0 + +export function update() { + if (boshy.dead) return + + timeH = ( + boshy.position.x > Engine.screen.viewport.x - margin || + boshy.position.x < margin + ) ? timeH + 1 : 0 + + timeV = ( + boshy.position.y > Engine.screen.viewport.y - margin || + boshy.position.y < margin + ) ? timeV + 1 : 0 + + if (timeH == maxTime) new BigDump(false) + if (timeV == maxTime) new BigDump(true) +} -- cgit v1.2.3