User prompt
can you change game's name to 'Shoot The Thiefs'
User prompt
Can you change the level counter to the top right
User prompt
can you change the level counter color the black
User prompt
Can you change the level counter to the top middle
User prompt
and delete the timer when we move next level and when next level is start add the timer
User prompt
can you add a level counter
User prompt
can you delete the laserline asset in when we move on to the new level
User prompt
add other levels and have more thieves in each new level and change the places of the thieves in each level
User prompt
can you change the timer's color to dark blue
User prompt
and delete the timer when the game is over and when game is start add the timer
User prompt
can you change the timer to start with 13
User prompt
End the game when the timer 0
User prompt
and delete the timer when the game is over and when game is start add the timer
User prompt
can you add timer to bottom left
User prompt
can you do thief more light
User prompt
can you change background to a prison
User prompt
Please fix the bug: 'Cannot read properties of null (reading 'y')' in or related to this line: 'timerText.y = tutorialBtn.y + 70;' Line Number: 207
User prompt
can you change the timer place
User prompt
can you add a time countdown
User prompt
can you change the theme to thief police
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of null (setting 'visible')' in or related to this line: 'winText.visible = true;' Line Number: 378
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of null (reading 'visible')' in or related to this line: 'return !tutorialOpen && !winText.visible && power > 0;' Line Number: 279
User prompt
delete the text in lower right corner
User prompt
can you change the goals places
User prompt
please do a tuttorial
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // LaserLine: a segment between two points, visually a rotated rectangle (was NeonLine) var LaserLine = Container.expand(function () { var self = Container.call(this); // Set up endpoints self.x1 = 0; self.y1 = 0; self.x2 = 0; self.y2 = 0; // The visual line asset var lineAsset = self.attachAsset('laserLine', { anchorX: 0.5, anchorY: 0.5 }); // Set endpoints and update position/rotation/length self.setEndpoints = function (x1, y1, x2, y2) { self.x1 = x1; self.y1 = y1; self.x2 = x2; self.y2 = y2; // Center of the line self.x = (x1 + x2) / 2; self.y = (y1 + y2) / 2; // Angle var dx = x2 - x1; var dy = y2 - y1; var len = Math.sqrt(dx * dx + dy * dy); self.rotation = Math.atan2(dy, dx); // Set length lineAsset.width = len; // Simulate glow by alpha pulse lineAsset.alpha = 0.85 + 0.15 * Math.sin(LK.ticks / 8); }; // For update pulse self.update = function () { // Animate glow var lineAsset = self.children[0]; lineAsset.alpha = 0.85 + 0.15 * Math.sin(LK.ticks / 8 + self.x * 0.01 + self.y * 0.01); }; return self; }); // Police: the starting node for laser lines (was PowerSource) var Police = Container.expand(function () { var self = Container.call(this); var policeAsset = self.attachAsset('police', { anchorX: 0.5, anchorY: 0.5 }); // Pulse effect self.update = function () { policeAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 8); }; return self; }); // Thief: a thief to catch (was Device) var Thief = Container.expand(function () { var self = Container.call(this); var thiefAsset = self.attachAsset('thief', { anchorX: 0.5, anchorY: 0.5 }); // Caught state self.caught = false; self.energy = 1; // 1 = not caught, 0 = caught // For pulsing effect when caught self.update = function () { if (self.caught) { thiefAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 6 + self.x * 0.01); } else { thiefAsset.alpha = 0.7; } }; // Flash when caught self.flash = function () { tween(thiefAsset, { tint: 0xffffff }, { duration: 120, onFinish: function onFinish() { tween(thiefAsset, { tint: 0x222222 }, { duration: 200 }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0a0a1a }); /**** * Game Code ****/ // Police blue for tutorial // Police: blue // Laser/rope: police blue // Thief: dark/gray // Thief-Police theme: 'device' is now 'thief', 'powerSource' is 'police', neonLine is a rope/laser // Tutorial button // Police node (was power source) // Thief node (was device) // Laser line segment (was neon line) // --- Game constants --- var GAME_WIDTH = 2048; var GAME_HEIGHT = 2732; var THIEF_COUNT = 5; var POWER_DRAIN_PER_PIXEL = 0.00012; // Power cost per pixel of line var POWER_REGEN_PER_TICK = 0.0002; // Power regen per tick (if desired) var THIEF_ENERGY_LOSS_PER_TICK = 0.0012; // How fast thieves escape var THIEF_CATCH_RADIUS = 100; // px, how close a line endpoint must be to catch var POWER_MIN = 0; var POWER_MAX = 1; // --- Game state --- var power = 1; // Shared power meter (0-1) var thieves = []; var lines = []; var police = null; var drawing = false; var drawStart = null; // {x, y} var drawLine = null; // LaserLine being drawn var drawFromPolice = false; var caughtThieves = 0; var tutorialOpen = false; // --- UI elements --- var powerBarBg = null; var powerBarFg = null; var tutorialBtn = null; var tutorialText = null; var winText = null; // --- Helper functions --- // Clamp value between min and max function clamp(val, min, max) { return Math.max(min, Math.min(max, val)); } // Distance between two points function dist(x1, y1, x2, y2) { var dx = x2 - x1; var dy = y2 - y1; return Math.sqrt(dx * dx + dy * dy); } // Check if a point is inside a device (for connecting) function pointInDevice(x, y, device) { var dx = x - device.x; var dy = y - device.y; var r = device.children[0].width / 2; return dx * dx + dy * dy <= r * r; } // --- UI Setup --- // Power bar (top center, not in top left 100x100) powerBarBg = new Container(); var bgBar = LK.getAsset('neonLine', { width: 600, height: 36, anchorX: 0, anchorY: 0.5 }); bgBar.tint = 0x222244; powerBarBg.addChild(bgBar); powerBarFg = LK.getAsset('neonLine', { width: 600, height: 36, anchorX: 0, anchorY: 0.5 }); powerBarFg.tint = 0x00fff7; powerBarBg.addChild(powerBarFg); powerBarBg.x = (LK.gui.width - 600) / 2; powerBarBg.y = 110; LK.gui.top.addChild(powerBarBg); // Tutorial button (top right, not in top left) tutorialBtn = LK.getAsset('tutorialBtn', { anchorX: 0.5, anchorY: 0.5 }); tutorialBtn.x = LK.gui.width - 120; tutorialBtn.y = 110; LK.gui.top.addChild(tutorialBtn); var tutorialBtnText = new Text2('?', { size: 60, fill: 0xFFFFFF }); tutorialBtnText.anchor.set(0.5, 0.5); tutorialBtnText.x = tutorialBtn.x; tutorialBtnText.y = tutorialBtn.y; LK.gui.top.addChild(tutorialBtnText); // Tutorial popup (hidden by default) tutorialText = new Text2("How to Play:\n\n" + "1. Draw blue police laser lines from the police (bottom) to catch all the thieves (gray circles).\n" + "2. Every laser drains the police's energy meter at the top.\n" + "3. Catch all thieves before the police run out of energy!\n" + "4. Lasers must touch a thief to catch them.\n\n" + "Tip: Plan your path to use as little energy as possible.\n\n" + "Tap the '?' button anytime for help.", { size: 70, fill: 0x1976d2, align: "center", wordWrap: true, wordWrapWidth: 1200 }); tutorialText.anchor.set(0.5, 0.5); tutorialText.x = LK.gui.width / 2; tutorialText.y = LK.gui.height / 2; tutorialText.visible = false; LK.gui.center.addChild(tutorialText); // Win text (hidden by default) // (Removed lower right corner text as requested) // --- Game Setup --- // Place police (bottom center) police = new Police(); police.x = GAME_WIDTH / 2; police.y = GAME_HEIGHT - 300; game.addChild(police); // Place thieves at new fixed positions (example: corners and center top) thieves = []; var thiefPositions = [{ x: 400, y: 600 }, { x: GAME_WIDTH - 400, y: 600 }, { x: 400, y: 1400 }, { x: GAME_WIDTH - 400, y: 1400 }, { x: GAME_WIDTH / 2, y: 300 }]; for (var i = 0; i < THIEF_COUNT; i++) { var t = new Thief(); t.x = thiefPositions[i].x; t.y = thiefPositions[i].y; thieves.push(t); game.addChild(t); } // --- Drawing logic --- // Helper: find thief at (x, y) function findThiefAt(x, y) { for (var i = 0; i < thieves.length; i++) { if (pointInDevice(x, y, thieves[i])) return thieves[i]; } return null; } // Helper: check if a line endpoint is close enough to a thief to catch function thiefInRadius(x, y) { for (var i = 0; i < thieves.length; i++) { if (!thieves[i].caught && dist(x, y, thieves[i].x, thieves[i].y) < THIEF_CATCH_RADIUS) { return thieves[i]; } } return null; } // Helper: check if a point is close to the police function pointNearPolice(x, y) { var dx = x - police.x; var dy = y - police.y; var r = police.children[0].width / 2 + 30; return dx * dx + dy * dy <= r * r; } // --- Input handlers --- // Only allow drawing if not in tutorial or win function canDraw() { // Block all game input if tutorial is open or win text is visible return !tutorialOpen && (!winText || !winText.visible) && power > 0; } // Start drawing: must start from police or a caught thief game.down = function (x, y, obj) { if (tutorialOpen) return; if (!canDraw()) return; // Convert to game coordinates var gx = x, gy = y; // Start from police? if (pointNearPolice(gx, gy)) { drawFromPolice = true; drawStart = { x: police.x, y: police.y }; } else { // Start from caught thief? for (var i = 0; i < thieves.length; i++) { if (thieves[i].caught && pointInDevice(gx, gy, thieves[i])) { drawFromPolice = false; drawStart = { x: thieves[i].x, y: thieves[i].y }; break; } } } if (drawStart) { drawing = true; drawLine = new LaserLine(); drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy); game.addChild(drawLine); } }; // Drawing in progress game.move = function (x, y, obj) { if (tutorialOpen) return; if (!drawing || !drawLine) return; if (!canDraw()) return; var gx = x, gy = y; drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy); // Show line in real time, but don't finalize until up }; // Finish drawing: if endpoint is on an uncaught thief, connect and catch game.up = function (x, y, obj) { if (tutorialOpen) return; if (!drawing || !drawLine) { drawing = false; drawStart = null; return; } if (!canDraw()) { // Remove preview line if (drawLine) { drawLine.destroy(); drawLine = null; } drawing = false; drawStart = null; return; } var gx = x, gy = y; drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy); // Check if endpoint is close to an uncaught thief var targetThief = thiefInRadius(gx, gy); // Only allow connecting to uncaught thief if (targetThief) { // Calculate line length var len = dist(drawStart.x, drawStart.y, targetThief.x, targetThief.y); var cost = len * POWER_DRAIN_PER_PIXEL; if (power >= cost) { // Snap endpoint to thief center drawLine.setEndpoints(drawStart.x, drawStart.y, targetThief.x, targetThief.y); lines.push(drawLine); // Drain power power = clamp(power - cost, POWER_MIN, POWER_MAX); // Catch thief targetThief.caught = true; targetThief.energy = 1; targetThief.flash(); caughtThieves++; // Win condition if (caughtThieves === thieves.length) { if (winText) winText.visible = true; LK.effects.flashScreen(0x1976d2, 1200); LK.setTimeout(function () { LK.showYouWin(); }, 1800); } drawLine = null; drawing = false; drawStart = null; return; } else { // Not enough power, flash bar LK.effects.flashObject(powerBarFg, 0xff0000, 400); } } // Not a valid connection, remove preview line if (drawLine) { drawLine.destroy(); drawLine = null; } drawing = false; drawStart = null; }; // --- Tutorial button handler --- tutorialBtn.down = function (x, y, obj) { if (tutorialOpen) { tutorialText.visible = false; tutorialOpen = false; } else { tutorialText.visible = true; tutorialOpen = true; } }; tutorialBtnText.down = tutorialBtn.down; // Allow tap anywhere on tutorialText to close it tutorialText.down = function (x, y, obj) { if (tutorialOpen) { tutorialText.visible = false; tutorialOpen = false; } }; // --- Game update loop --- game.update = function () { // Update power bar var barW = 600 * power; powerBarFg.width = barW; if (power < 0.18) { powerBarFg.tint = 0xff0033; } else { powerBarFg.tint = 0x00fff7; } // Thieves lose energy if not caught for (var i = 0; i < thieves.length; i++) { var t = thieves[i]; if (!t.caught) { t.energy = clamp(t.energy - THIEF_ENERGY_LOSS_PER_TICK, 0, 1); // If energy runs out, game over (thief escapes) if (t.energy <= 0) { LK.effects.flashScreen(0xff0033, 1200); LK.setTimeout(function () { LK.showGameOver(); }, 1200); return; } } } // Power regen (optional, comment out to disable) // power = clamp(power + POWER_REGEN_PER_TICK, POWER_MIN, POWER_MAX); // Animate lines for (var i = 0; i < lines.length; i++) { if (lines[i].update) lines[i].update(); } // Animate thieves and police for (var i = 0; i < thieves.length; i++) { if (thieves[i].update) thieves[i].update(); } if (police && police.update) police.update(); if (drawLine && drawLine.update) drawLine.update(); }; // --- End of file ---
===================================================================
--- original.js
+++ change.js
@@ -5,53 +5,18 @@
/****
* Classes
****/
-// Device: a cyberpunk device/friend to energize
-var Device = Container.expand(function () {
+// LaserLine: a segment between two points, visually a rotated rectangle (was NeonLine)
+var LaserLine = Container.expand(function () {
var self = Container.call(this);
- var deviceAsset = self.attachAsset('device', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- // Energy state
- self.energized = false;
- self.energy = 1; // 1 = full, 0 = empty
- // For pulsing effect when energized
- self.update = function () {
- if (self.energized) {
- deviceAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 6 + self.x * 0.01);
- } else {
- deviceAsset.alpha = 0.7;
- }
- };
- // Flash when energized
- self.flash = function () {
- tween(deviceAsset, {
- tint: 0xffffff
- }, {
- duration: 120,
- onFinish: function onFinish() {
- tween(deviceAsset, {
- tint: 0xff00c8
- }, {
- duration: 200
- });
- }
- });
- };
- return self;
-});
-// NeonLine: a segment between two points, visually a rotated rectangle
-var NeonLine = Container.expand(function () {
- var self = Container.call(this);
// Set up endpoints
self.x1 = 0;
self.y1 = 0;
self.x2 = 0;
self.y2 = 0;
// The visual line asset
- var lineAsset = self.attachAsset('neonLine', {
+ var lineAsset = self.attachAsset('laserLine', {
anchorX: 0.5,
anchorY: 0.5
});
// Set endpoints and update position/rotation/length
@@ -80,21 +45,56 @@
lineAsset.alpha = 0.85 + 0.15 * Math.sin(LK.ticks / 8 + self.x * 0.01 + self.y * 0.01);
};
return self;
});
-// PowerSource: the starting node for power lines
-var PowerSource = Container.expand(function () {
+// Police: the starting node for laser lines (was PowerSource)
+var Police = Container.expand(function () {
var self = Container.call(this);
- var sourceAsset = self.attachAsset('powerSource', {
+ var policeAsset = self.attachAsset('police', {
anchorX: 0.5,
anchorY: 0.5
});
// Pulse effect
self.update = function () {
- sourceAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 8);
+ policeAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 8);
};
return self;
});
+// Thief: a thief to catch (was Device)
+var Thief = Container.expand(function () {
+ var self = Container.call(this);
+ var thiefAsset = self.attachAsset('thief', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Caught state
+ self.caught = false;
+ self.energy = 1; // 1 = not caught, 0 = caught
+ // For pulsing effect when caught
+ self.update = function () {
+ if (self.caught) {
+ thiefAsset.alpha = 0.95 + 0.05 * Math.sin(LK.ticks / 6 + self.x * 0.01);
+ } else {
+ thiefAsset.alpha = 0.7;
+ }
+ };
+ // Flash when caught
+ self.flash = function () {
+ tween(thiefAsset, {
+ tint: 0xffffff
+ }, {
+ duration: 120,
+ onFinish: function onFinish() {
+ tween(thiefAsset, {
+ tint: 0x222222
+ }, {
+ duration: 200
+ });
+ }
+ });
+ };
+ return self;
+});
/****
* Initialize Game
****/
@@ -104,32 +104,37 @@
/****
* Game Code
****/
+// Police blue for tutorial
+// Police: blue
+// Laser/rope: police blue
+// Thief: dark/gray
+// Thief-Police theme: 'device' is now 'thief', 'powerSource' is 'police', neonLine is a rope/laser
// Tutorial button
-// Power source node
-// Device node (cyberpunk device/friend)
-// Neon line segment (glowing effect simulated by color)
+// Police node (was power source)
+// Thief node (was device)
+// Laser line segment (was neon line)
// --- Game constants ---
var GAME_WIDTH = 2048;
var GAME_HEIGHT = 2732;
-var DEVICE_COUNT = 5;
+var THIEF_COUNT = 5;
var POWER_DRAIN_PER_PIXEL = 0.00012; // Power cost per pixel of line
var POWER_REGEN_PER_TICK = 0.0002; // Power regen per tick (if desired)
-var DEVICE_ENERGY_LOSS_PER_TICK = 0.0012; // How fast devices lose energy
-var DEVICE_ENERGIZE_RADIUS = 100; // px, how close a line endpoint must be to energize
+var THIEF_ENERGY_LOSS_PER_TICK = 0.0012; // How fast thieves escape
+var THIEF_CATCH_RADIUS = 100; // px, how close a line endpoint must be to catch
var POWER_MIN = 0;
var POWER_MAX = 1;
// --- Game state ---
var power = 1; // Shared power meter (0-1)
-var devices = [];
+var thieves = [];
var lines = [];
-var powerSource = null;
+var police = null;
var drawing = false;
var drawStart = null; // {x, y}
-var drawLine = null; // NeonLine being drawn
-var drawFromSource = false;
-var energizedDevices = 0;
+var drawLine = null; // LaserLine being drawn
+var drawFromPolice = false;
+var caughtThieves = 0;
var tutorialOpen = false;
// --- UI elements ---
var powerBarBg = null;
var powerBarFg = null;
@@ -192,11 +197,11 @@
tutorialBtnText.x = tutorialBtn.x;
tutorialBtnText.y = tutorialBtn.y;
LK.gui.top.addChild(tutorialBtnText);
// Tutorial popup (hidden by default)
-tutorialText = new Text2("How to Play:\n\n" + "1. Draw neon lines from the green power source to pink devices (your friends).\n" + "2. Every line drains the shared power meter at the top.\n" + "3. Connect all devices before power runs out!\n" + "4. Lines must touch a device to energize it.\n\n" + "Tip: Plan your path to use as little power as possible.\n\n" + "Tap the '?' button anytime for help.", {
+tutorialText = new Text2("How to Play:\n\n" + "1. Draw blue police laser lines from the police (bottom) to catch all the thieves (gray circles).\n" + "2. Every laser drains the police's energy meter at the top.\n" + "3. Catch all thieves before the police run out of energy!\n" + "4. Lasers must touch a thief to catch them.\n\n" + "Tip: Plan your path to use as little energy as possible.\n\n" + "Tap the '?' button anytime for help.", {
size: 70,
- fill: 0x00FFF7,
+ fill: 0x1976d2,
align: "center",
wordWrap: true,
wordWrapWidth: 1200
});
@@ -207,16 +212,16 @@
LK.gui.center.addChild(tutorialText);
// Win text (hidden by default)
// (Removed lower right corner text as requested)
// --- Game Setup ---
-// Place power source (bottom center)
-powerSource = new PowerSource();
-powerSource.x = GAME_WIDTH / 2;
-powerSource.y = GAME_HEIGHT - 300;
-game.addChild(powerSource);
-// Place devices at new fixed positions (example: corners and center top)
-devices = [];
-var devicePositions = [{
+// Place police (bottom center)
+police = new Police();
+police.x = GAME_WIDTH / 2;
+police.y = GAME_HEIGHT - 300;
+game.addChild(police);
+// Place thieves at new fixed positions (example: corners and center top)
+thieves = [];
+var thiefPositions = [{
x: 400,
y: 600
}, {
x: GAME_WIDTH - 400,
@@ -230,75 +235,75 @@
}, {
x: GAME_WIDTH / 2,
y: 300
}];
-for (var i = 0; i < DEVICE_COUNT; i++) {
- var d = new Device();
- d.x = devicePositions[i].x;
- d.y = devicePositions[i].y;
- devices.push(d);
- game.addChild(d);
+for (var i = 0; i < THIEF_COUNT; i++) {
+ var t = new Thief();
+ t.x = thiefPositions[i].x;
+ t.y = thiefPositions[i].y;
+ thieves.push(t);
+ game.addChild(t);
}
// --- Drawing logic ---
-// Helper: find device at (x, y)
-function findDeviceAt(x, y) {
- for (var i = 0; i < devices.length; i++) {
- if (pointInDevice(x, y, devices[i])) return devices[i];
+// Helper: find thief at (x, y)
+function findThiefAt(x, y) {
+ for (var i = 0; i < thieves.length; i++) {
+ if (pointInDevice(x, y, thieves[i])) return thieves[i];
}
return null;
}
-// Helper: check if a line endpoint is close enough to a device to energize
-function deviceInRadius(x, y) {
- for (var i = 0; i < devices.length; i++) {
- if (!devices[i].energized && dist(x, y, devices[i].x, devices[i].y) < DEVICE_ENERGIZE_RADIUS) {
- return devices[i];
+// Helper: check if a line endpoint is close enough to a thief to catch
+function thiefInRadius(x, y) {
+ for (var i = 0; i < thieves.length; i++) {
+ if (!thieves[i].caught && dist(x, y, thieves[i].x, thieves[i].y) < THIEF_CATCH_RADIUS) {
+ return thieves[i];
}
}
return null;
}
-// Helper: check if a point is close to the power source
-function pointNearPowerSource(x, y) {
- var dx = x - powerSource.x;
- var dy = y - powerSource.y;
- var r = powerSource.children[0].width / 2 + 30;
+// Helper: check if a point is close to the police
+function pointNearPolice(x, y) {
+ var dx = x - police.x;
+ var dy = y - police.y;
+ var r = police.children[0].width / 2 + 30;
return dx * dx + dy * dy <= r * r;
}
// --- Input handlers ---
// Only allow drawing if not in tutorial or win
function canDraw() {
// Block all game input if tutorial is open or win text is visible
return !tutorialOpen && (!winText || !winText.visible) && power > 0;
}
-// Start drawing: must start from power source or an energized device
+// Start drawing: must start from police or a caught thief
game.down = function (x, y, obj) {
if (tutorialOpen) return;
if (!canDraw()) return;
// Convert to game coordinates
var gx = x,
gy = y;
- // Start from power source?
- if (pointNearPowerSource(gx, gy)) {
- drawFromSource = true;
+ // Start from police?
+ if (pointNearPolice(gx, gy)) {
+ drawFromPolice = true;
drawStart = {
- x: powerSource.x,
- y: powerSource.y
+ x: police.x,
+ y: police.y
};
} else {
- // Start from energized device?
- for (var i = 0; i < devices.length; i++) {
- if (devices[i].energized && pointInDevice(gx, gy, devices[i])) {
- drawFromSource = false;
+ // Start from caught thief?
+ for (var i = 0; i < thieves.length; i++) {
+ if (thieves[i].caught && pointInDevice(gx, gy, thieves[i])) {
+ drawFromPolice = false;
drawStart = {
- x: devices[i].x,
- y: devices[i].y
+ x: thieves[i].x,
+ y: thieves[i].y
};
break;
}
}
}
if (drawStart) {
drawing = true;
- drawLine = new NeonLine();
+ drawLine = new LaserLine();
drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy);
game.addChild(drawLine);
}
};
@@ -311,9 +316,9 @@
gy = y;
drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy);
// Show line in real time, but don't finalize until up
};
-// Finish drawing: if endpoint is on an unenergized device, connect and energize
+// Finish drawing: if endpoint is on an uncaught thief, connect and catch
game.up = function (x, y, obj) {
if (tutorialOpen) return;
if (!drawing || !drawLine) {
drawing = false;
@@ -332,30 +337,30 @@
}
var gx = x,
gy = y;
drawLine.setEndpoints(drawStart.x, drawStart.y, gx, gy);
- // Check if endpoint is close to an unenergized device
- var targetDevice = deviceInRadius(gx, gy);
- // Only allow connecting to unenergized device
- if (targetDevice) {
+ // Check if endpoint is close to an uncaught thief
+ var targetThief = thiefInRadius(gx, gy);
+ // Only allow connecting to uncaught thief
+ if (targetThief) {
// Calculate line length
- var len = dist(drawStart.x, drawStart.y, targetDevice.x, targetDevice.y);
+ var len = dist(drawStart.x, drawStart.y, targetThief.x, targetThief.y);
var cost = len * POWER_DRAIN_PER_PIXEL;
if (power >= cost) {
- // Snap endpoint to device center
- drawLine.setEndpoints(drawStart.x, drawStart.y, targetDevice.x, targetDevice.y);
+ // Snap endpoint to thief center
+ drawLine.setEndpoints(drawStart.x, drawStart.y, targetThief.x, targetThief.y);
lines.push(drawLine);
// Drain power
power = clamp(power - cost, POWER_MIN, POWER_MAX);
- // Energize device
- targetDevice.energized = true;
- targetDevice.energy = 1;
- targetDevice.flash();
- energizedDevices++;
+ // Catch thief
+ targetThief.caught = true;
+ targetThief.energy = 1;
+ targetThief.flash();
+ caughtThieves++;
// Win condition
- if (energizedDevices === devices.length) {
+ if (caughtThieves === thieves.length) {
if (winText) winText.visible = true;
- LK.effects.flashScreen(0x00fff7, 1200);
+ LK.effects.flashScreen(0x1976d2, 1200);
LK.setTimeout(function () {
LK.showYouWin();
}, 1800);
}
@@ -403,15 +408,15 @@
powerBarFg.tint = 0xff0033;
} else {
powerBarFg.tint = 0x00fff7;
}
- // Devices lose energy if not energized
- for (var i = 0; i < devices.length; i++) {
- var d = devices[i];
- if (!d.energized) {
- d.energy = clamp(d.energy - DEVICE_ENERGY_LOSS_PER_TICK, 0, 1);
- // If energy runs out, game over
- if (d.energy <= 0) {
+ // Thieves lose energy if not caught
+ for (var i = 0; i < thieves.length; i++) {
+ var t = thieves[i];
+ if (!t.caught) {
+ t.energy = clamp(t.energy - THIEF_ENERGY_LOSS_PER_TICK, 0, 1);
+ // If energy runs out, game over (thief escapes)
+ if (t.energy <= 0) {
LK.effects.flashScreen(0xff0033, 1200);
LK.setTimeout(function () {
LK.showGameOver();
}, 1200);
@@ -424,12 +429,12 @@
// Animate lines
for (var i = 0; i < lines.length; i++) {
if (lines[i].update) lines[i].update();
}
- // Animate devices and power source
- for (var i = 0; i < devices.length; i++) {
- if (devices[i].update) devices[i].update();
+ // Animate thieves and police
+ for (var i = 0; i < thieves.length; i++) {
+ if (thieves[i].update) thieves[i].update();
}
- if (powerSource && powerSource.update) powerSource.update();
+ if (police && police.update) police.update();
if (drawLine && drawLine.update) drawLine.update();
};
// --- End of file ---
\ No newline at end of file
bullets arranged from top to bottom. In-Game asset. 2d. High contrast. No shadows
a topdown policeman and he's pointing a gun. In-Game asset. 2d. High contrast. No shadows. In-Game asset. 2d. High contrast. No shadows
topdown thief. In-Game asset. 2d. High contrast. No shadows
a top down white black theme prison. In-Game asset. 2d. High contrast. No shadows. In-Game asset. 2d. High contrast. No shadows