User prompt
oyun daha canlı olsun
User prompt
oyun daha canlı ve hareketli olsun
User prompt
arka ilerledikce arka pilanda ilerlesin ve farklı gezegenler cıksın
User prompt
arka pilan siyah olsun
User prompt
arka pilan uzay olsun
User prompt
arka pilanı hareket len dir
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'length')' in or related to this line: 'for (var i = 0; i < backgroundPlanets.length; i++) {' Line Number: 175
User prompt
arka pilan uzay olsun ve arkada gezegenler olsun
User prompt
arka pilanı kaldır
User prompt
arkadaki dikenli topları kaldır
User prompt
arka pilanı degistir
User prompt
son ekledigin seyi kaldır
User prompt
grafikleri geliştir
User prompt
oyunu daha canlı yap
User prompt
ARKA PİLANI UZAY YAP VE ARKADA BAZEN GEZEGENLER GÖZÜKSÜN
User prompt
BULUTLARI GERİ EKLE
User prompt
oyunu sıfırla
User prompt
oyunu 4k yap
User prompt
oyunun kalitesini arrtır
User prompt
oyunun kalitesini arttır
Code edit (1 edits merged)
Please save this source code
User prompt
Nyan Cat Sky Dash
User prompt
ana karakter nyan cat olsun
Initial prompt
bana flapy bird gibi bir oyun yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Nyan Cat class
var NyanCat = Container.expand(function () {
var self = Container.call(this);
// Rainbow trail (visual only, not collidable)
var rainbow = self.attachAsset('rainbow', {
anchorX: 1,
anchorY: 0.5,
x: -90,
y: 0,
scaleY: 1.2
});
// Add a soft highlight to rainbow for polish
rainbow.alpha = 0.92;
rainbow.tint = 0xffe0fa;
// Nyan Cat sprite
var cat = self.attachAsset('nyanCat', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
// Add a soft shadow to Nyan Cat for depth
cat.alpha = 1;
cat.tint = 0xffffff;
self.catShadow = LK.getAsset('nyanCat', {
anchorX: 0.5,
anchorY: 0.5,
x: 8,
y: 18
});
self.catShadow.alpha = 0.22;
self.catShadow.tint = 0x000000;
self.addChildAt(self.catShadow, 0);
// For collision, use the cat's bounds (not rainbow)
self.getCollisionBounds = function () {
return {
x: self.x - cat.width / 2,
y: self.y - cat.height / 2,
width: cat.width,
height: cat.height
};
};
// Flash effect on hit
self.flash = function () {
tween(cat, {
alpha: 0.3
}, {
duration: 80,
onFinish: function onFinish() {
tween(cat, {
alpha: 1
}, {
duration: 120
});
}
});
};
// Rainbow parallax movement for quality polish
self.update = function () {
// Rainbow trail parallax: slight horizontal movement for visual polish
rainbow.x = -90 + Math.sin(LK.ticks * 0.12) * 12;
// Bobbing handled in main update
};
return self;
});
// Obstacle class (cloud or star)
var Obstacle = Container.expand(function () {
var self = Container.call(this);
// Randomly choose cloud or star
var isStar = Math.random() < 0.4;
var assetId = isStar ? 'star' : 'cloud';
var asset = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5
});
// Add soft shadow for depth
self.shadow = self.attachAsset(assetId, {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: 18
});
self.shadow.alpha = 0.18;
self.shadow.tint = 0x000000;
self.addChildAt(self.shadow, 0);
self.isStar = isStar;
// For collision
self.getCollisionBounds = function () {
return {
x: self.x - asset.width / 2,
y: self.y - asset.height / 2,
width: asset.width,
height: asset.height
};
};
// Speed will be set on spawn
self.speed = 0;
self.update = function () {
self.x -= self.speed;
};
return self;
});
// Treat class (collectible)
var Treat = Container.expand(function () {
var self = Container.call(this);
var treat = self.attachAsset('treat', {
anchorX: 0.5,
anchorY: 0.5
});
// Add soft shadow for treat
self.shadow = self.attachAsset('treat', {
anchorX: 0.5,
anchorY: 0.5,
x: 10,
y: 18
});
self.shadow.alpha = 0.18;
self.shadow.tint = 0x000000;
self.addChildAt(self.shadow, 0);
// For collision
self.getCollisionBounds = function () {
return {
x: self.x - treat.width / 2,
y: self.y - treat.height / 2,
width: treat.width,
height: treat.height
};
};
// Speed will be set on spawn
self.speed = 0;
self.update = function () {
self.x -= self.speed;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
// No title, no description
// Always backgroundColor is black
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Planet assets for background planets (variety of colors/sizes)
// Starfield background
var starfieldStars = [];
var STARFIELD_STAR_COUNT = 32;
for (var s = 0; s < STARFIELD_STAR_COUNT; s++) {
var star = LK.getAsset('star', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: Math.random() * 0.5 + 0.2,
scaleY: Math.random() * 0.5 + 0.2,
alpha: Math.random() * 0.5 + 0.2,
x: Math.random() * 3840,
y: Math.random() * 2160
});
star.zIndex = -1000; // ensure behind everything
game.addChild(star);
star.speed = Math.random() * 0.7 + 0.2;
starfieldStars.push(star);
}
// Animated background clouds for more lively scene
var bgClouds = [];
var BG_CLOUD_COUNT = 7;
for (var c = 0; c < BG_CLOUD_COUNT; c++) {
var cloud = LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.7 + Math.random() * 0.7,
scaleY: 0.7 + Math.random() * 0.7,
alpha: 0.18 + Math.random() * 0.13,
x: Math.random() * 3840,
y: 180 + Math.random() * (2160 - 360)
});
cloud.zIndex = -950; // behind planets, in front of stars
cloud.speed = 0.5 + Math.random() * 0.7;
game.addChild(cloud);
bgClouds.push(cloud);
}
// Planets background system
var planetTypes = [{
id: 'planetBlue',
minScale: 0.7,
maxScale: 1.1,
alpha: 0.38
}, {
id: 'planetRed',
minScale: 0.6,
maxScale: 1.0,
alpha: 0.32
}, {
id: 'planetGreen',
minScale: 0.5,
maxScale: 0.9,
alpha: 0.28
}, {
id: 'planetYellow',
minScale: 0.4,
maxScale: 0.7,
alpha: 0.22
}, {
id: 'planetPurple',
minScale: 0.6,
maxScale: 1.0,
alpha: 0.30
}];
var planets = [];
var PLANET_COUNT = 3;
for (var p = 0; p < PLANET_COUNT; p++) {
var type = planetTypes[Math.floor(Math.random() * planetTypes.length)];
var scale = type.minScale + Math.random() * (type.maxScale - type.minScale);
var planet = LK.getAsset(type.id, {
anchorX: 0.5,
anchorY: 0.5,
scaleX: scale,
scaleY: scale,
alpha: type.alpha,
x: Math.random() * 3840,
y: Math.random() * 2160
});
planet.zIndex = -900; // behind everything except stars
planet.speed = 0.7 + Math.random() * 0.7; // slower than stars
planet._planetType = type;
game.addChild(planet);
planets.push(planet);
}
// Timer for planet respawn
var planetRespawnTimer = 0;
// Music
// Sound effects
// Rainbow trail
// Treat (pop tart)
// Obstacle (star)
// Obstacle (cloud)
// Nyan Cat (main character)
// Game area margins
var GAME_TOP = 0;
var GAME_BOTTOM = 2160;
var GAME_LEFT = 0;
var GAME_RIGHT = 3840;
// Avoid top left 100x100 for menu
var SAFE_TOP = 120;
// Main character
var nyanCat = new NyanCat();
game.addChild(nyanCat);
// Center Nyan Cat horizontally, place at 60% height
nyanCat.x = 3840 * 0.25;
nyanCat.y = 2160 * 0.6;
var nyanCatBaseY = nyanCat.y;
// Score display
var scoreTxt = new Text2('0', {
size: 220,
fill: "#fff"
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Arrays for obstacles and treats
var obstacles = [];
var treats = [];
// Difficulty parameters
var baseSpeed = 12;
var speed = baseSpeed;
var spawnInterval = 70; // ticks between spawns
var treatInterval = 110; // ticks between treat spawns
var minSpawnInterval = 30;
var maxSpeed = 32;
// Dragging
var dragNode = null;
// Last collision state
var lastHit = false;
// Play music
LK.playMusic('nyanMusic');
// Helper: collision check (AABB)
function isColliding(a, b) {
var ab = a.getCollisionBounds();
var bb = b.getCollisionBounds();
return ab.x < bb.x + bb.width && ab.x + ab.width > bb.x && ab.y < bb.y + bb.height && ab.y + ab.height > bb.y;
}
// Move handler (drag Nyan Cat)
function handleMove(x, y, obj) {
if (dragNode) {
// Clamp to game area, avoid top left 100x100
var cat = dragNode;
var bounds = cat.getCollisionBounds();
var halfW = bounds.width / 2;
var halfH = bounds.height / 2;
var minX = GAME_LEFT + halfW;
var maxX = GAME_RIGHT - halfW;
var minY = Math.max(GAME_TOP + halfH, SAFE_TOP + halfH);
var maxY = GAME_BOTTOM - halfH;
cat.x = Math.max(minX, Math.min(maxX, x));
cat.y = Math.max(minY, Math.min(maxY, y));
}
}
game.move = handleMove;
game.down = function (x, y, obj) {
// Only allow drag if touch is on Nyan Cat
var bounds = nyanCat.getCollisionBounds();
if (x >= bounds.x && x <= bounds.x + bounds.width && y >= bounds.y && y <= bounds.y + bounds.height) {
dragNode = nyanCat;
handleMove(x, y, obj);
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Game update loop
game.update = function () {
// Animate starfield
for (var s = 0; s < starfieldStars.length; s++) {
var star = starfieldStars[s];
star.x -= star.speed;
// Twinkle: animate alpha for twinkling effect
star.alpha = 0.25 + Math.abs(Math.sin(LK.ticks * 0.01 + s)) * 0.55;
// Add subtle color cycling for richer starfield
if (s % 3 === 0) {
star.tint = 0x99ccff + Math.floor(Math.sin(LK.ticks * 0.01 + s) * 0x22);
} else if (s % 3 === 1) {
star.tint = 0xffeedd + Math.floor(Math.cos(LK.ticks * 0.012 + s) * 0x22);
} else {
star.tint = 0xffffff;
}
// Add a soft glow effect by pulsing scale
star.scaleX = star.scaleY = star.scaleX + Math.abs(Math.sin(LK.ticks * 0.02 + s)) * 0.08;
// Reset if off screen
if (star.x < -100) {
star.x = 3840 + 100;
star.y = Math.random() * 2160;
star.alpha = Math.random() * 0.5 + 0.2;
star.scaleX = star.scaleY = Math.random() * 0.5 + 0.2;
star.tint = 0xffffff;
}
}
// Animate background clouds for lively sky
for (var c = 0; c < bgClouds.length; c++) {
var cloud = bgClouds[c];
cloud.x -= cloud.speed;
// Gentle vertical floating for more life
cloud.y += Math.sin(LK.ticks * 0.008 + c) * 0.18;
if (cloud.x < -cloud.width * cloud.scaleX) {
cloud.x = 3840 + cloud.width * cloud.scaleX + Math.random() * 200;
cloud.y = 180 + Math.random() * (2160 - 360);
cloud.scaleX = cloud.scaleY = 0.7 + Math.random() * 0.7;
cloud.alpha = 0.18 + Math.random() * 0.13;
cloud.speed = 0.5 + Math.random() * 0.7;
}
}
// Animate planets (move left, respawn if off screen, occasionally spawn new)
for (var p = 0; p < planets.length; p++) {
var planet = planets[p];
planet.x -= planet.speed;
// Subtle slow rotation for visual polish
planet.rotation += 0.0007 + Math.random() * 0.0005;
// Add animated glow and color cycling for vibrancy
var glowPulse = 0.98 + Math.abs(Math.sin(LK.ticks * 0.008 + p)) * 0.13;
planet.scaleX = planet.scaleY = (planet._planetType ? planet._planetType.minScale + Math.random() * (planet._planetType.maxScale - planet._planetType.minScale) : 1) * glowPulse;
if (planet._planetType && planet._planetType.id === 'planetBlue') {
planet.tint = 0x7ecbff + Math.floor(Math.sin(LK.ticks * 0.01 + p) * 0x22);
} else if (planet._planetType && planet._planetType.id === 'planetRed') {
planet.tint = 0xffb3b3 + Math.floor(Math.cos(LK.ticks * 0.012 + p) * 0x22);
} else if (planet._planetType && planet._planetType.id === 'planetGreen') {
planet.tint = 0xbaffc9 + Math.floor(Math.sin(LK.ticks * 0.013 + p) * 0x22);
} else if (planet._planetType && planet._planetType.id === 'planetYellow') {
planet.tint = 0xfff7b2 + Math.floor(Math.cos(LK.ticks * 0.014 + p) * 0x22);
} else if (planet._planetType && planet._planetType.id === 'planetPurple') {
planet.tint = 0xe0b3ff + Math.floor(Math.sin(LK.ticks * 0.015 + p) * 0x22);
} else {
planet.tint = 0xffffff;
}
if (planet.x < -planet.width * planet.scaleX) {
// Remove and respawn later
planet.visible = false;
planet._respawnTick = LK.ticks + 600 + Math.floor(Math.random() * 1200);
}
}
// Respawn planets if their timer is up, and randomly show a new one every ~7-12 seconds
for (var p = 0; p < planets.length; p++) {
var planet = planets[p];
if (!planet.visible && planet._respawnTick && LK.ticks > planet._respawnTick) {
// Pick new type and scale
var type = planetTypes[Math.floor(Math.random() * planetTypes.length)];
var scale = type.minScale + Math.random() * (type.maxScale - type.minScale);
planet.texture = LK.getAsset(type.id, {
anchorX: 0.5,
anchorY: 0.5
}).texture;
planet.scaleX = scale;
planet.scaleY = scale;
planet.alpha = type.alpha;
planet.x = 3840 + planet.width * scale + Math.random() * 400;
planet.y = 300 + Math.random() * (2160 - 600);
planet.speed = 0.7 + Math.random() * 0.7;
planet.rotation = Math.random() * Math.PI * 2;
planet.visible = true;
planet._planetType = type;
planet._respawnTick = null;
}
}
// Increase difficulty over time
if (LK.ticks % 180 === 0 && speed < maxSpeed) {
speed += 1.2;
spawnInterval = Math.max(minSpawnInterval, spawnInterval - 4);
}
// Spawn obstacles
if (LK.ticks % spawnInterval === 0) {
var obs = new Obstacle();
obs.speed = speed;
// Random Y, avoid top 100px
var asset = obs.children[0];
var minY = SAFE_TOP + asset.height / 2;
var maxY = GAME_BOTTOM - asset.height / 2;
obs.x = GAME_RIGHT + asset.width / 2 + 10;
obs.y = Math.random() * (maxY - minY) + minY;
obstacles.push(obs);
game.addChild(obs);
}
// Spawn treats
if (LK.ticks % treatInterval === 0) {
var treat = new Treat();
treat.speed = speed * 0.95;
var asset = treat.children[0];
var minY = SAFE_TOP + asset.height / 2;
var maxY = GAME_BOTTOM - asset.height / 2;
treat.x = GAME_RIGHT + asset.width / 2 + 10;
treat.y = Math.random() * (maxY - minY) + minY;
treats.push(treat);
game.addChild(treat);
}
// Update obstacles
for (var i = obstacles.length - 1; i >= 0; i--) {
var obs = obstacles[i];
obs.update();
// Remove if off screen
if (obs.x < -300) {
obs.destroy();
obstacles.splice(i, 1);
continue;
}
// Collision with Nyan Cat
var hit = isColliding(obs, nyanCat);
if (hit && !lastHit) {
// Flash, play sound, game over
nyanCat.flash();
LK.getSound('hit').play();
LK.effects.flashScreen(0xff0000, 800);
LK.showGameOver();
lastHit = true;
break; // Stop further checks
}
}
// Update treats
for (var j = treats.length - 1; j >= 0; j--) {
var treat = treats[j];
treat.update();
// Remove if off screen
if (treat.x < -200) {
treat.destroy();
treats.splice(j, 1);
continue;
}
// Collision with Nyan Cat
if (isColliding(treat, nyanCat)) {
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
LK.getSound('collect').play();
// Animate treat
tween(treat, {
scaleX: 2.1,
scaleY: 2.1,
alpha: 0
}, {
duration: 220,
ease: "outBack",
onFinish: function onFinish() {
treat.destroy();
}
});
treats.splice(j, 1);
continue;
}
}
// Nyan Cat idle bobbing and lively animation
if (!dragNode) {
nyanCat.y = nyanCatBaseY + Math.sin(LK.ticks * 0.08) * 22;
// Subtle rotation and scale for lively effect
if (nyanCat.children && nyanCat.children.length > 1) {
var catSprite = nyanCat.children[1];
catSprite.rotation = Math.sin(LK.ticks * 0.07) * 0.08;
catSprite.scaleX = 1 + Math.sin(LK.ticks * 0.11) * 0.04;
catSprite.scaleY = 1 + Math.cos(LK.ticks * 0.13) * 0.04;
}
}
// Reset lastHit if not colliding
if (!obstacles.some(function (obs) {
return isColliding(obs, nyanCat);
})) {
lastHit = false;
}
};
// Reset score and all game state on game start
LK.setScore(0);
scoreTxt.setText('0');
// Remove all obstacles and treats from game
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].destroy();
}
obstacles = [];
for (var j = 0; j < treats.length; j++) {
treats[j].destroy();
}
treats = [];
// Reset Nyan Cat position and base Y
nyanCat.x = 3840 * 0.25;
nyanCat.y = 2160 * 0.6;
nyanCatBaseY = nyanCat.y;
// Reset difficulty
speed = baseSpeed;
spawnInterval = 70;
treatInterval = 110;
// Reset drag and collision state
dragNode = null;
lastHit = false; ===================================================================
--- original.js
+++ change.js
@@ -485,45 +485,8 @@
}, {
duration: 220,
ease: "outBack",
onFinish: function onFinish() {
- // Sparkle burst effect
- for (var sp = 0; sp < 7; sp++) {
- var sparkle = LK.getAsset('star', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.3 + Math.random() * 0.2,
- scaleY: 0.3 + Math.random() * 0.2,
- alpha: 0.8,
- x: treat.x,
- y: treat.y
- });
- game.addChild(sparkle);
- var angle = Math.PI * 2 * (sp / 7) + Math.random() * 0.3;
- var dist = 120 + Math.random() * 60;
- tween(sparkle, {
- x: treat.x + Math.cos(angle) * dist,
- y: treat.y + Math.sin(angle) * dist,
- alpha: 0
- }, {
- duration: 320 + Math.random() * 120,
- onFinish: function (sparkle) {
- return function () {
- sparkle.destroy();
- };
- }(sparkle)
- });
- // Sparkle twinkle for extra lively effect
- tween(sparkle, {
- scaleX: sparkle.scaleX * 1.7,
- scaleY: sparkle.scaleY * 1.7,
- alpha: 0.95
- }, {
- duration: 80 + Math.random() * 60,
- yoyo: true,
- repeat: 1
- });
- }
treat.destroy();
}
});
treats.splice(j, 1);
NYAN CAT. In-Game asset. 2d. High contrast. No shadows
DİKENLİ TOP. In-Game asset. 2d. High contrast. No shadows
TAŞ. In-Game asset. 2d. High contrast. No shadows
kurabiye. In-Game asset. 2d. High contrast. No shadows
satürn. In-Game asset. 2d. High contrast. No shadows
neptün. In-Game asset. 2d. High contrast. No shadows