User prompt
Make Sure The Snowball's Size Is Changing By Height and Width
User prompt
The Snowball Isn't Changing In Size
User prompt
The Snowball's Growth Should Be Half A Pixel Per Second
User prompt
The Snowball Should Grow By A Quarter Of A Pixel Per Second ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make It So That If An Obstacle Hits The Snowball, The Obstacle Breaks. The Snow Particles Should Be Coming from The Bottom Of The Snowball and Moving To The Left Like A Trail
User prompt
The Snowball Is Now Right On Top Of Twilight. Position The Snowball Right Up Against The Edge Of The Middle-Left Of The Screen
User prompt
Make It So That The Snowball Is On The Middle-Left Of The Screen. Snow Particles Should Be Coming Off The Snowball and The Snowball Slowly Gets Bigger ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make It So The Player Can Drag Twilight and The Snowball Stays In One Place
User prompt
Twilight Is Moving Too Slowly
Code edit (1 edits merged)
Please save this source code
User prompt
Twilight's Snowball Escape
Initial prompt
A Game (For PC, Console, and Mobile Devices) Where The Player (Twilight Sparkle (In Her Alicorn Form (from MLP: FiM))) Is Being Chased By A Giant Rolling Snowball (The Image For The "Game Over" Screen Is Twilight Stuck In A Snow Pile and Crying, While The Image For The "Victory" Screen Is Her Cheering With Her Wings Spread)
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.update = function () {
self.x -= self.speed;
};
return self;
});
var PowerUp = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 15;
self.type = 'shield'; // Types: shield, speed, health
self.update = function () {
self.x -= self.speed;
// Gentle floating animation
powerupGraphics.y = Math.sin(LK.ticks * 0.1) * 10;
powerupGraphics.rotation += 0.05;
};
return self;
});
var Snowball = Container.expand(function () {
var self = Container.call(this);
var snowballGraphics = self.attachAsset('snowball', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.baseSpeed = 10;
self.growthRate = 0.002;
self.update = function () {
// Move snowball forward
self.x += self.speed;
// Gradually increase speed and size
self.speed += 0.001;
var scale = 1 + LK.ticks * self.growthRate * 0.1;
snowballGraphics.scaleX = scale;
snowballGraphics.scaleY = scale;
};
return self;
});
var Twilight = Container.expand(function () {
var self = Container.call(this);
var twilightGraphics = self.attachAsset('twilight', {
anchorX: 0.5,
anchorY: 0.5
});
self.verticalSpeed = 0;
self.maxSpeed = 15;
self.acceleration = 1.2;
self.deceleration = 0.8;
self.horizontalSpeed = 12; // Forward movement speed
self.health = 3;
self.isShielded = false;
self.shieldTime = 0;
self.update = function () {
// Apply horizontal movement (running forward)
self.x += self.horizontalSpeed;
// Apply vertical movement
self.y += self.verticalSpeed;
// Apply deceleration when not moving
if (self.verticalSpeed > 0) {
self.verticalSpeed = Math.max(0, self.verticalSpeed - self.deceleration);
} else if (self.verticalSpeed < 0) {
self.verticalSpeed = Math.min(0, self.verticalSpeed + self.deceleration);
}
// Keep Twilight within screen bounds
if (self.y < 100) {
self.y = 100;
self.verticalSpeed = 0;
}
if (self.y > 2632) {
self.y = 2632;
self.verticalSpeed = 0;
}
// Handle shield effect
if (self.isShielded) {
self.shieldTime--;
twilightGraphics.tint = Math.sin(LK.ticks * 0.3) > 0 ? 0xFFFFFF : 0x00FFFF;
if (self.shieldTime <= 0) {
self.isShielded = false;
twilightGraphics.tint = 0xFFFFFF;
}
}
};
self.moveUp = function () {
self.verticalSpeed = Math.max(-self.maxSpeed, self.verticalSpeed - self.acceleration);
};
self.moveDown = function () {
self.verticalSpeed = Math.min(self.maxSpeed, self.verticalSpeed + self.acceleration);
};
self.takeDamage = function () {
if (!self.isShielded) {
self.health--;
LK.getSound('hit').play();
LK.effects.flashObject(self, 0xFF0000, 500);
return true;
}
return false;
};
self.activateShield = function () {
self.isShielded = true;
self.shieldTime = 300; // 5 seconds at 60fps
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Add background
var background = game.attachAsset('background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Game variables
var twilight;
var snowball;
var obstacles = [];
var powerups = [];
var gameSpeed = 1;
var survivalTime = 0;
var targetSurvivalTime = 3600; // 60 seconds at 60fps
var isGameActive = true;
// UI elements
var healthTxt = new Text2('Health: 3', {
size: 80,
fill: 0xFFFFFF
});
healthTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(healthTxt);
healthTxt.x = 120; // Offset from menu icon
var timeTxt = new Text2('Time: 0s', {
size: 80,
fill: 0xFFFFFF
});
timeTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(timeTxt);
var scoreTxt = new Text2('Score: 0', {
size: 80,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
// Initialize Twilight
twilight = game.addChild(new Twilight());
twilight.x = 400;
twilight.y = 1366; // Center vertically
// Initialize Snowball
snowball = game.addChild(new Snowball());
snowball.x = -300;
snowball.y = 1366;
// Touch controls
var isDragging = false;
var lastTouchY = 0;
game.down = function (x, y, obj) {
if (!isGameActive) return;
isDragging = true;
lastTouchY = y;
};
game.move = function (x, y, obj) {
if (!isGameActive || !isDragging) return;
var deltaY = y - lastTouchY;
if (deltaY < -20) {
twilight.moveUp();
} else if (deltaY > 20) {
twilight.moveDown();
}
lastTouchY = y;
};
game.up = function (x, y, obj) {
isDragging = false;
};
// Spawn obstacles
function spawnObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2200;
obstacle.y = 200 + Math.random() * 2300; // Random vertical position
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Spawn power-ups
function spawnPowerUp() {
var powerup = new PowerUp();
powerup.x = 2200;
powerup.y = 300 + Math.random() * 2100;
// Randomly assign power-up type
var types = ['shield'];
powerup.type = types[Math.floor(Math.random() * types.length)];
// Color based on type
var powerupGraphics = powerup.children[0];
if (powerup.type === 'shield') {
powerupGraphics.tint = 0x00FFFF;
}
powerups.push(powerup);
game.addChild(powerup);
}
// Update score display
function updateUI() {
healthTxt.setText('Health: ' + twilight.health);
timeTxt.setText('Time: ' + Math.floor(survivalTime / 60) + 's');
scoreTxt.setText('Score: ' + LK.getScore());
}
// Main game update
game.update = function () {
if (!isGameActive) return;
survivalTime++;
// Increase game speed over time
gameSpeed = 1 + survivalTime * 0.0002;
// Spawn obstacles
if (LK.ticks % Math.max(60, 120 - Math.floor(survivalTime * 0.02)) === 0) {
spawnObstacle();
}
// Spawn power-ups occasionally
if (LK.ticks % 600 === 0) {
// Every 10 seconds
spawnPowerUp();
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obstacle = obstacles[i];
// Remove off-screen obstacles
if (obstacle.x < -100) {
obstacle.destroy();
obstacles.splice(i, 1);
LK.setScore(LK.getScore() + 10);
continue;
}
// Check collision with Twilight
if (obstacle.intersects(twilight)) {
if (twilight.takeDamage()) {
obstacle.destroy();
obstacles.splice(i, 1);
if (twilight.health <= 0) {
isGameActive = false;
LK.effects.flashScreen(0xFF0000, 1000);
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
return;
}
}
}
}
// Update power-ups
for (var j = powerups.length - 1; j >= 0; j--) {
var powerup = powerups[j];
// Remove off-screen power-ups
if (powerup.x < -100) {
powerup.destroy();
powerups.splice(j, 1);
continue;
}
// Check collection by Twilight
if (powerup.intersects(twilight)) {
LK.getSound('collect').play();
if (powerup.type === 'shield') {
twilight.activateShield();
}
LK.setScore(LK.getScore() + 50);
powerup.destroy();
powerups.splice(j, 1);
}
}
// Check if snowball caught Twilight
if (snowball.intersects(twilight) && !twilight.isShielded) {
isGameActive = false;
LK.effects.flashScreen(0xFF0000, 1000);
LK.setTimeout(function () {
LK.showGameOver();
}, 1000);
return;
}
// Check victory condition
if (survivalTime >= targetSurvivalTime) {
isGameActive = false;
LK.effects.flashScreen(0x00FF00, 1000);
LK.setTimeout(function () {
LK.showYouWin();
}, 1000);
return;
}
// Keep snowball at a threatening distance
var targetDistance = 300 + (twilight.isShielded ? 100 : 0);
if (twilight.x - snowball.x > targetDistance) {
snowball.speed += 0.5;
} else if (twilight.x - snowball.x < targetDistance - 50) {
snowball.speed = Math.max(snowball.baseSpeed, snowball.speed - 0.2);
}
updateUI();
};
// Start background music
LK.playMusic('chase'); ===================================================================
--- original.js
+++ change.js
@@ -11,9 +11,9 @@
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 8;
+ self.speed = 15;
self.update = function () {
self.x -= self.speed;
};
return self;
@@ -23,9 +23,9 @@
var powerupGraphics = self.attachAsset('powerup', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 8;
+ self.speed = 15;
self.type = 'shield'; // Types: shield, speed, health
self.update = function () {
self.x -= self.speed;
// Gentle floating animation
@@ -39,10 +39,10 @@
var snowballGraphics = self.attachAsset('snowball', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 3;
- self.baseSpeed = 3;
+ self.speed = 10;
+ self.baseSpeed = 10;
self.growthRate = 0.002;
self.update = function () {
// Move snowball forward
self.x += self.speed;
@@ -63,12 +63,15 @@
self.verticalSpeed = 0;
self.maxSpeed = 15;
self.acceleration = 1.2;
self.deceleration = 0.8;
+ self.horizontalSpeed = 12; // Forward movement speed
self.health = 3;
self.isShielded = false;
self.shieldTime = 0;
self.update = function () {
+ // Apply horizontal movement (running forward)
+ self.x += self.horizontalSpeed;
// Apply vertical movement
self.y += self.verticalSpeed;
// Apply deceleration when not moving
if (self.verticalSpeed > 0) {