User prompt
uzaylılar bize değince canımız gitsin oyunda 2 canımız olsun
User prompt
oyunda uzaylılar olsun silahımızla onları vurup yok edelim
User prompt
oyunda trambolin olsun ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
bir silahımız olsun
User prompt
karakter sürekli zıplasın
User prompt
150 coine ulaşınca bravo yazan bir tabele çıksın
User prompt
oyuna coin getir
User prompt
basılı tutma olsun
User prompt
sağa sola gidişatının hızını çok az azalt ve kayma olmasın
User prompt
sağa sola gidiş hızını arttır zıplamasını azalt
User prompt
zıplamasını 2 kat arttır
User prompt
sağa sola gitsin
Code edit (1 edits merged)
Please save this source code
User prompt
Dude Jump
Initial prompt
bana dule jump yap
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Alien = Container.expand(function () {
var self = Container.call(this);
var alienGraphics = self.attachAsset('alien', {
anchorX: 0.5,
anchorY: 0.5
});
self.health = 3;
self.speed = 1;
self.direction = 1;
self.moveRange = 200;
self.startX = 0;
self.active = true;
self.lastWasHit = false;
self.takeDamage = function () {
self.health--;
if (self.health <= 0) {
self.active = false;
LK.getSound('alienDestroy').play();
// Flash effect before destruction
tween(alienGraphics, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
onFinish: function onFinish() {
self.destroy();
}
});
} else {
LK.getSound('alienHit').play();
// Flash red when hit
LK.effects.flashObject(self, 0xff0000, 200);
}
};
self.update = function () {
if (!self.active) return;
// Move alien horizontally
self.x += self.direction * self.speed;
// Reverse direction when reaching movement limits
if (self.x > self.startX + self.moveRange || self.x < self.startX - self.moveRange) {
self.direction *= -1;
}
// Bob up and down slightly
self.y += Math.sin(LK.ticks * 0.03) * 0.3;
// Keep alien within screen bounds
if (self.x < 40) {
self.x = 40;
self.direction = 1;
}
if (self.x > 2008) {
self.x = 2008;
self.direction = -1;
}
};
return self;
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -15;
self.active = true;
self.update = function () {
self.y += self.speed;
// Remove bullet if it goes off screen
if (self.y < cameraY - 200) {
self.active = false;
}
};
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.rotationSpeed = 0.1;
self.update = function () {
// Rotate coin for visual appeal
coinGraphics.rotation += self.rotationSpeed;
// Float up and down slightly
self.y += Math.sin(LK.ticks * 0.05) * 0.5;
};
return self;
});
var Dude = Container.expand(function () {
var self = Container.call(this);
var dudeGraphics = self.attachAsset('dude', {
anchorX: 0.5,
anchorY: 0.5
});
self.velocityY = 0;
self.velocityX = 0;
self.isJumping = false;
self.isOnPlatform = false;
self.jumpPower = 35;
self.gravity = 0.8;
self.maxFallSpeed = 15;
self.horizontalSpeed = 12;
self.airResistance = 0.85;
self.invincible = false;
self.invincibleTimer = 0;
self.jump = function () {
if (self.isOnPlatform) {
self.velocityY = -self.jumpPower;
self.isJumping = true;
self.isOnPlatform = false;
LK.getSound('jump').play();
}
};
self.update = function () {
// Auto jump when on platform
if (self.isOnPlatform) {
self.jump();
}
// Apply gravity
self.velocityY += self.gravity;
if (self.velocityY > self.maxFallSpeed) {
self.velocityY = self.maxFallSpeed;
}
// Update position
self.y += self.velocityY;
self.x += self.velocityX;
// Apply continuous horizontal movement while pressed
if (isPressed && pressedSide !== 0) {
self.velocityX += pressedSide * self.horizontalSpeed * 0.3;
}
// Apply air resistance to horizontal movement
self.velocityX *= self.airResistance;
// Handle invincibility timer
if (self.invincible) {
self.invincibleTimer--;
if (self.invincibleTimer <= 0) {
self.invincible = false;
dudeGraphics.alpha = 1;
} else {
dudeGraphics.alpha = Math.sin(self.invincibleTimer * 0.3) * 0.5 + 0.5;
}
}
// Keep dude on screen horizontally
if (self.x < 40) self.x = 40;
if (self.x > 2008) self.x = 2008;
// Check if fallen off screen
if (self.y > cameraY + 2732 + 200) {
LK.showGameOver();
}
};
self.shoot = function () {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y - 30;
bullets.push(bullet);
game.addChild(bullet);
LK.getSound('shoot').play();
};
return self;
});
var Platform = Container.expand(function (type) {
var self = Container.call(this);
self.type = type || 'normal';
self.landed = false;
self.disappearing = false;
self.moveDirection = 1;
self.moveRange = 300;
self.startX = 0;
var platformGraphics;
if (self.type === 'moving') {
platformGraphics = self.attachAsset('movingPlatform', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.type === 'disappearing') {
platformGraphics = self.attachAsset('disappearingPlatform', {
anchorX: 0.5,
anchorY: 0.5
});
} else if (self.type === 'powerup') {
platformGraphics = self.attachAsset('powerUpPlatform', {
anchorX: 0.5,
anchorY: 0.5
});
} else {
platformGraphics = self.attachAsset('platform', {
anchorX: 0.5,
anchorY: 0.5
});
}
self.update = function () {
// Moving platform behavior
if (self.type === 'moving') {
self.x += self.moveDirection * 2;
if (self.x > self.startX + self.moveRange || self.x < self.startX - self.moveRange) {
self.moveDirection *= -1;
}
}
// Disappearing platform behavior
if (self.type === 'disappearing' && self.landed && !self.disappearing) {
self.disappearing = true;
tween(platformGraphics, {
alpha: 0
}, {
duration: 1000,
onFinish: function onFinish() {
self.active = false;
}
});
}
};
return self;
});
var Trampoline = Container.expand(function () {
var self = Container.call(this);
var trampolineGraphics = self.attachAsset('trampoline', {
anchorX: 0.5,
anchorY: 0.5
});
self.bounced = false;
self.active = true;
self.bounce = function () {
// Animate trampoline compression and expansion
tween(trampolineGraphics, {
scaleY: 0.5
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(trampolineGraphics, {
scaleY: 1.2
}, {
duration: 200,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(trampolineGraphics, {
scaleY: 1
}, {
duration: 100,
easing: tween.easeOut
});
}
});
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
var dude = game.addChild(new Dude());
var platforms = [];
var coins = [];
var bullets = [];
var trampolines = [];
var cameraY = 0;
var highestY = 2400;
var lastPlatformY = 2400;
var platformSpacing = 200;
var coinsCollected = 0;
var lastShootTime = 0;
var shootCooldown = 20; // 20 ticks between shots
var aliens = [];
var aliensKilled = 0;
// Create score display
var scoreTxt = new Text2('0', {
size: 60,
fill: 0xFFFFFF
});
scoreTxt.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreTxt);
// Create height display
var heightTxt = new Text2('Height: 0m', {
size: 40,
fill: 0xFFFFFF
});
heightTxt.anchor.set(1, 0);
heightTxt.x = -20;
heightTxt.y = 20;
LK.gui.topRight.addChild(heightTxt);
// Create coin counter display
var coinTxt = new Text2('Coins: 0', {
size: 40,
fill: 0xffd700
});
coinTxt.anchor.set(0, 0);
coinTxt.x = 20;
coinTxt.y = 20;
LK.gui.topLeft.addChild(coinTxt);
// Initialize dude position
dude.x = 1024;
dude.y = 2400;
// Create initial platforms
function createPlatform(x, y, type) {
var platform = new Platform(type);
platform.x = x;
platform.y = y;
platform.startX = x;
platform.active = true;
platforms.push(platform);
game.addChild(platform);
return platform;
}
// Create starting platform
createPlatform(1024, 2450, 'normal');
// Generate initial platforms
for (var i = 0; i < 20; i++) {
generateNextPlatform();
}
function generateNextPlatform() {
lastPlatformY -= platformSpacing + Math.random() * 100;
var x = 200 + Math.random() * 1648;
// Determine platform type based on height
var type = 'normal';
var height = Math.abs(lastPlatformY - 2400);
if (height > 1000) {
var rand = Math.random();
if (rand < 0.3) {
type = 'moving';
} else if (rand < 0.5) {
type = 'disappearing';
} else if (rand < 0.6) {
type = 'powerup';
}
}
createPlatform(x, lastPlatformY, type);
// Generate coins near platforms (70% chance)
if (Math.random() < 0.7) {
generateCoin(x + (Math.random() - 0.5) * 200, lastPlatformY - 80);
}
// Generate trampolines occasionally (20% chance)
if (Math.random() < 0.2) {
createTrampoline(x, lastPlatformY - 100);
}
// Generate aliens occasionally (30% chance)
if (Math.random() < 0.3) {
createAlien(x + (Math.random() - 0.5) * 300, lastPlatformY - 150);
}
}
function generateCoin(x, y) {
var coin = new Coin();
coin.x = x;
coin.y = y;
coin.active = true;
coins.push(coin);
game.addChild(coin);
}
function createTrampoline(x, y) {
var trampoline = new Trampoline();
trampoline.x = x;
trampoline.y = y;
trampoline.active = true;
trampolines.push(trampoline);
game.addChild(trampoline);
return trampoline;
}
function createAlien(x, y) {
var alien = new Alien();
alien.x = x;
alien.y = y;
alien.startX = x;
alien.active = true;
aliens.push(alien);
game.addChild(alien);
return alien;
}
function updateCamera() {
var targetY = dude.y - 1800;
if (targetY < cameraY) {
cameraY = targetY;
game.y = -cameraY;
// Update highest position
if (dude.y < highestY) {
highestY = dude.y;
var height = Math.floor((2400 - highestY) / 10);
LK.setScore(height);
scoreTxt.setText(LK.getScore());
heightTxt.setText('Height: ' + height + 'm');
}
}
}
function checkPlatformCollisions() {
if (dude.velocityY <= 0) return; // Only check when falling
for (var i = 0; i < platforms.length; i++) {
var platform = platforms[i];
if (!platform.active) continue;
var dudeBottom = dude.y + 40;
var platformTop = platform.y - 15;
var platformBottom = platform.y + 15;
if (dudeBottom >= platformTop && dudeBottom <= platformBottom + 20) {
if (dude.x >= platform.x - 100 && dude.x <= platform.x + 100) {
// Landing on platform
dude.y = platformTop - 40;
dude.velocityY = 0;
dude.isOnPlatform = true;
dude.isJumping = false;
if (!platform.landed) {
platform.landed = true;
LK.getSound('land').play();
// Handle special platform effects
if (platform.type === 'powerup') {
dude.invincible = true;
dude.invincibleTimer = 300;
dude.jumpPower = 35;
LK.getSound('powerup').play();
// Reset jump power after time
LK.setTimeout(function () {
dude.jumpPower = 50;
}, 3000);
}
}
break;
}
}
}
}
function checkCoinCollisions() {
for (var i = coins.length - 1; i >= 0; i--) {
var coin = coins[i];
if (!coin.active || coin.collected) continue;
// Check if dude is close enough to collect coin
var distance = Math.sqrt(Math.pow(dude.x - coin.x, 2) + Math.pow(dude.y - coin.y, 2));
if (distance < 50) {
// Collect coin
coin.collected = true;
coin.active = false;
coinsCollected++;
coinTxt.setText('Coins: ' + coinsCollected);
LK.getSound('coinCollect').play();
// Check if player reached 150 coins
if (coinsCollected >= 150) {
// Show bravo message
LK.showYouWin();
}
// Remove coin with fade effect
tween(coin, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 200,
onFinish: function onFinish() {
coin.destroy();
coins.splice(i, 1);
}
});
}
}
}
function checkTrampolineCollisions() {
if (dude.velocityY <= 0) return; // Only check when falling
for (var i = 0; i < trampolines.length; i++) {
var trampoline = trampolines[i];
if (!trampoline.active) continue;
var dudeBottom = dude.y + 40;
var trampolineTop = trampoline.y - 30;
var trampolineBottom = trampoline.y + 30;
if (dudeBottom >= trampolineTop && dudeBottom <= trampolineBottom + 20) {
if (dude.x >= trampoline.x - 100 && dude.x <= trampoline.x + 100) {
// Bounce off trampoline with super jump
dude.velocityY = -60; // Much higher than normal jump
dude.isJumping = true;
dude.isOnPlatform = false;
trampoline.bounce();
LK.getSound('jump').play();
break;
}
}
}
}
function checkBulletAlienCollisions() {
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (!bullet.active) continue;
for (var j = aliens.length - 1; j >= 0; j--) {
var alien = aliens[j];
if (!alien.active) continue;
// Check collision between bullet and alien
var distance = Math.sqrt(Math.pow(bullet.x - alien.x, 2) + Math.pow(bullet.y - alien.y, 2));
if (distance < 50) {
// Hit detected
bullet.active = false;
bullet.destroy();
bullets.splice(i, 1);
alien.takeDamage();
if (!alien.active) {
aliensKilled++;
aliens.splice(j, 1);
// Increase score for killing alien
LK.setScore(LK.getScore() + 10);
scoreTxt.setText(LK.getScore());
}
break;
}
}
}
}
function cleanupPlatforms() {
for (var i = platforms.length - 1; i >= 0; i--) {
var platform = platforms[i];
if (platform.y > cameraY + 3000 || !platform.active) {
platform.destroy();
platforms.splice(i, 1);
}
}
}
function cleanupCoins() {
for (var i = coins.length - 1; i >= 0; i--) {
var coin = coins[i];
if (coin.y > cameraY + 3000 || !coin.active) {
coin.destroy();
coins.splice(i, 1);
}
}
}
function cleanupBullets() {
for (var i = bullets.length - 1; i >= 0; i--) {
var bullet = bullets[i];
if (bullet.y < cameraY - 200 || !bullet.active) {
bullet.destroy();
bullets.splice(i, 1);
}
}
}
function cleanupTrampolines() {
for (var i = trampolines.length - 1; i >= 0; i--) {
var trampoline = trampolines[i];
if (trampoline.y > cameraY + 3000 || !trampoline.active) {
trampoline.destroy();
trampolines.splice(i, 1);
}
}
}
function cleanupAliens() {
for (var i = aliens.length - 1; i >= 0; i--) {
var alien = aliens[i];
if (alien.y > cameraY + 3000 || !alien.active) {
if (alien.active) {
alien.destroy();
}
aliens.splice(i, 1);
}
}
}
function generateMorePlatforms() {
while (lastPlatformY > cameraY - 1000) {
generateNextPlatform();
}
}
// Touch controls
var isPressed = false;
var pressedSide = 0; // -1 for left, 1 for right, 0 for center
game.down = function (x, y, obj) {
dude.jump();
isPressed = true;
// Determine which side was pressed
var screenCenter = 1024; // Half of 2048
var touchOffset = x - screenCenter;
if (touchOffset > 50) {
pressedSide = 1; // Right side
} else if (touchOffset < -50) {
pressedSide = -1; // Left side
} else {
pressedSide = 0; // Center
}
// Shoot when touching center area
if (Math.abs(touchOffset) <= 50 && LK.ticks - lastShootTime >= shootCooldown) {
dude.shoot();
lastShootTime = LK.ticks;
}
};
game.up = function (x, y, obj) {
isPressed = false;
pressedSide = 0;
};
// Main game loop
game.update = function () {
updateCamera();
checkPlatformCollisions();
checkTrampolineCollisions();
checkCoinCollisions();
checkBulletAlienCollisions();
cleanupPlatforms();
generateMorePlatforms();
// Remove platforms that are too far down
if (LK.ticks % 60 === 0) {
cleanupPlatforms();
cleanupCoins();
cleanupBullets();
cleanupTrampolines();
cleanupAliens();
}
}; ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,65 @@
/****
* Classes
****/
+var Alien = Container.expand(function () {
+ var self = Container.call(this);
+ var alienGraphics = self.attachAsset('alien', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 3;
+ self.speed = 1;
+ self.direction = 1;
+ self.moveRange = 200;
+ self.startX = 0;
+ self.active = true;
+ self.lastWasHit = false;
+ self.takeDamage = function () {
+ self.health--;
+ if (self.health <= 0) {
+ self.active = false;
+ LK.getSound('alienDestroy').play();
+ // Flash effect before destruction
+ tween(alienGraphics, {
+ alpha: 0,
+ scaleX: 1.5,
+ scaleY: 1.5
+ }, {
+ duration: 300,
+ onFinish: function onFinish() {
+ self.destroy();
+ }
+ });
+ } else {
+ LK.getSound('alienHit').play();
+ // Flash red when hit
+ LK.effects.flashObject(self, 0xff0000, 200);
+ }
+ };
+ self.update = function () {
+ if (!self.active) return;
+ // Move alien horizontally
+ self.x += self.direction * self.speed;
+ // Reverse direction when reaching movement limits
+ if (self.x > self.startX + self.moveRange || self.x < self.startX - self.moveRange) {
+ self.direction *= -1;
+ }
+ // Bob up and down slightly
+ self.y += Math.sin(LK.ticks * 0.03) * 0.3;
+ // Keep alien within screen bounds
+ if (self.x < 40) {
+ self.x = 40;
+ self.direction = 1;
+ }
+ if (self.x > 2008) {
+ self.x = 2008;
+ self.direction = -1;
+ }
+ };
+ return self;
+});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
@@ -221,8 +278,10 @@
var platformSpacing = 200;
var coinsCollected = 0;
var lastShootTime = 0;
var shootCooldown = 20; // 20 ticks between shots
+var aliens = [];
+var aliensKilled = 0;
// Create score display
var scoreTxt = new Text2('0', {
size: 60,
fill: 0xFFFFFF
@@ -291,8 +350,12 @@
// Generate trampolines occasionally (20% chance)
if (Math.random() < 0.2) {
createTrampoline(x, lastPlatformY - 100);
}
+ // Generate aliens occasionally (30% chance)
+ if (Math.random() < 0.3) {
+ createAlien(x + (Math.random() - 0.5) * 300, lastPlatformY - 150);
+ }
}
function generateCoin(x, y) {
var coin = new Coin();
coin.x = x;
@@ -309,8 +372,18 @@
trampolines.push(trampoline);
game.addChild(trampoline);
return trampoline;
}
+function createAlien(x, y) {
+ var alien = new Alien();
+ alien.x = x;
+ alien.y = y;
+ alien.startX = x;
+ alien.active = true;
+ aliens.push(alien);
+ game.addChild(alien);
+ return alien;
+}
function updateCamera() {
var targetY = dude.y - 1800;
if (targetY < cameraY) {
cameraY = targetY;
@@ -413,8 +486,35 @@
}
}
}
}
+function checkBulletAlienCollisions() {
+ for (var i = bullets.length - 1; i >= 0; i--) {
+ var bullet = bullets[i];
+ if (!bullet.active) continue;
+ for (var j = aliens.length - 1; j >= 0; j--) {
+ var alien = aliens[j];
+ if (!alien.active) continue;
+ // Check collision between bullet and alien
+ var distance = Math.sqrt(Math.pow(bullet.x - alien.x, 2) + Math.pow(bullet.y - alien.y, 2));
+ if (distance < 50) {
+ // Hit detected
+ bullet.active = false;
+ bullet.destroy();
+ bullets.splice(i, 1);
+ alien.takeDamage();
+ if (!alien.active) {
+ aliensKilled++;
+ aliens.splice(j, 1);
+ // Increase score for killing alien
+ LK.setScore(LK.getScore() + 10);
+ scoreTxt.setText(LK.getScore());
+ }
+ break;
+ }
+ }
+ }
+}
function cleanupPlatforms() {
for (var i = platforms.length - 1; i >= 0; i--) {
var platform = platforms[i];
if (platform.y > cameraY + 3000 || !platform.active) {
@@ -449,8 +549,19 @@
trampolines.splice(i, 1);
}
}
}
+function cleanupAliens() {
+ for (var i = aliens.length - 1; i >= 0; i--) {
+ var alien = aliens[i];
+ if (alien.y > cameraY + 3000 || !alien.active) {
+ if (alien.active) {
+ alien.destroy();
+ }
+ aliens.splice(i, 1);
+ }
+ }
+}
function generateMorePlatforms() {
while (lastPlatformY > cameraY - 1000) {
generateNextPlatform();
}
@@ -486,14 +597,16 @@
updateCamera();
checkPlatformCollisions();
checkTrampolineCollisions();
checkCoinCollisions();
+ checkBulletAlienCollisions();
cleanupPlatforms();
generateMorePlatforms();
// Remove platforms that are too far down
if (LK.ticks % 60 === 0) {
cleanupPlatforms();
cleanupCoins();
cleanupBullets();
cleanupTrampolines();
+ cleanupAliens();
}
};
\ No newline at end of file
bir sevimli gülen yüzlü uzaylı. In-Game asset. 2d. High contrast. No shadows
coin. In-Game asset. 2d. High contrast. No shadows
trambolin. In-Game asset. 2d. High contrast. No shadows
çirkin korkutucu uzaylı. In-Game asset. 2d. High contrast. No shadows
kalp. In-Game asset. 2d. High contrast. No shadows
bir düğme ama içinde kurukafa .işareti olsun şeffaf. In-Game asset. 2d. High contrast. No shadows
platform. In-Game asset. 2d. High contrast. No shadows
güç platformu. In-Game asset. 2d. High contrast. No shadows
yuvarlak yeşil top. In-Game asset. 2d. High contrast. No shadows
sevimli bana yardım edin diyen bir uzaylı. In-Game asset. 2d. High contrast. No shadows
ufo. In-Game asset. 2d. High contrast. No shadows
bomba. In-Game asset. 2d. High contrast. No shadows
falsh bombası. In-Game asset. 2d. High contrast. No shadows