diff options
author | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-26 14:24:53 +0100 |
---|---|---|
committer | niliara-edu <nil.jimeno@estudiant.fjaverianas.com> | 2024-12-26 14:24:53 +0100 |
commit | 474a7253b6b67e2ed33936f6b633587d5d304b66 (patch) | |
tree | 456b9cef3cb59da8e0eb575b9425a1fedfe67e1e /src/anticheese.js | |
parent | 1fc522bc8c4a96858223e597ced8fea94ba57874 (diff) |
hello kitty stage 1 and 2 done
Diffstat (limited to 'src/anticheese.js')
-rw-r--r-- | src/anticheese.js | 25 |
1 files changed, 25 insertions, 0 deletions
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) +} |