/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Button class
var Button = Container.expand(function () {
var self = Container.call(this);
var buttonGraphics = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 200;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
buttons.push(self);
self.down = function (x, y, obj) {
spawnRandomButton();
};
return self;
});
// ChaosButton class
var ChaosButton = Container.expand(function () {
var self = Container.call(this);
var chaosButtonGraphics = self.attachAsset('chaosButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement chaos button behavior
// Spawn 10 of every other button when pressed
for (var i = 0; i < 10; i++) {
var cloneButton = spawnCloneButton(self.x, self.y);
var doubleButton = spawnDoubleButton(self.x, self.y);
var doubleSizeButton = spawnDoubleSizeButton(self.x, self.y);
var iceButton = spawnIceButton(self.x, self.y);
var lilGuyButton = spawnLilGuyButton(self.x, self.y);
var nukeButton = spawnNukeButton(self.x, self.y);
var timerButton = spawnTimerButton(self.x, self.y);
// Teleport buttons randomly every nanosecond
(function (cloneButton, doubleButton, doubleSizeButton, iceButton, lilGuyButton, nukeButton, timerButton) {
LK.setInterval(function () {
if (cloneButton) {
cloneButton.x = Math.random() * 2048;
cloneButton.y = Math.random() * 2732;
}
if (doubleButton) {
doubleButton.x = Math.random() * 2048;
doubleButton.y = Math.random() * 2732;
}
if (doubleSizeButton) {
doubleSizeButton.x = Math.random() * 2048;
doubleSizeButton.y = Math.random() * 2732;
}
if (iceButton) {
iceButton.x = Math.random() * 2048;
iceButton.y = Math.random() * 2732;
}
if (lilGuyButton) {
lilGuyButton.x = Math.random() * 2048;
lilGuyButton.y = Math.random() * 2732;
}
if (nukeButton) {
nukeButton.x = Math.random() * 2048;
nukeButton.y = Math.random() * 2732;
}
if (timerButton) {
timerButton.x = Math.random() * 2048;
timerButton.y = Math.random() * 2732;
}
}, 1);
})(cloneButton, doubleButton, doubleSizeButton, iceButton, lilGuyButton, nukeButton, timerButton);
}
};
return self;
});
// CloneButton class
var CloneButton = Container.expand(function () {
var self = Container.call(this);
var cloneButtonGraphics = self.attachAsset('cloneButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 50;
self.height = 50;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
spawnCloneButton(self.x, self.y + self.height);
};
return self;
});
// DisguiseButton class
var DisguiseButton = Container.expand(function () {
var self = Container.call(this);
var disguiseButtonGraphics = self.attachAsset('disguiseButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement disguise button behavior
for (var i = 0; i < buttons.length; i++) {
if (buttons[i] !== self) {
var randomTexture = getRandomButtonTexture();
buttons[i].attachAsset(randomTexture, {
anchorX: 0.5,
anchorY: 0.5
});
}
}
};
return self;
});
// Function to spawn a DisguiseButton
// DoubleButton class
var DoubleButton = Container.expand(function () {
var self = Container.call(this);
var doubleButtonGraphics = self.attachAsset('doubleButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement double button behavior
var newDoubleButton = new DoubleButton();
newDoubleButton.x = self.x + self.width;
newDoubleButton.y = self.y;
game.addChild(newDoubleButton);
};
return self;
});
// DoubleSizeButton class
var DoubleSizeButton = Container.expand(function () {
var self = Container.call(this);
var doublesizeButtonGraphics = self.attachAsset('doublesizeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement doublesize button behavior
self.width *= 2;
self.height *= 2;
};
return self;
});
// HideButton class
var HideButton = Container.expand(function () {
var self = Container.call(this);
var hideButtonGraphics = self.attachAsset('hideButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement hide button behavior
for (var i = 0; i < buttons.length; i++) {
buttons[i].visible = false;
}
// Make buttons visible again after 3 seconds
LK.setTimeout(function () {
for (var i = 0; i < buttons.length; i++) {
buttons[i].visible = true;
}
}, 3000);
};
return self;
});
// IceButton class
var IceButton = Container.expand(function () {
var self = Container.call(this);
var iceButtonGraphics = self.attachAsset('iceButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement ice button behavior
game.interactive = false;
game.setBackgroundColor(0xFFFFFF); // Change background color to white
LK.setTimeout(function () {
game.interactive = true;
game.setBackgroundColor(0x565292); // Change background color to 0x565292
}, 3000);
};
return self;
});
// LagButton class
var LagButton = Container.expand(function () {
var self = Container.call(this);
var lagButtonGraphics = self.attachAsset('lagButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement lag button behavior
for (var i = 0; i < 20; i++) {
for (var j = 0; j < 20; j++) {
var newLagButton = new LagButton();
newLagButton.x = i * 100;
newLagButton.y = j * 100;
buttons.push(newLagButton);
game.addChild(newLagButton);
}
}
};
return self;
});
// LilGuy class
var LilGuy = Container.expand(function () {
var self = Container.call(this);
var lilguyGraphics = self.attachAsset('lilguy', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 50;
self.height = 50;
self.interactive = true;
self.buttonMode = true;
self.speedX = Math.random() * 10 - 5;
self.speedY = Math.random() * 10 - 5;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
if (self.x < 0 || self.x > 2048) {
self.speedX *= -1;
}
if (self.y < 0 || self.y > 2732) {
self.speedY *= -1;
}
};
return self;
});
// LilGuyButton class
var LilGuyButton = Container.expand(function () {
var self = Container.call(this);
var lilguyButtonGraphics = self.attachAsset('lilguyButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 50;
self.height = 50;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
var newLilGuy = new LilGuy();
newLilGuy.x = Math.random() * 2048;
newLilGuy.y = Math.random() * 2732;
game.addChild(newLilGuy);
};
return self;
});
// MagnetButton class
var MagnetButton = Container.expand(function () {
var self = Container.call(this);
var magnetButtonGraphics = self.attachAsset('magnetButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
for (var i = 0; i < buttons.length; i++) {
if (buttons[i] !== self) {
var targetButton = buttons[i];
var dx = self.x - targetButton.x;
var dy = self.y - targetButton.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var speed = 10; // Adjust speed as needed
var steps = distance / speed;
var stepX = dx / steps;
var stepY = dy / steps;
(function animateButton(targetButton, startX, startY, endX, endY, steps, currentStep) {
if (currentStep <= steps) {
var t = easeInOutQuad(currentStep / steps);
targetButton.x = startX + (endX - startX) * t;
targetButton.y = startY + (endY - startY) * t;
currentStep++;
LK.setTimeout(function () {
animateButton(targetButton, startX, startY, endX, endY, steps, currentStep);
}, 16); // Approximately 60 FPS
}
})(targetButton, targetButton.x, targetButton.y, self.x, self.y, steps, 0);
}
}
};
return self;
});
// NukeButton class
var NukeButton = Container.expand(function () {
var self = Container.call(this);
var nukeButtonGraphics = self.attachAsset('nukeButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 200;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement nuke button behavior
LK.showGameOver();
// Play the 'tacticalnuke' sound effect
LK.getSound('tacticalnuke').play();
};
return self;
});
// QuestButton1 class
var QuestButton1 = Container.expand(function () {
var self = Container.call(this);
var questButton1Graphics = self.attachAsset('questbutton1', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
console.log("QuestButton1 pressed");
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
spawnQuestButton2(randomX, randomY);
// Make all other buttons unpressable
for (var i = 0; i < buttons.length; i++) {
if (!(buttons[i] instanceof QuestButton2)) {
buttons[i].interactive = false;
}
}
self.destroy(); // Make QuestButton1 disappear
// Set a timeout to end the game if QuestButton2 is not pressed within 2 seconds
questTimeout = LK.setTimeout(function () {
spawnNukeButton(Math.random() * 2048, Math.random() * 2732);
spawnNukeButton(Math.random() * 2048, Math.random() * 2732);
console.log("Quest failed! Two Nuke buttons spawned.");
questStatusTxt.setText('No quest enabled');
}, 2000);
};
return self;
});
// QuestButton2 class
var QuestButton2 = Container.expand(function () {
var self = Container.call(this);
var questButton2Graphics = self.attachAsset('questbutton2', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
console.log("QuestButton2 pressed");
// Make all buttons pressable again
for (var i = 0; i < buttons.length; i++) {
buttons[i].interactive = true;
}
self.destroy(); // Make QuestButton2 disappear
// Clear the timeout to prevent game over
LK.clearTimeout(questTimeout);
};
return self;
});
// QuestButton3 class
var QuestButton3 = Container.expand(function () {
var self = Container.call(this);
var questButton3Graphics = self.attachAsset('questbutton3', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
console.log("QuestButton3 pressed");
startButtonQuest();
};
return self;
});
// RandomTPButton class
var RandomTPButton = Container.expand(function () {
var self = Container.call(this);
var randomTPButtonGraphics = self.attachAsset('randomTPButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement random teleport button behavior
for (var i = 0; i < buttons.length; i++) {
if (buttons[i] !== self) {
buttons[i].x = Math.random() * 2048;
buttons[i].y = Math.random() * 2732;
}
}
};
return self;
});
// TimerButton class
var TimerButton = Container.expand(function () {
var self = Container.call(this);
var timerButtonGraphics = self.attachAsset('timerButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.width = 100;
self.height = 100;
self.interactive = true;
self.buttonMode = true;
self.down = function (x, y, obj) {
// Implement timer button behavior
var timer = LK.setTimeout(function () {
// Enable all buttons after 5 seconds
for (var i = 0; i < buttons.length; i++) {
buttons[i].interactive = true;
}
}, 5000);
// Disable all buttons
for (var i = 0; i < buttons.length; i++) {
buttons[i].interactive = false;
}
// Play the 'timestop' sound effect
LK.getSound('timestop').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x565292 //Init game with black background
});
/****
* Game Code
****/
// Function to spawn a QuestButton3
function spawnQuestButton3(x, y) {
var newButton = new QuestButton3();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to start the button quest
function startButtonQuest() {
var questStartTime = Date.now();
var questDuration = 15000; // 15 seconds
var questButtonPressCount = 0;
var questComplete = false;
// Function to update quest status text
function updateQuestStatus() {
var timeRemaining = Math.max(0, questDuration - (Date.now() - questStartTime));
questStatusTxt.setText("Quest: Press 10 buttons\nTime Left: ".concat(Math.ceil(timeRemaining / 1000), "s\nProgress: ").concat(questButtonPressCount, "/10"));
}
// Function to check quest completion
function checkQuestCompletion() {
updateQuestStatus();
if (questButtonPressCount >= 10) {
questComplete = true;
scoreMultiplier = 2;
LK.setTimeout(function () {
scoreMultiplier = 1;
}, 30000); // 2x score multiplier for 30 seconds
console.log("Quest completed! 2x score multiplier for 30 seconds.");
questStatusTxt.setText('No quest enabled');
} else if (Date.now() - questStartTime >= questDuration) {
if (!questComplete) {
spawnNukeButton(Math.random() * 2048, Math.random() * 2732);
spawnNukeButton(Math.random() * 2048, Math.random() * 2732);
console.log("Quest failed! Two Nuke buttons spawned.");
questStatusTxt.setText('No quest enabled');
}
} else {
LK.setTimeout(checkQuestCompletion, 100);
}
}
// Override button down function to count button presses
var originalButtonDown = Button.prototype.down;
Button.prototype.down = function (x, y, obj) {
questButtonPressCount++;
originalButtonDown.call(this, x, y, obj);
};
// Start checking for quest completion
checkQuestCompletion();
}
var questTimeout;
// Function to spawn a QuestButton2
function spawnQuestButton2(x, y) {
var newButton = new QuestButton2();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a QuestButton1
function spawnQuestButton1(x, y) {
var newButton = new QuestButton1();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a LagButton
function spawnLagButton(x, y) {
var newButton = new LagButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a LagButton
function getRandomButtonTexture() {
var textures = ['button', 'chaosButton', 'cloneButton', 'disguiseButton', 'doubleButton', 'doublesizeButton', 'hideButton', 'iceButton', 'lilguyButton', 'lilguy', 'magnetButton', 'nukeButton', 'timerButton'];
return textures[Math.floor(Math.random() * textures.length)];
}
function spawnDisguiseButton(x, y) {
var newButton = new DisguiseButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a RandomTPButton
function spawnRandomTPButton(x, y) {
var newButton = new RandomTPButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a DisguiseButton
function easeInOutQuad(t) {
return t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t;
}
function spawnHideButton(x, y) {
var newButton = new HideButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a TimerButton
function spawnTimerButton(x, y) {
var newButton = new TimerButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a NukeButton
function spawnNukeButton(x, y) {
var newButton = new NukeButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a LilGuyButton
function spawnLilGuyButton(x, y) {
var newButton = new LilGuyButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn an IceButton
function spawnIceButton(x, y) {
var newButton = new IceButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a DoubleSizeButton
function spawnDoubleSizeButton(x, y) {
var newButton = new DoubleSizeButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a DoubleButton
function spawnDoubleButton(x, y) {
var newButton = new DoubleButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a clone button
function spawnCloneButton(x, y) {
var newButton = new CloneButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
// Function to spawn a MagnetButton
function spawnMagnetButton(x, y) {
var newButton = new MagnetButton();
newButton.x = x;
newButton.y = y;
buttons.push(newButton);
game.addChild(newButton);
}
var buttonPressCount = 0;
var buttonSpawned = {
clone: false,
nuke: false
};
// Initialize arrays and variables
var buttons = [];
var buttonPressCount = 0;
var buttonSpawned = {
clone: false,
nuke: false,
lilguy: false,
ice: false,
doublesize: false,
timer: false,
"double": false,
hide: false,
magnet: false,
disguise: false,
randomtp: false,
lag: false,
quest1: false,
quest3: false,
chaos: false
};
var questTimeout;
var questStatusTxt = new Text2('No quest enabled', {
size: 100,
fill: "#ffffff"
});
questStatusTxt.anchor.set(0.5, 0);
questStatusTxt.y = 200; // Position below the score text
LK.gui.top.addChild(questStatusTxt);
var score = 0;
var scoreMultiplier = 1;
var questStatusTxt = new Text2('No quest enabled', {
size: 100,
fill: "#ffffff"
});
questStatusTxt.anchor.set(0.5, 0);
questStatusTxt.y = 200; // Position below the score text
LK.gui.top.addChild(questStatusTxt);
// Function to spawn a random button
function spawnRandomButton() {
var newButton;
var buttonTypes = [{
type: NukeButton,
key: 'nuke'
}, {
type: CloneButton,
key: 'clone'
}, {
type: LilGuyButton,
key: 'lilguy'
}, {
type: IceButton,
key: 'ice'
}, {
type: DoubleSizeButton,
key: 'doublesize'
}, {
type: TimerButton,
key: 'timer'
}, {
type: DoubleButton,
key: 'double'
}, {
type: HideButton,
key: 'hide'
}, {
type: MagnetButton,
key: 'magnet'
}, {
type: DisguiseButton,
key: 'disguise'
}, {
type: RandomTPButton,
key: 'randomtp'
}, {
type: LagButton,
key: 'lag'
}, {
type: QuestButton1,
key: 'quest1'
}, {
type: QuestButton3,
key: 'quest3'
}, {
type: ChaosButton,
key: 'chaos'
}];
for (var i = 0; i < buttonTypes.length; i++) {
if (Math.random() < 0.2 && !buttonSpawned[buttonTypes[i].key]) {
newButton = new buttonTypes[i].type();
buttonSpawned[buttonTypes[i].key] = true;
break;
}
}
if (newButton) {
newButton.x = Math.random() * 2048;
newButton.y = Math.random() * 2732;
buttons.push(newButton);
game.addChild(newButton);
}
}
// Create the initial button
var initialButton = new Button();
initialButton.x = 2048 / 2;
initialButton.y = 2732 / 2;
buttons.push(initialButton);
game.addChild(initialButton);
// Update function
game.update = function () {
// Update logic if needed
};
// Function to spawn a DisguiseButton
a red button with text that. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. pixelated
a button with a cube on it with two eyes and hands but no arms. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button that is dripping with icicles that says "ice". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with text that says "X". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a clock. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button that says "double". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button that says "Chaos!". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with text that fades to the right saying "hide". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with a two sided magnet on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a fading shirt on a button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with a red button next to a blue button on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with random rainbow cubes on it over the text "lag". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with a scroll on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with a ! on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a button with a scroll and a computer cursor on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.