/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Button = Container.expand(function () { var self = Container.call(this); // Attach button asset var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); // Initialize counter self.counter = 0; // Create counter text self.counterText = new Text2(self.counter.toString(), { size: 50, fill: 0xFFFFFF }); self.counterText.anchor.set(0.5, 0); self.counterText.y = buttonGraphics.height / 2 + 10; // Position text below the button self.addChild(self.counterText); // Event handler for button press self.down = function () { self.counter = 0; // Reset the counter self.counter += 4; // Increase the counter by 4 self.counterText.setText(self.counter.toString()); // Add event listener for button press self.on('pointerdown', function () { console.log('Button pressed!'); }); }; }); var GibberishText = Container.expand(function () { var self = Container.call(this); // Create gibberish text var gibberishText = new Text2('var i = 0; while (i < 10) { console.log(i); i++; }', { size: 10, fill: 0x008000, alpha: 0.02 }); self.addChild(gibberishText); // Make the gibberish text appear word after word var words = gibberishText.text ? gibberishText.text.split(' ') : []; gibberishText.text = ''; var i = 0; var interval = LK.setInterval(function () { if (i < words.length) { gibberishText.text += words[i] + ' '; i++; } else { LK.clearInterval(interval); } }, 1000); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Removed main screen elements and start button var lastAchievementText = null; var lastUnlockText = null; var clickIncrement = 4; var unlockableFeatures = [{ name: "New Keyboard", cost: 100, effect: function effect() { clickIncrement += 2; } }, { name: "Faster Typing", cost: 500, effect: function effect() { clickIncrement += 5; } }, { name: "AI Assistant", cost: 1000, effect: function effect() { clickIncrement += 10; } }]; var buttonSpacing = 150; var buttonStartY = 2300; var buttonY = 2732 - 100; var buttonSpacing = 512; // Create upgrade buttons for each unlockable feature unlockableFeatures.forEach(function (feature, index) { var upgradeButton = new Button(); upgradeButton.x = 1024; upgradeButton.y = buttonStartY + index * buttonSpacing; upgradeButton.counterText.setText(feature.name + " ($" + feature.cost + ")"); upgradeButton.down = function () { if (code >= feature.cost && !feature.unlocked) { feature.effect(); feature.unlocked = true; console.log(feature.name + " unlocked!"); code -= feature.cost; // Deduct cost from code // Update button text to show unlocked status upgradeButton.counterText.setText(feature.name + " (Unlocked)"); // Update code display codeTxt.setText('Lines of Code written: ' + code.toString() + ' | Level: ' + level + ' | XP: ' + experience + '/' + experienceToNextLevel); // Add visual feedback for unlocking if (lastUnlockText) { lastUnlockText.y -= 70; } var unlockText = new Text2(feature.name + " Unlocked!", { size: 60, fill: 0xFFD700, font: "'Courier New', Courier, monospace" }); unlockText.anchor.set(0.5, 0.5); unlockText.x = 1024; unlockText.y = 700; game.addChild(unlockText); lastUnlockText = unlockText; tween(unlockText, { alpha: 0 }, { duration: 2000, onComplete: function onComplete() { unlockText.destroy(); } }); } }; game.addChild(upgradeButton); }); var background = game.attachAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); var coder = game.attachAsset('coder', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); var code = 0; var level = 1; var experience = 0; var experienceToNextLevel = 100; var codeTxt = new Text2('Code written: ' + code.toString(), { size: 50, fill: 0xFFFFFF }); codeTxt.anchor.set(0.5, 0); LK.gui.top.addChild(codeTxt); coder.down = function () { // Play typing sound effect LK.getSound('typing').play(); // Increase code by clickIncrement every click code += clickIncrement; // Increase experience by clickIncrement experience += clickIncrement; // Check if experience has reached the threshold for leveling up if (experience >= experienceToNextLevel) { level++; experience -= experienceToNextLevel; experienceToNextLevel = Math.floor(experienceToNextLevel * 1.5); // Increase the threshold for the next level console.log("Level Up! You are now level " + level); // Display level up message var levelUpText = new Text2("Level Up! Level " + level, { size: 60, fill: 0x00FF00, font: "'Courier New', Courier, monospace" }); levelUpText.anchor.set(0.5, 0.5); levelUpText.x = 1024; levelUpText.y = 800; game.addChild(levelUpText); tween(levelUpText, { alpha: 0 }, { duration: 2000, onComplete: function onComplete() { levelUpText.destroy(); } }); } // Check for achievements var achievements = [{ name: "First 100 Lines", threshold: 100 }, { name: "Halfway to 500", threshold: 250 }, { name: "Code Master", threshold: 500 }]; achievements.forEach(function (achievement) { if (code >= achievement.threshold && !achievement.unlocked) { achievement.unlocked = true; console.log(achievement.name + " achieved!"); // Move previous achievement text up if it exists if (lastAchievementText) { lastAchievementText.y -= 70; } var achievementText = new Text2(achievement.name + " Achieved!", { size: 60, fill: 0xFFD700, font: "'Courier New', Courier, monospace" // Techy font }); achievementText.anchor.set(0.5, 0.5); achievementText.x = 1024; achievementText.y = 600; // Move higher game.addChild(achievementText); lastAchievementText = achievementText; tween(achievementText, { alpha: 0 }, { duration: 2000, onComplete: function onComplete() { achievementText.destroy(); } }); } }); // Check if the number of clicks is a multiple of 16 if (code % 16 === 0) { // List of coding terminology words var codingTerms = ["function", "variable", "loop", "array", "object", "class", "method", "event", "callback", "promise", "async", "await"]; // Select a random word from the list var randomWord = codingTerms[Math.floor(Math.random() * codingTerms.length)]; // Create a text object for the random word var wordText = new Text2(randomWord, { size: 50, fill: 0xFFFFFF, font: "'Courier New', Courier, monospace" // Techy font }); // Position the word text to the left of the coder wordText.x = coder.x - 200; wordText.y = coder.y; // Add the word text to the game game.addChild(wordText); // Animate the word text to move upwards and fade out tween(wordText, { y: wordText.y - 100, alpha: 0 }, { duration: 1000, onComplete: function onComplete() { wordText.destroy(); } }); } // Check and unlock features based on accumulated code unlockableFeatures.forEach(function (feature) { if (code >= feature.cost && !feature.unlocked) { feature.effect(); feature.unlocked = true; console.log(feature.name + " unlocked!"); // Add visual feedback for unlocking // Move previous unlock text up if it exists if (lastUnlockText) { lastUnlockText.y -= 70; } var unlockText = new Text2(feature.name + " Unlocked!", { size: 60, fill: 0xFFD700, font: "'Courier New', Courier, monospace" // Techy font }); unlockText.anchor.set(0.5, 0.5); unlockText.x = 1024; unlockText.y = 700; // Move higher game.addChild(unlockText); lastUnlockText = unlockText; tween(unlockText, { alpha: 0 }, { duration: 2000, onComplete: function onComplete() { unlockText.destroy(); } }); } }); // Update code display codeTxt.setText('Lines of Code written: ' + code.toString() + ' | Level: ' + level + ' | XP: ' + experience + '/' + experienceToNextLevel); // Create a pop effect on the coder when clicked tween(coder, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, onComplete: function onComplete() { tween(coder, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); // Add a ripple effect around the coder var ripple = new LK.getAsset('circle', { anchorX: 0.5, anchorY: 0.5, x: coder.x, y: coder.y, scaleX: 0.1, scaleY: 0.1, alpha: 0.5 }); game.addChild(ripple); tween(ripple, { scaleX: 1, scaleY: 1, alpha: 0 }, { duration: 500, onComplete: function onComplete() { ripple.destroy(); } }); // Return to normal size after a delay LK.setTimeout(function () { tween(coder, { scaleX: 1, scaleY: 1 }, { duration: 100 }); // Add gibberish text to the game for (var i = 0; i < 12; i++) { // Generate gibberish text randomly positioned var gibberishText = new GibberishText(); gibberishText.x = Math.random() * 2048; gibberishText.y = Math.random() * 2732; game.addChild(gibberishText); } // Remove gibberish text after 10 seconds LK.setTimeout(function () { for (var i = 0; i < 12; i++) { // gibberishText.destroy(); // Removed to fix the error } }, 10000); }, 100); }; game.tick = function () { // Initialize lastX and lastY for tracking if (typeof this.lastX === 'undefined') { this.lastX = 0; } if (typeof this.lastY === 'undefined') { this.lastY = 0; } // Update lastX and lastY this.lastX = this.x; this.lastY = this.y; // Introduce new challenges as code increases if (code >= 200 && !challengeIntroduced) { challengeIntroduced = true; console.log("New Challenge: Manage Multiple Tasks!"); var challengeText = new Text2("New Challenge: Manage Multiple Tasks!", { size: 40, fill: 0xFF4500 }); challengeText.anchor.set(0.5, 0.5); challengeText.x = 1024; challengeText.y = 1366; game.addChild(challengeText); tween(challengeText, { alpha: 0 }, { duration: 2000, onComplete: function onComplete() { challengeText.destroy(); } }); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Button = Container.expand(function () {
var self = Container.call(this);
// Attach button asset
var buttonGraphics = self.attachAsset('button', {
anchorX: 0.5,
anchorY: 0.5
});
// Initialize counter
self.counter = 0;
// Create counter text
self.counterText = new Text2(self.counter.toString(), {
size: 50,
fill: 0xFFFFFF
});
self.counterText.anchor.set(0.5, 0);
self.counterText.y = buttonGraphics.height / 2 + 10; // Position text below the button
self.addChild(self.counterText);
// Event handler for button press
self.down = function () {
self.counter = 0; // Reset the counter
self.counter += 4; // Increase the counter by 4
self.counterText.setText(self.counter.toString());
// Add event listener for button press
self.on('pointerdown', function () {
console.log('Button pressed!');
});
};
});
var GibberishText = Container.expand(function () {
var self = Container.call(this);
// Create gibberish text
var gibberishText = new Text2('var i = 0; while (i < 10) { console.log(i); i++; }', {
size: 10,
fill: 0x008000,
alpha: 0.02
});
self.addChild(gibberishText);
// Make the gibberish text appear word after word
var words = gibberishText.text ? gibberishText.text.split(' ') : [];
gibberishText.text = '';
var i = 0;
var interval = LK.setInterval(function () {
if (i < words.length) {
gibberishText.text += words[i] + ' ';
i++;
} else {
LK.clearInterval(interval);
}
}, 1000);
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Removed main screen elements and start button
var lastAchievementText = null;
var lastUnlockText = null;
var clickIncrement = 4;
var unlockableFeatures = [{
name: "New Keyboard",
cost: 100,
effect: function effect() {
clickIncrement += 2;
}
}, {
name: "Faster Typing",
cost: 500,
effect: function effect() {
clickIncrement += 5;
}
}, {
name: "AI Assistant",
cost: 1000,
effect: function effect() {
clickIncrement += 10;
}
}];
var buttonSpacing = 150;
var buttonStartY = 2300;
var buttonY = 2732 - 100;
var buttonSpacing = 512;
// Create upgrade buttons for each unlockable feature
unlockableFeatures.forEach(function (feature, index) {
var upgradeButton = new Button();
upgradeButton.x = 1024;
upgradeButton.y = buttonStartY + index * buttonSpacing;
upgradeButton.counterText.setText(feature.name + " ($" + feature.cost + ")");
upgradeButton.down = function () {
if (code >= feature.cost && !feature.unlocked) {
feature.effect();
feature.unlocked = true;
console.log(feature.name + " unlocked!");
code -= feature.cost; // Deduct cost from code
// Update button text to show unlocked status
upgradeButton.counterText.setText(feature.name + " (Unlocked)");
// Update code display
codeTxt.setText('Lines of Code written: ' + code.toString() + ' | Level: ' + level + ' | XP: ' + experience + '/' + experienceToNextLevel);
// Add visual feedback for unlocking
if (lastUnlockText) {
lastUnlockText.y -= 70;
}
var unlockText = new Text2(feature.name + " Unlocked!", {
size: 60,
fill: 0xFFD700,
font: "'Courier New', Courier, monospace"
});
unlockText.anchor.set(0.5, 0.5);
unlockText.x = 1024;
unlockText.y = 700;
game.addChild(unlockText);
lastUnlockText = unlockText;
tween(unlockText, {
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
unlockText.destroy();
}
});
}
};
game.addChild(upgradeButton);
});
var background = game.attachAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var coder = game.attachAsset('coder', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
});
var code = 0;
var level = 1;
var experience = 0;
var experienceToNextLevel = 100;
var codeTxt = new Text2('Code written: ' + code.toString(), {
size: 50,
fill: 0xFFFFFF
});
codeTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(codeTxt);
coder.down = function () {
// Play typing sound effect
LK.getSound('typing').play();
// Increase code by clickIncrement every click
code += clickIncrement;
// Increase experience by clickIncrement
experience += clickIncrement;
// Check if experience has reached the threshold for leveling up
if (experience >= experienceToNextLevel) {
level++;
experience -= experienceToNextLevel;
experienceToNextLevel = Math.floor(experienceToNextLevel * 1.5); // Increase the threshold for the next level
console.log("Level Up! You are now level " + level);
// Display level up message
var levelUpText = new Text2("Level Up! Level " + level, {
size: 60,
fill: 0x00FF00,
font: "'Courier New', Courier, monospace"
});
levelUpText.anchor.set(0.5, 0.5);
levelUpText.x = 1024;
levelUpText.y = 800;
game.addChild(levelUpText);
tween(levelUpText, {
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
levelUpText.destroy();
}
});
}
// Check for achievements
var achievements = [{
name: "First 100 Lines",
threshold: 100
}, {
name: "Halfway to 500",
threshold: 250
}, {
name: "Code Master",
threshold: 500
}];
achievements.forEach(function (achievement) {
if (code >= achievement.threshold && !achievement.unlocked) {
achievement.unlocked = true;
console.log(achievement.name + " achieved!");
// Move previous achievement text up if it exists
if (lastAchievementText) {
lastAchievementText.y -= 70;
}
var achievementText = new Text2(achievement.name + " Achieved!", {
size: 60,
fill: 0xFFD700,
font: "'Courier New', Courier, monospace" // Techy font
});
achievementText.anchor.set(0.5, 0.5);
achievementText.x = 1024;
achievementText.y = 600; // Move higher
game.addChild(achievementText);
lastAchievementText = achievementText;
tween(achievementText, {
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
achievementText.destroy();
}
});
}
});
// Check if the number of clicks is a multiple of 16
if (code % 16 === 0) {
// List of coding terminology words
var codingTerms = ["function", "variable", "loop", "array", "object", "class", "method", "event", "callback", "promise", "async", "await"];
// Select a random word from the list
var randomWord = codingTerms[Math.floor(Math.random() * codingTerms.length)];
// Create a text object for the random word
var wordText = new Text2(randomWord, {
size: 50,
fill: 0xFFFFFF,
font: "'Courier New', Courier, monospace" // Techy font
});
// Position the word text to the left of the coder
wordText.x = coder.x - 200;
wordText.y = coder.y;
// Add the word text to the game
game.addChild(wordText);
// Animate the word text to move upwards and fade out
tween(wordText, {
y: wordText.y - 100,
alpha: 0
}, {
duration: 1000,
onComplete: function onComplete() {
wordText.destroy();
}
});
}
// Check and unlock features based on accumulated code
unlockableFeatures.forEach(function (feature) {
if (code >= feature.cost && !feature.unlocked) {
feature.effect();
feature.unlocked = true;
console.log(feature.name + " unlocked!");
// Add visual feedback for unlocking
// Move previous unlock text up if it exists
if (lastUnlockText) {
lastUnlockText.y -= 70;
}
var unlockText = new Text2(feature.name + " Unlocked!", {
size: 60,
fill: 0xFFD700,
font: "'Courier New', Courier, monospace" // Techy font
});
unlockText.anchor.set(0.5, 0.5);
unlockText.x = 1024;
unlockText.y = 700; // Move higher
game.addChild(unlockText);
lastUnlockText = unlockText;
tween(unlockText, {
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
unlockText.destroy();
}
});
}
});
// Update code display
codeTxt.setText('Lines of Code written: ' + code.toString() + ' | Level: ' + level + ' | XP: ' + experience + '/' + experienceToNextLevel);
// Create a pop effect on the coder when clicked
tween(coder, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
onComplete: function onComplete() {
tween(coder, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
// Add a ripple effect around the coder
var ripple = new LK.getAsset('circle', {
anchorX: 0.5,
anchorY: 0.5,
x: coder.x,
y: coder.y,
scaleX: 0.1,
scaleY: 0.1,
alpha: 0.5
});
game.addChild(ripple);
tween(ripple, {
scaleX: 1,
scaleY: 1,
alpha: 0
}, {
duration: 500,
onComplete: function onComplete() {
ripple.destroy();
}
});
// Return to normal size after a delay
LK.setTimeout(function () {
tween(coder, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
// Add gibberish text to the game
for (var i = 0; i < 12; i++) {
// Generate gibberish text randomly positioned
var gibberishText = new GibberishText();
gibberishText.x = Math.random() * 2048;
gibberishText.y = Math.random() * 2732;
game.addChild(gibberishText);
}
// Remove gibberish text after 10 seconds
LK.setTimeout(function () {
for (var i = 0; i < 12; i++) {
// gibberishText.destroy(); // Removed to fix the error
}
}, 10000);
}, 100);
};
game.tick = function () {
// Initialize lastX and lastY for tracking
if (typeof this.lastX === 'undefined') {
this.lastX = 0;
}
if (typeof this.lastY === 'undefined') {
this.lastY = 0;
}
// Update lastX and lastY
this.lastX = this.x;
this.lastY = this.y;
// Introduce new challenges as code increases
if (code >= 200 && !challengeIntroduced) {
challengeIntroduced = true;
console.log("New Challenge: Manage Multiple Tasks!");
var challengeText = new Text2("New Challenge: Manage Multiple Tasks!", {
size: 40,
fill: 0xFF4500
});
challengeText.anchor.set(0.5, 0.5);
challengeText.x = 1024;
challengeText.y = 1366;
game.addChild(challengeText);
tween(challengeText, {
alpha: 0
}, {
duration: 2000,
onComplete: function onComplete() {
challengeText.destroy();
}
});
}
};
a developer sitting on his laptop in his cubicle, typing on the keyboard. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
coffee mug. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
coffee cup 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows