summaryrefslogtreecommitdiff
path: root/src/anticheese.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/anticheese.js')
-rw-r--r--src/anticheese.js25
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)
+}