User prompt
haz los dialogos del golem mas grandes y que aparezcan en un globo de texto ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que el golem pueda decir mensajes dependiendo de como esta, por ejemplo si tiene un sombrero diria: ¡que buen gusto tienes! y tambien si tiene hambre diria: que hambre tengo, ¡dame de comer! ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
haz que se pueda quitar el moño y el sombrero con un boton en la tienda ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
añade moños a la tienda para el golem ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
haz mas grandes las barras de hambre y felicidad y tambien haz un nuevo boton que diga miniGame 2 que sea un nuevo miniGame que sea de conectar colores con sus nombres por tiempo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz mas separados los botones de Feed, Clean, Play, Shop y Mini game y tambien haz que entre mas cara sea la comida, rellene mas la barra de comida ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
haz que cuando estes en el menu de comida al tocar una comida se le de la comida que elejiste al golem ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
haz que cuando toques el boton Feed aparezca un menu de la comida que compraste para elegir que darle de comer al golem ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
haz todo el texto del juego mas grande
User prompt
haz todos los botones del juego mas grandes y que en la tienda haiga diferentes tipos comida para comprar y que ahora tengas que comprar la comida para que no sea infinita ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
haz que el minijuego de flappy bird tenga que empezar cuando toques primero el boton Mini Game y luego el boto Jump ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
agrega una tienda que sirva paraa comprar sombreros con las monedas ↪💡 Consider importing and using the following plugins: @upit/storage.v1, @upit/tween.v1
User prompt
haz que cada que pases por un tubo en el minijuego recivas una moneda ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que las monedas aparezcan mas veces en el minijuego ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz un boton para el minijuego de flappy bird para saltar con el pajaro y que el pajaro sea mas grande ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
haz que haya un boton que diga: Mini Game que cuando lo toques haga que jueges un mini juego estilo flappy bird y que entre mas cuides a tu golem resiva monedas que hagan que le puedas comprar ropa a el golem ↪💡 Consider importing and using the following plugins: @upit/tween.v1, @upit/storage.v1
User prompt
haz que cuando toques el boton Clean aparezca una gota de agua que caiga sobre la suciedad y que los botones para hacer una accion sean mas grandes ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
crea una barra de hambre, que cuando presionas el boton Play aparezca una pelota que tengas que hacer revotar para subir la barra de felicidad ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Stone Golem Pet
Initial prompt
un juego de cuidar a un golem de piedra mascota estilo talking tom
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var Ball = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('ball', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityX = 3 + Math.random() * 4;
self.velocityY = 3 + Math.random() * 4;
self.isActive = true;
self.update = function () {
if (!self.isActive) return;
// Move ball
self.x += self.velocityX;
self.y += self.velocityY;
// Bounce off walls
if (self.x <= 30 || self.x >= 2018) {
self.velocityX *= -1;
}
if (self.y <= 200 || self.y >= 2200) {
self.velocityY *= -1;
}
// Keep ball in bounds
self.x = Math.max(30, Math.min(2018, self.x));
self.y = Math.max(200, Math.min(2200, self.y));
};
self.down = function (x, y, obj) {
if (!self.isActive) return;
// Ball was touched - increase happiness
golem.happiness = Math.min(100, golem.happiness + 3);
// Bounce effect
tween(self, {
scaleX: 1.3,
scaleY: 1.3
}, {
duration: 100
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
// Change velocity randomly
self.velocityX = (Math.random() - 0.5) * 8;
self.velocityY = (Math.random() - 0.5) * 8;
LK.getSound('happy').play();
};
return self;
});
var Coin = Container.expand(function () {
var self = Container.call(this);
var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.floatOffset = Math.random() * Math.PI * 2;
self.update = function () {
// Floating animation
self.y += Math.sin(LK.ticks * 0.1 + self.floatOffset) * 0.3;
self.rotation += 0.05;
};
return self;
});
var Crystal = Container.expand(function () {
var self = Container.call(this);
var crystalGraphics = self.attachAsset('crystal', {
anchorX: 0.5,
anchorY: 0.5
});
// Floating animation
self.floatOffset = Math.random() * Math.PI * 2;
self.update = function () {
self.y += Math.sin(LK.ticks * 0.05 + self.floatOffset) * 0.5;
self.rotation += 0.01;
};
return self;
});
var FlappyBird = Container.expand(function () {
var self = Container.call(this);
var birdGraphics = self.attachAsset('flappyBird', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.gravity = 0.8;
self.jumpPower = -12;
self.isAlive = true;
self.update = function () {
if (!self.isAlive) return;
// Apply gravity
self.velocityY += self.gravity;
self.y += self.velocityY;
// Rotate bird based on velocity
self.rotation = Math.min(Math.max(self.velocityY * 0.1, -0.5), 0.5);
// Check bounds
if (self.y < 300 || self.y > 2400) {
self.isAlive = false;
}
};
self.jump = function () {
if (self.isAlive) {
self.velocityY = self.jumpPower;
// Jump animation
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
}
};
self.down = function (x, y, obj) {
self.jump();
};
return self;
});
var GameButton = Container.expand(function (text, color) {
var self = Container.call(this);
var buttonBg = self.attachAsset(color === 0x9B59B6 ? 'feedButton' : color === 0x3498DB ? 'cleanButton' : 'playButton', {
anchorX: 0.5,
anchorY: 0.5
});
var buttonText = new Text2(text, {
size: 28,
fill: 0xFFFFFF
});
buttonText.anchor.set(0.5, 0.5);
self.addChild(buttonText);
self.callback = null;
self.down = function (x, y, obj) {
// Button press animation
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
if (self.callback) {
self.callback();
}
};
return self;
});
var Pipe = Container.expand(function (isTop) {
var self = Container.call(this);
var pipeGraphics = self.attachAsset('pipe', {
anchorX: 0.5,
anchorY: isTop ? 1.0 : 0.0
});
self.speed = -4;
self.passed = false;
self.update = function () {
self.x += self.speed;
};
return self;
});
var StoneGolem = Container.expand(function () {
var self = Container.call(this);
// Create golem body
var body = self.attachAsset('golem', {
anchorX: 0.5,
anchorY: 0.5
});
// Create eyes
var leftEye = self.attachAsset('golemEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: -60,
y: -80
});
var rightEye = self.attachAsset('golemEyes', {
anchorX: 0.5,
anchorY: 0.5,
x: 60,
y: -80
});
// Create mouth
var mouth = self.attachAsset('golemMouth', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
// Golem properties
self.happiness = storage.golemHappiness || 100;
self.hunger = storage.golemHunger || 100;
self.lastFeedTime = storage.lastFeedTime || Date.now();
self.lastCleanTime = storage.lastCleanTime || Date.now();
self.coins = storage.golemCoins || 0;
self.mood = 'happy'; // happy, sad, sleepy, excited
self.mossSpots = [];
// Create initial moss spots
self.createMossSpots = function () {
for (var i = 0; i < 3; i++) {
var mossSpot = self.attachAsset('moss', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 300,
y: (Math.random() - 0.5) * 400,
alpha: 0.7
});
self.mossSpots.push(mossSpot);
}
};
self.createMossSpots();
// React to petting
self.pet = function () {
// Happy animation
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut
});
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.easeIn
});
// Eyes blink
tween(leftEye, {
scaleY: 0.1
}, {
duration: 100
});
tween(leftEye, {
scaleY: 1.0
}, {
duration: 100
});
tween(rightEye, {
scaleY: 0.1
}, {
duration: 100
});
tween(rightEye, {
scaleY: 1.0
}, {
duration: 100
});
LK.getSound('happy').play();
self.happiness = Math.min(100, self.happiness + 2);
};
// Feed the golem
self.feed = function () {
if (Date.now() - self.lastFeedTime > 5000) {
// Can feed every 5 seconds
mouth.scaleX = 1.5;
mouth.scaleY = 1.5;
tween(mouth, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 500
});
// Bounce animation
tween(self, {
y: self.y - 20
}, {
duration: 200,
easing: tween.easeOut
});
tween(self, {
y: self.y
}, {
duration: 200,
easing: tween.bounceOut
});
LK.getSound('eat').play();
self.happiness = Math.min(100, self.happiness + 15);
self.hunger = Math.min(100, self.hunger + 20);
self.lastFeedTime = Date.now();
return true;
}
return false;
};
// Clean moss from golem
self.clean = function () {
if (self.mossSpots.length > 0) {
var mossToRemove = self.mossSpots.pop();
tween(mossToRemove, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
self.removeChild(mossToRemove);
}
});
LK.getSound('clean').play();
self.happiness = Math.min(100, self.happiness + 10);
return true;
}
return false;
};
// Update mood based on happiness
self.updateMood = function () {
if (self.happiness > 80) {
self.mood = 'happy';
body.tint = 0x8B7355; // Normal stone color
} else if (self.happiness > 50) {
self.mood = 'neutral';
body.tint = 0x7A6B4F; // Slightly darker
} else if (self.happiness > 20) {
self.mood = 'sad';
body.tint = 0x695C42; // Darker
} else {
self.mood = 'very_sad';
body.tint = 0x5A4D35; // Very dark
}
};
// Decrease happiness over time
self.update = function () {
// Decrease happiness slowly over time
if (LK.ticks % 300 == 0) {
// Every 5 seconds at 60fps
self.happiness = Math.max(0, self.happiness - 1);
self.updateMood();
}
// Decrease hunger over time
if (LK.ticks % 240 == 0) {
// Every 4 seconds at 60fps
self.hunger = Math.max(0, self.hunger - 1);
}
// Add moss spots occasionally
if (LK.ticks % 1800 == 0 && self.mossSpots.length < 5) {
// Every 30 seconds
var mossSpot = self.attachAsset('moss', {
anchorX: 0.5,
anchorY: 0.5,
x: (Math.random() - 0.5) * 300,
y: (Math.random() - 0.5) * 400,
alpha: 0.7
});
self.mossSpots.push(mossSpot);
}
// Save state
if (LK.ticks % 60 == 0) {
// Every second
storage.golemHappiness = self.happiness;
storage.golemHunger = self.hunger;
storage.lastFeedTime = self.lastFeedTime;
storage.lastCleanTime = self.lastCleanTime;
storage.golemCoins = self.coins;
}
};
// Touch response
self.down = function (x, y, obj) {
self.pet();
};
return self;
});
var WaterDrop = Container.expand(function () {
var self = Container.call(this);
var dropGraphics = self.attachAsset('waterDrop', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 8;
self.isActive = true;
self.update = function () {
if (!self.isActive) return;
// Move water drop down
self.y += self.velocityY;
// Check if drop hit any moss spots
for (var i = 0; i < golem.mossSpots.length; i++) {
var mossSpot = golem.mossSpots[i];
var mossGlobalPos = golem.toGlobal(mossSpot.position);
var dropGlobalPos = game.toGlobal(self.position);
var distance = Math.sqrt(Math.pow(mossGlobalPos.x - dropGlobalPos.x, 2) + Math.pow(mossGlobalPos.y - dropGlobalPos.y, 2));
if (distance < 50) {
// Hit moss - clean it
golem.mossSpots.splice(i, 1);
tween(mossSpot, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300,
onFinish: function onFinish() {
golem.removeChild(mossSpot);
}
});
golem.happiness = Math.min(100, golem.happiness + 10);
LK.getSound('clean').play();
// Remove water drop
self.isActive = false;
game.removeChild(self);
return;
}
}
// Remove drop if it goes off screen
if (self.y > 2732) {
self.isActive = false;
game.removeChild(self);
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2C3E50
});
/****
* Game Code
****/
// Create UI elements
var happinessBg = LK.getAsset('happinessBg', {
anchorX: 0.5,
anchorY: 0.5
});
LK.gui.top.addChild(happinessBg);
happinessBg.y = 100;
var happinessBar = LK.getAsset('happinessBar', {
anchorX: 0.0,
anchorY: 0.5
});
happinessBg.addChild(happinessBar);
happinessBar.x = -145;
var happinessText = new Text2('Happiness: 100%', {
size: 32,
fill: 0xFFFFFF
});
happinessText.anchor.set(0.5, 0);
LK.gui.top.addChild(happinessText);
happinessText.y = 50;
// Create hunger bar UI
var hungerBg = LK.getAsset('hungerBg', {
anchorX: 0.5,
anchorY: 0.5
});
LK.gui.top.addChild(hungerBg);
hungerBg.y = 160;
var hungerBar = LK.getAsset('hungerBar', {
anchorX: 0.0,
anchorY: 0.5
});
hungerBg.addChild(hungerBar);
hungerBar.x = -145;
var hungerText = new Text2('Hunger: 100%', {
size: 32,
fill: 0xFFFFFF
});
hungerText.anchor.set(0.5, 0);
LK.gui.top.addChild(hungerText);
hungerText.y = 140;
// Create coins display
var coinsText = new Text2('Coins: 0', {
size: 32,
fill: 0xFFFFFF
});
coinsText.anchor.set(0.5, 0);
LK.gui.top.addChild(coinsText);
coinsText.y = 200;
// Create main golem
var golem = game.addChild(new StoneGolem());
golem.x = 1024;
golem.y = 1200;
// Create control buttons
var feedButton = new GameButton('Feed', 0x9B59B6);
feedButton.x = 1024 - 200;
feedButton.y = 2500;
feedButton.callback = function () {
if (golem.feed()) {
// Create crystal animation
var crystal = game.addChild(new Crystal());
crystal.x = golem.x;
crystal.y = golem.y - 200;
tween(crystal, {
x: golem.x,
y: golem.y
}, {
duration: 800,
easing: tween.easeIn,
onFinish: function onFinish() {
game.removeChild(crystal);
}
});
}
};
game.addChild(feedButton);
var cleanButton = new GameButton('Clean', 0x3498DB);
cleanButton.x = 1024;
cleanButton.y = 2500;
cleanButton.callback = function () {
// Create water drop that falls on moss
var waterDrop = game.addChild(new WaterDrop());
waterDrop.x = golem.x + (Math.random() - 0.5) * 200;
waterDrop.y = 300;
// Add some animation to the water drop creation
tween(waterDrop, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100
});
tween(waterDrop, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 100
});
};
game.addChild(cleanButton);
var playButton = new GameButton('Play', 0xE74C3C);
playButton.x = 1024 + 200;
playButton.y = 2500;
// Game state variables
var isPlayingMiniGame = false;
var miniGameBall = null;
var miniGameTimer = 0;
var miniGameDuration = 600; // 10 seconds at 60fps
// Flappy bird mini game variables
var isPlayingFlappyBird = false;
var flappyBird = null;
var pipes = [];
var gameCoins = [];
var flappyScore = 0;
var pipeSpawnTimer = 0;
var coinSpawnTimer = 0;
playButton.callback = function () {
if (!isPlayingMiniGame) {
// Start mini-game
isPlayingMiniGame = true;
miniGameTimer = 0;
miniGameBall = game.addChild(new Ball());
miniGameBall.x = 1024;
miniGameBall.y = 1000;
} else {
// Stop mini-game early
if (miniGameBall) {
miniGameBall.isActive = false;
game.removeChild(miniGameBall);
miniGameBall = null;
}
isPlayingMiniGame = false;
}
};
game.addChild(playButton);
var miniGameButton = new GameButton('Mini Game', 0xF39C12);
miniGameButton.x = 1024;
miniGameButton.y = 2600;
miniGameButton.callback = function () {
if (!isPlayingFlappyBird) {
// Start flappy bird mini game
isPlayingFlappyBird = true;
flappyScore = 0;
pipeSpawnTimer = 0;
coinSpawnTimer = 0;
// Create bird
flappyBird = game.addChild(new FlappyBird());
flappyBird.x = 400;
flappyBird.y = 1200;
// Clear any existing pipes and coins
pipes = [];
gameCoins = [];
} else {
// Stop flappy bird game
if (flappyBird) {
game.removeChild(flappyBird);
flappyBird = null;
}
// Clean up pipes
for (var i = 0; i < pipes.length; i++) {
game.removeChild(pipes[i]);
}
pipes = [];
// Clean up coins
for (var i = 0; i < gameCoins.length; i++) {
game.removeChild(gameCoins[i]);
}
gameCoins = [];
isPlayingFlappyBird = false;
}
};
game.addChild(miniGameButton);
// Floating crystals for ambiance
var floatingCrystals = [];
for (var i = 0; i < 3; i++) {
var floatingCrystal = game.addChild(new Crystal());
floatingCrystal.x = 200 + i * 800;
floatingCrystal.y = 300 + Math.random() * 200;
floatingCrystal.alpha = 0.3;
floatingCrystal.scaleX = 0.5;
floatingCrystal.scaleY = 0.5;
floatingCrystals.push(floatingCrystal);
}
// Game update loop
game.update = function () {
// Update happiness display
var happinessPercent = Math.max(0, golem.happiness);
happinessText.setText('Happiness: ' + Math.round(happinessPercent) + '%');
// Update happiness bar visual
var barWidth = happinessPercent / 100 * 290;
happinessBar.width = barWidth;
// Change bar color based on happiness
if (happinessPercent > 60) {
happinessBar.tint = 0x2ECC71; // Green
} else if (happinessPercent > 30) {
happinessBar.tint = 0xF39C12; // Orange
} else {
happinessBar.tint = 0xE74C3C; // Red
}
// Update hunger display
var hungerPercent = Math.max(0, golem.hunger);
hungerText.setText('Hunger: ' + Math.round(hungerPercent) + '%');
// Update hunger bar visual
var hungerBarWidth = hungerPercent / 100 * 290;
hungerBar.width = hungerBarWidth;
// Change hunger bar color based on hunger level
if (hungerPercent > 60) {
hungerBar.tint = 0xE67E22; // Orange
} else if (hungerPercent > 30) {
hungerBar.tint = 0xD35400; // Darker orange
} else {
hungerBar.tint = 0xE74C3C; // Red
}
// Update coins display
coinsText.setText('Coins: ' + golem.coins);
// Handle flappy bird mini game
if (isPlayingFlappyBird && flappyBird) {
// Spawn pipes
pipeSpawnTimer++;
if (pipeSpawnTimer >= 120) {
// Every 2 seconds
pipeSpawnTimer = 0;
var gapY = 800 + Math.random() * 800; // Random gap position
var gapSize = 300; // Gap between pipes
// Top pipe
var topPipe = game.addChild(new Pipe(true));
topPipe.x = 2200;
topPipe.y = gapY - gapSize / 2;
pipes.push(topPipe);
// Bottom pipe
var bottomPipe = game.addChild(new Pipe(false));
bottomPipe.x = 2200;
bottomPipe.y = gapY + gapSize / 2;
pipes.push(bottomPipe);
}
// Spawn coins
coinSpawnTimer++;
if (coinSpawnTimer >= 180) {
// Every 3 seconds
coinSpawnTimer = 0;
var gameCoin = game.addChild(new Coin());
gameCoin.x = 2200;
gameCoin.y = 600 + Math.random() * 1200;
gameCoins.push(gameCoin);
}
// Update and check pipes
for (var i = pipes.length - 1; i >= 0; i--) {
var pipe = pipes[i];
// Check collision with bird
if (flappyBird.intersects(pipe)) {
flappyBird.isAlive = false;
}
// Remove off-screen pipes
if (pipe.x < -100) {
game.removeChild(pipe);
pipes.splice(i, 1);
// Award coins based on care level
if (!pipe.passed) {
var careBonus = Math.floor((golem.happiness + golem.hunger) / 20);
golem.coins += 1 + careBonus;
flappyScore++;
}
}
// Mark pipe as passed for scoring
if (!pipe.passed && pipe.x < flappyBird.x) {
pipe.passed = true;
}
}
// Update and check coins
for (var i = gameCoins.length - 1; i >= 0; i--) {
var gameCoin = gameCoins[i];
// Check collision with bird
if (!gameCoin.collected && flappyBird.intersects(gameCoin)) {
gameCoin.collected = true;
var careBonus = Math.floor((golem.happiness + golem.hunger) / 25);
golem.coins += 2 + careBonus;
// Coin collection animation
tween(gameCoin, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 200,
onFinish: function onFinish() {
game.removeChild(gameCoin);
}
});
gameCoins.splice(i, 1);
continue;
}
// Remove off-screen coins
if (gameCoin.x < -50) {
game.removeChild(gameCoin);
gameCoins.splice(i, 1);
}
}
// Check if bird died
if (!flappyBird.isAlive) {
// End game
game.removeChild(flappyBird);
flappyBird = null;
// Clean up pipes
for (var i = 0; i < pipes.length; i++) {
game.removeChild(pipes[i]);
}
pipes = [];
// Clean up coins
for (var i = 0; i < gameCoins.length; i++) {
game.removeChild(gameCoins[i]);
}
gameCoins = [];
isPlayingFlappyBird = false;
}
}
// Handle mini-game
if (isPlayingMiniGame) {
miniGameTimer++;
// End mini-game after duration
if (miniGameTimer >= miniGameDuration) {
if (miniGameBall) {
miniGameBall.isActive = false;
game.removeChild(miniGameBall);
miniGameBall = null;
}
isPlayingMiniGame = false;
}
}
// Game over condition
if (golem.happiness <= 0 || golem.hunger <= 0) {
LK.showGameOver();
}
// Idle animations for golem
if (LK.ticks % 600 == 0) {
// Every 10 seconds
// Random idle animation
if (Math.random() < 0.5) {
tween(golem, {
rotation: 0.1
}, {
duration: 1000,
easing: tween.easeInOut
});
tween(golem, {
rotation: 0
}, {
duration: 1000,
easing: tween.easeInOut
});
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -55,8 +55,23 @@
LK.getSound('happy').play();
};
return self;
});
+var Coin = Container.expand(function () {
+ var self = Container.call(this);
+ var coinGraphics = self.attachAsset('coin', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.collected = false;
+ self.floatOffset = Math.random() * Math.PI * 2;
+ self.update = function () {
+ // Floating animation
+ self.y += Math.sin(LK.ticks * 0.1 + self.floatOffset) * 0.3;
+ self.rotation += 0.05;
+ };
+ return self;
+});
var Crystal = Container.expand(function () {
var self = Container.call(this);
var crystalGraphics = self.attachAsset('crystal', {
anchorX: 0.5,
@@ -69,8 +84,53 @@
self.rotation += 0.01;
};
return self;
});
+var FlappyBird = Container.expand(function () {
+ var self = Container.call(this);
+ var birdGraphics = self.attachAsset('flappyBird', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.velocityY = 0;
+ self.gravity = 0.8;
+ self.jumpPower = -12;
+ self.isAlive = true;
+ self.update = function () {
+ if (!self.isAlive) return;
+ // Apply gravity
+ self.velocityY += self.gravity;
+ self.y += self.velocityY;
+ // Rotate bird based on velocity
+ self.rotation = Math.min(Math.max(self.velocityY * 0.1, -0.5), 0.5);
+ // Check bounds
+ if (self.y < 300 || self.y > 2400) {
+ self.isAlive = false;
+ }
+ };
+ self.jump = function () {
+ if (self.isAlive) {
+ self.velocityY = self.jumpPower;
+ // Jump animation
+ tween(self, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 100
+ });
+ tween(self, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 100
+ });
+ }
+ };
+ self.down = function (x, y, obj) {
+ self.jump();
+ };
+ return self;
+});
var GameButton = Container.expand(function (text, color) {
var self = Container.call(this);
var buttonBg = self.attachAsset(color === 0x9B59B6 ? 'feedButton' : color === 0x3498DB ? 'cleanButton' : 'playButton', {
anchorX: 0.5,
@@ -102,8 +162,21 @@
}
};
return self;
});
+var Pipe = Container.expand(function (isTop) {
+ var self = Container.call(this);
+ var pipeGraphics = self.attachAsset('pipe', {
+ anchorX: 0.5,
+ anchorY: isTop ? 1.0 : 0.0
+ });
+ self.speed = -4;
+ self.passed = false;
+ self.update = function () {
+ self.x += self.speed;
+ };
+ return self;
+});
var StoneGolem = Container.expand(function () {
var self = Container.call(this);
// Create golem body
var body = self.attachAsset('golem', {
@@ -134,8 +207,9 @@
self.happiness = storage.golemHappiness || 100;
self.hunger = storage.golemHunger || 100;
self.lastFeedTime = storage.lastFeedTime || Date.now();
self.lastCleanTime = storage.lastCleanTime || Date.now();
+ self.coins = storage.golemCoins || 0;
self.mood = 'happy'; // happy, sad, sleepy, excited
self.mossSpots = [];
// Create initial moss spots
self.createMossSpots = function () {
@@ -292,8 +366,9 @@
storage.golemHappiness = self.happiness;
storage.golemHunger = self.hunger;
storage.lastFeedTime = self.lastFeedTime;
storage.lastCleanTime = self.lastCleanTime;
+ storage.golemCoins = self.coins;
}
};
// Touch response
self.down = function (x, y, obj) {
@@ -398,8 +473,16 @@
});
hungerText.anchor.set(0.5, 0);
LK.gui.top.addChild(hungerText);
hungerText.y = 140;
+// Create coins display
+var coinsText = new Text2('Coins: 0', {
+ size: 32,
+ fill: 0xFFFFFF
+});
+coinsText.anchor.set(0.5, 0);
+LK.gui.top.addChild(coinsText);
+coinsText.y = 200;
// Create main golem
var golem = game.addChild(new StoneGolem());
golem.x = 1024;
golem.y = 1200;
@@ -456,8 +539,16 @@
var isPlayingMiniGame = false;
var miniGameBall = null;
var miniGameTimer = 0;
var miniGameDuration = 600; // 10 seconds at 60fps
+// Flappy bird mini game variables
+var isPlayingFlappyBird = false;
+var flappyBird = null;
+var pipes = [];
+var gameCoins = [];
+var flappyScore = 0;
+var pipeSpawnTimer = 0;
+var coinSpawnTimer = 0;
playButton.callback = function () {
if (!isPlayingMiniGame) {
// Start mini-game
isPlayingMiniGame = true;
@@ -475,8 +566,45 @@
isPlayingMiniGame = false;
}
};
game.addChild(playButton);
+var miniGameButton = new GameButton('Mini Game', 0xF39C12);
+miniGameButton.x = 1024;
+miniGameButton.y = 2600;
+miniGameButton.callback = function () {
+ if (!isPlayingFlappyBird) {
+ // Start flappy bird mini game
+ isPlayingFlappyBird = true;
+ flappyScore = 0;
+ pipeSpawnTimer = 0;
+ coinSpawnTimer = 0;
+ // Create bird
+ flappyBird = game.addChild(new FlappyBird());
+ flappyBird.x = 400;
+ flappyBird.y = 1200;
+ // Clear any existing pipes and coins
+ pipes = [];
+ gameCoins = [];
+ } else {
+ // Stop flappy bird game
+ if (flappyBird) {
+ game.removeChild(flappyBird);
+ flappyBird = null;
+ }
+ // Clean up pipes
+ for (var i = 0; i < pipes.length; i++) {
+ game.removeChild(pipes[i]);
+ }
+ pipes = [];
+ // Clean up coins
+ for (var i = 0; i < gameCoins.length; i++) {
+ game.removeChild(gameCoins[i]);
+ }
+ gameCoins = [];
+ isPlayingFlappyBird = false;
+ }
+};
+game.addChild(miniGameButton);
// Floating crystals for ambiance
var floatingCrystals = [];
for (var i = 0; i < 3; i++) {
var floatingCrystal = game.addChild(new Crystal());
@@ -516,8 +644,109 @@
hungerBar.tint = 0xD35400; // Darker orange
} else {
hungerBar.tint = 0xE74C3C; // Red
}
+ // Update coins display
+ coinsText.setText('Coins: ' + golem.coins);
+ // Handle flappy bird mini game
+ if (isPlayingFlappyBird && flappyBird) {
+ // Spawn pipes
+ pipeSpawnTimer++;
+ if (pipeSpawnTimer >= 120) {
+ // Every 2 seconds
+ pipeSpawnTimer = 0;
+ var gapY = 800 + Math.random() * 800; // Random gap position
+ var gapSize = 300; // Gap between pipes
+ // Top pipe
+ var topPipe = game.addChild(new Pipe(true));
+ topPipe.x = 2200;
+ topPipe.y = gapY - gapSize / 2;
+ pipes.push(topPipe);
+ // Bottom pipe
+ var bottomPipe = game.addChild(new Pipe(false));
+ bottomPipe.x = 2200;
+ bottomPipe.y = gapY + gapSize / 2;
+ pipes.push(bottomPipe);
+ }
+ // Spawn coins
+ coinSpawnTimer++;
+ if (coinSpawnTimer >= 180) {
+ // Every 3 seconds
+ coinSpawnTimer = 0;
+ var gameCoin = game.addChild(new Coin());
+ gameCoin.x = 2200;
+ gameCoin.y = 600 + Math.random() * 1200;
+ gameCoins.push(gameCoin);
+ }
+ // Update and check pipes
+ for (var i = pipes.length - 1; i >= 0; i--) {
+ var pipe = pipes[i];
+ // Check collision with bird
+ if (flappyBird.intersects(pipe)) {
+ flappyBird.isAlive = false;
+ }
+ // Remove off-screen pipes
+ if (pipe.x < -100) {
+ game.removeChild(pipe);
+ pipes.splice(i, 1);
+ // Award coins based on care level
+ if (!pipe.passed) {
+ var careBonus = Math.floor((golem.happiness + golem.hunger) / 20);
+ golem.coins += 1 + careBonus;
+ flappyScore++;
+ }
+ }
+ // Mark pipe as passed for scoring
+ if (!pipe.passed && pipe.x < flappyBird.x) {
+ pipe.passed = true;
+ }
+ }
+ // Update and check coins
+ for (var i = gameCoins.length - 1; i >= 0; i--) {
+ var gameCoin = gameCoins[i];
+ // Check collision with bird
+ if (!gameCoin.collected && flappyBird.intersects(gameCoin)) {
+ gameCoin.collected = true;
+ var careBonus = Math.floor((golem.happiness + golem.hunger) / 25);
+ golem.coins += 2 + careBonus;
+ // Coin collection animation
+ tween(gameCoin, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 200,
+ onFinish: function onFinish() {
+ game.removeChild(gameCoin);
+ }
+ });
+ gameCoins.splice(i, 1);
+ continue;
+ }
+ // Remove off-screen coins
+ if (gameCoin.x < -50) {
+ game.removeChild(gameCoin);
+ gameCoins.splice(i, 1);
+ }
+ }
+ // Check if bird died
+ if (!flappyBird.isAlive) {
+ // End game
+ game.removeChild(flappyBird);
+ flappyBird = null;
+ // Clean up pipes
+ for (var i = 0; i < pipes.length; i++) {
+ game.removeChild(pipes[i]);
+ }
+ pipes = [];
+ // Clean up coins
+ for (var i = 0; i < gameCoins.length; i++) {
+ game.removeChild(gameCoins[i]);
+ }
+ gameCoins = [];
+ isPlayingFlappyBird = false;
+ }
+ }
// Handle mini-game
if (isPlayingMiniGame) {
miniGameTimer++;
// End mini-game after duration
una roca regtangular en 2d de color gris claro. In-Game asset. 2d. High contrast. No shadows
una pelota de tenis naranja. In-Game asset. 2d. High contrast. No shadows
gota de agua en 2d. In-Game asset. 2d. High contrast. No shadows
cristal morado cubico 2d. In-Game asset. 2d. High contrast. No shadows
pajaro de flappy bird 2d. In-Game asset. 2d. High contrast. No shadows
tubo de flappy bird. In-Game asset. 2d. High contrast. No shadows
moneda de flappy bird. In-Game asset. 2d. High contrast. No shadows
sombrero de mago de color azul 2d. In-Game asset. 2d. High contrast. No shadows
sombrero de mafioso de color rojo. In-Game asset. 2d. High contrast. No shadows
sombrero de vaquero de color naranja. In-Game asset. 2d. High contrast. No shadows
sombrero de hojas de color verde 2d. In-Game asset. 2d. High contrast. No shadows
bread 2d. In-Game asset. 2d. High contrast. No shadows
apple 2d. In-Game asset. 2d. High contrast. No shadows
chesse 2d. In-Game asset. 2d. High contrast. No shadows
red X. In-Game asset. 2d. High contrast. No shadows
green mold stain 2d. In-Game asset. 2d. High contrast. No shadows
moño. In-Game asset. 2d. High contrast. No shadows
moño negro elegante 2d. In-Game asset. 2d. High contrast. No shadows
moño azul 2d. In-Game asset. 2d. High contrast. No shadows
speechbubble. In-Game asset. 2d. High contrast. No shadows