User prompt
place floor should not be the same as the game menu
User prompt
add a menu to the game and have a menu suitable for this character
User prompt
the writings should not overlap each other but all the writings should be side by side
User prompt
show how many enemies we need to capture for the next wave and how many waves we are in.
User prompt
make the background and floor like a Turkish palace
User prompt
draw me pictures of characters, swords and enemies
User prompt
when the character attacks, hit everywhere within an area
User prompt
when pressed on the right side of the screen it will attack, when pressed on the left side I can move the character left and right, up and down
User prompt
have different rounds in the game and increase the number of enemies in each round, as well as a shop system and random power-ups with different features that we will add to the sword at the end of each round DeepL ile çevrildi https://www.deepl.com/app/?utm_source=android&utm_medium=app&utm_campaign=share-translation
Code edit (1 edits merged)
Please save this source code
User prompt
Blade Rush: Endless Slash
Initial prompt
I want a pixel art mobile game with a camera angle where you look from above in a 2d unlimited area and many enemies are constantly coming wave after wave and we only cut them with a sword.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyBody = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 4 + Math.random() * 2; // base speed, will be set on spawn self.dir = 0; // direction in radians, will be set on spawn // For hit flash self.isHit = false; self.hitTicks = 0; self.update = function () { // Move towards direction self.x += Math.cos(self.dir) * self.speed; self.y += Math.sin(self.dir) * self.speed; // Hit flash if (self.isHit) { self.hitTicks--; if (self.hitTicks <= 0) { enemyBody.tint = 0xe74c3c; self.isHit = false; } } }; self.flashHit = function () { self.isHit = true; self.hitTicks = 6; enemyBody.tint = 0xffffff; }; return self; }); // Hero class var Hero = Container.expand(function () { var self = Container.call(this); // Hero body var heroBody = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); // Sword var sword = self.attachAsset('sword', { anchorX: 0.0, anchorY: 0.5, x: 60, // offset to right of hero center y: 0 }); sword.rotation = 0; sword.visible = false; // Only visible during slash // Slash effect var slash = self.attachAsset('slash', { anchorX: 0.0, anchorY: 0.5, x: 80, y: 0 }); slash.alpha = 0; slash.visible = false; // State self.sword = sword; self.slash = slash; self.slashCooldown = 0; // ticks until next slash allowed self.slashActive = false; self.slashDir = 0; // radians, direction of last slash // Slash method self.doSlash = function (dir) { if (self.slashCooldown > 0) return false; self.slashCooldown = 18; // 0.3s at 60fps self.slashActive = true; self.slashDir = dir; // Sword swing animation self.sword.visible = true; self.sword.rotation = dir - Math.PI / 2 - 0.5; tween(self.sword, { rotation: dir - Math.PI / 2 + 0.5 }, { duration: 120, easing: tween.cubicOut, onFinish: function onFinish() { self.sword.visible = false; } }); // Slash effect self.slash.visible = true; self.slash.rotation = dir - Math.PI / 2; self.slash.alpha = 0.7; tween(self.slash, { alpha: 0 }, { duration: 180, easing: tween.linear, onFinish: function onFinish() { self.slash.visible = false; } }); // Play swing sound LK.getSound('swing').play(); return true; }; // Update self.update = function () { if (self.slashCooldown > 0) { self.slashCooldown--; if (self.slashCooldown === 0) { self.slashActive = false; } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x181818 }); /**** * Game Code ****/ // Sound: sword swing // Sound: enemy hit // Slash effect: white ellipse, 90x40 // Enemy: red ellipse, 100x100 // Sword: yellow box, 80x24 // Hero: blue box, 120x120 // Game constants var ARENA_MARGIN = 60; // px, keep enemies from spawning too close to edge var HERO_START_X = 2048 / 2; var HERO_START_Y = 2732 / 2; var HERO_SPEED = 18; // px per move var ENEMY_SPAWN_INTERVAL = 60; // ticks (1s) var ENEMY_MIN_DIST = 220; // min distance from hero to spawn var ENEMY_MAX = 32; // max enemies at once // Game state var hero = new Hero(); game.addChild(hero); hero.x = HERO_START_X; hero.y = HERO_START_Y; var enemies = []; var score = 0; var wave = 1; var ticksSinceSpawn = 0; var isDragging = false; var dragOffsetX = 0; var dragOffsetY = 0; var lastTouchX = hero.x; var lastTouchY = hero.y; // Score text var scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Helper: spawn enemy at random edge, moving toward hero function spawnEnemy() { // Pick random edge: 0=top,1=bottom,2=left,3=right var edge = Math.floor(Math.random() * 4); var ex, ey; if (edge === 0) { // top ex = ARENA_MARGIN + Math.random() * (2048 - 2 * ARENA_MARGIN); ey = ARENA_MARGIN; } else if (edge === 1) { // bottom ex = ARENA_MARGIN + Math.random() * (2048 - 2 * ARENA_MARGIN); ey = 2732 - ARENA_MARGIN; } else if (edge === 2) { // left ex = ARENA_MARGIN; ey = ARENA_MARGIN + Math.random() * (2732 - 2 * ARENA_MARGIN); } else { // right ex = 2048 - ARENA_MARGIN; ey = ARENA_MARGIN + Math.random() * (2732 - 2 * ARENA_MARGIN); } // Don't spawn too close to hero var dx = ex - hero.x, dy = ey - hero.y; if (Math.sqrt(dx * dx + dy * dy) < ENEMY_MIN_DIST) { // Try again return; } var enemy = new Enemy(); enemy.x = ex; enemy.y = ey; // Direction toward hero var dir = Math.atan2(hero.y - ey, hero.x - ex); enemy.dir = dir; // Speed increases with wave enemy.speed = 3.5 + Math.random() * 1.5 + (wave - 1) * 0.25; enemies.push(enemy); game.addChild(enemy); } // Helper: check collision between two objects (circle approx) function isColliding(a, b, rA, rB) { var dx = a.x - b.x; var dy = a.y - b.y; var dist = Math.sqrt(dx * dx + dy * dy); return dist < rA + rB; } // Helper: check if point is inside sword slash arc function isInSlashArc(enemy, hero, dir) { // Sword arc: 90deg (PI/2) in direction dir, radius 180px from hero center var dx = enemy.x - hero.x; var dy = enemy.y - hero.y; var dist = Math.sqrt(dx * dx + dy * dy); if (dist > 180 || dist < 60) return false; var angle = Math.atan2(dy, dx); var diff = Math.abs((angle - dir + Math.PI * 3) % (Math.PI * 2) - Math.PI); return diff < Math.PI / 4; // 45deg to either side } // Touch controls: drag to move, tap/hold to slash in direction var dragNode = null; var dragStartX = 0, dragStartY = 0; var dragHeroStartX = 0, dragHeroStartY = 0; var lastMoveDir = 0; // Move handler: drag to move hero, tap/hold to slash function handleMove(x, y, obj) { // Don't allow hero to move into top left 100x100 if (x < 120 && y < 120) return; if (isDragging) { // Move hero var nx = x - dragOffsetX; var ny = y - dragOffsetY; // Clamp to arena nx = Math.max(ARENA_MARGIN, Math.min(2048 - ARENA_MARGIN, nx)); ny = Math.max(ARENA_MARGIN, Math.min(2732 - ARENA_MARGIN, ny)); hero.x = nx; hero.y = ny; lastTouchX = nx; lastTouchY = ny; } } game.move = handleMove; game.down = function (x, y, obj) { // If touch is on hero, start drag var dx = x - hero.x, dy = y - hero.y; if (dx * dx + dy * dy < 100 * 100) { isDragging = true; dragOffsetX = x - hero.x; dragOffsetY = y - hero.y; } else { // Not on hero: slash in direction from hero to touch var dir = Math.atan2(y - hero.y, x - hero.x); lastMoveDir = dir; hero.doSlash(dir); } }; game.up = function (x, y, obj) { isDragging = false; }; // Main update loop game.update = function () { // Update hero hero.update(); // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; enemy.update(); // If enemy off screen, remove if (enemy.x < -120 || enemy.x > 2048 + 120 || enemy.y < -120 || enemy.y > 2732 + 120) { enemy.destroy(); enemies.splice(i, 1); continue; } // If enemy collides with hero, game over if (isColliding(enemy, hero, 50, 50)) { LK.effects.flashScreen(0xff0000, 800); LK.showGameOver(); return; } // If hero is slashing and enemy in arc, destroy enemy if (hero.slashActive && isInSlashArc(enemy, hero, hero.slashDir)) { // Only allow one hit per slash per enemy if (!enemy.isHit) { enemy.flashHit(); LK.getSound('hit').play(); // Remove after short delay for flash (function (e, idx) { LK.setTimeout(function () { if (enemies.indexOf(e) !== -1) { e.destroy(); enemies.splice(enemies.indexOf(e), 1); // Score score++; scoreTxt.setText(score); } }, 80); })(enemy, i); } } } // Spawn enemies ticksSinceSpawn++; var spawnRate = Math.max(ENEMY_SPAWN_INTERVAL - (wave - 1) * 4, 24); // faster per wave if (ticksSinceSpawn >= spawnRate && enemies.length < ENEMY_MAX) { spawnEnemy(); ticksSinceSpawn = 0; } // Increase wave every 10 kills var newWave = Math.floor(score / 10) + 1; if (newWave > wave) { wave = newWave; // Flash hero LK.effects.flashObject(hero, 0x00ff00, 400); } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,322 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Enemy class
+var Enemy = Container.expand(function () {
+ var self = Container.call(this);
+ var enemyBody = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4 + Math.random() * 2; // base speed, will be set on spawn
+ self.dir = 0; // direction in radians, will be set on spawn
+ // For hit flash
+ self.isHit = false;
+ self.hitTicks = 0;
+ self.update = function () {
+ // Move towards direction
+ self.x += Math.cos(self.dir) * self.speed;
+ self.y += Math.sin(self.dir) * self.speed;
+ // Hit flash
+ if (self.isHit) {
+ self.hitTicks--;
+ if (self.hitTicks <= 0) {
+ enemyBody.tint = 0xe74c3c;
+ self.isHit = false;
+ }
+ }
+ };
+ self.flashHit = function () {
+ self.isHit = true;
+ self.hitTicks = 6;
+ enemyBody.tint = 0xffffff;
+ };
+ return self;
+});
+// Hero class
+var Hero = Container.expand(function () {
+ var self = Container.call(this);
+ // Hero body
+ var heroBody = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Sword
+ var sword = self.attachAsset('sword', {
+ anchorX: 0.0,
+ anchorY: 0.5,
+ x: 60,
+ // offset to right of hero center
+ y: 0
+ });
+ sword.rotation = 0;
+ sword.visible = false; // Only visible during slash
+ // Slash effect
+ var slash = self.attachAsset('slash', {
+ anchorX: 0.0,
+ anchorY: 0.5,
+ x: 80,
+ y: 0
+ });
+ slash.alpha = 0;
+ slash.visible = false;
+ // State
+ self.sword = sword;
+ self.slash = slash;
+ self.slashCooldown = 0; // ticks until next slash allowed
+ self.slashActive = false;
+ self.slashDir = 0; // radians, direction of last slash
+ // Slash method
+ self.doSlash = function (dir) {
+ if (self.slashCooldown > 0) return false;
+ self.slashCooldown = 18; // 0.3s at 60fps
+ self.slashActive = true;
+ self.slashDir = dir;
+ // Sword swing animation
+ self.sword.visible = true;
+ self.sword.rotation = dir - Math.PI / 2 - 0.5;
+ tween(self.sword, {
+ rotation: dir - Math.PI / 2 + 0.5
+ }, {
+ duration: 120,
+ easing: tween.cubicOut,
+ onFinish: function onFinish() {
+ self.sword.visible = false;
+ }
+ });
+ // Slash effect
+ self.slash.visible = true;
+ self.slash.rotation = dir - Math.PI / 2;
+ self.slash.alpha = 0.7;
+ tween(self.slash, {
+ alpha: 0
+ }, {
+ duration: 180,
+ easing: tween.linear,
+ onFinish: function onFinish() {
+ self.slash.visible = false;
+ }
+ });
+ // Play swing sound
+ LK.getSound('swing').play();
+ return true;
+ };
+ // Update
+ self.update = function () {
+ if (self.slashCooldown > 0) {
+ self.slashCooldown--;
+ if (self.slashCooldown === 0) {
+ self.slashActive = false;
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x181818
+});
+
+/****
+* Game Code
+****/
+// Sound: sword swing
+// Sound: enemy hit
+// Slash effect: white ellipse, 90x40
+// Enemy: red ellipse, 100x100
+// Sword: yellow box, 80x24
+// Hero: blue box, 120x120
+// Game constants
+var ARENA_MARGIN = 60; // px, keep enemies from spawning too close to edge
+var HERO_START_X = 2048 / 2;
+var HERO_START_Y = 2732 / 2;
+var HERO_SPEED = 18; // px per move
+var ENEMY_SPAWN_INTERVAL = 60; // ticks (1s)
+var ENEMY_MIN_DIST = 220; // min distance from hero to spawn
+var ENEMY_MAX = 32; // max enemies at once
+// Game state
+var hero = new Hero();
+game.addChild(hero);
+hero.x = HERO_START_X;
+hero.y = HERO_START_Y;
+var enemies = [];
+var score = 0;
+var wave = 1;
+var ticksSinceSpawn = 0;
+var isDragging = false;
+var dragOffsetX = 0;
+var dragOffsetY = 0;
+var lastTouchX = hero.x;
+var lastTouchY = hero.y;
+// Score text
+var scoreTxt = new Text2('0', {
+ size: 120,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// Helper: spawn enemy at random edge, moving toward hero
+function spawnEnemy() {
+ // Pick random edge: 0=top,1=bottom,2=left,3=right
+ var edge = Math.floor(Math.random() * 4);
+ var ex, ey;
+ if (edge === 0) {
+ // top
+ ex = ARENA_MARGIN + Math.random() * (2048 - 2 * ARENA_MARGIN);
+ ey = ARENA_MARGIN;
+ } else if (edge === 1) {
+ // bottom
+ ex = ARENA_MARGIN + Math.random() * (2048 - 2 * ARENA_MARGIN);
+ ey = 2732 - ARENA_MARGIN;
+ } else if (edge === 2) {
+ // left
+ ex = ARENA_MARGIN;
+ ey = ARENA_MARGIN + Math.random() * (2732 - 2 * ARENA_MARGIN);
+ } else {
+ // right
+ ex = 2048 - ARENA_MARGIN;
+ ey = ARENA_MARGIN + Math.random() * (2732 - 2 * ARENA_MARGIN);
+ }
+ // Don't spawn too close to hero
+ var dx = ex - hero.x,
+ dy = ey - hero.y;
+ if (Math.sqrt(dx * dx + dy * dy) < ENEMY_MIN_DIST) {
+ // Try again
+ return;
+ }
+ var enemy = new Enemy();
+ enemy.x = ex;
+ enemy.y = ey;
+ // Direction toward hero
+ var dir = Math.atan2(hero.y - ey, hero.x - ex);
+ enemy.dir = dir;
+ // Speed increases with wave
+ enemy.speed = 3.5 + Math.random() * 1.5 + (wave - 1) * 0.25;
+ enemies.push(enemy);
+ game.addChild(enemy);
+}
+// Helper: check collision between two objects (circle approx)
+function isColliding(a, b, rA, rB) {
+ var dx = a.x - b.x;
+ var dy = a.y - b.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ return dist < rA + rB;
+}
+// Helper: check if point is inside sword slash arc
+function isInSlashArc(enemy, hero, dir) {
+ // Sword arc: 90deg (PI/2) in direction dir, radius 180px from hero center
+ var dx = enemy.x - hero.x;
+ var dy = enemy.y - hero.y;
+ var dist = Math.sqrt(dx * dx + dy * dy);
+ if (dist > 180 || dist < 60) return false;
+ var angle = Math.atan2(dy, dx);
+ var diff = Math.abs((angle - dir + Math.PI * 3) % (Math.PI * 2) - Math.PI);
+ return diff < Math.PI / 4; // 45deg to either side
+}
+// Touch controls: drag to move, tap/hold to slash in direction
+var dragNode = null;
+var dragStartX = 0,
+ dragStartY = 0;
+var dragHeroStartX = 0,
+ dragHeroStartY = 0;
+var lastMoveDir = 0;
+// Move handler: drag to move hero, tap/hold to slash
+function handleMove(x, y, obj) {
+ // Don't allow hero to move into top left 100x100
+ if (x < 120 && y < 120) return;
+ if (isDragging) {
+ // Move hero
+ var nx = x - dragOffsetX;
+ var ny = y - dragOffsetY;
+ // Clamp to arena
+ nx = Math.max(ARENA_MARGIN, Math.min(2048 - ARENA_MARGIN, nx));
+ ny = Math.max(ARENA_MARGIN, Math.min(2732 - ARENA_MARGIN, ny));
+ hero.x = nx;
+ hero.y = ny;
+ lastTouchX = nx;
+ lastTouchY = ny;
+ }
+}
+game.move = handleMove;
+game.down = function (x, y, obj) {
+ // If touch is on hero, start drag
+ var dx = x - hero.x,
+ dy = y - hero.y;
+ if (dx * dx + dy * dy < 100 * 100) {
+ isDragging = true;
+ dragOffsetX = x - hero.x;
+ dragOffsetY = y - hero.y;
+ } else {
+ // Not on hero: slash in direction from hero to touch
+ var dir = Math.atan2(y - hero.y, x - hero.x);
+ lastMoveDir = dir;
+ hero.doSlash(dir);
+ }
+};
+game.up = function (x, y, obj) {
+ isDragging = false;
+};
+// Main update loop
+game.update = function () {
+ // Update hero
+ hero.update();
+ // Update enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ enemy.update();
+ // If enemy off screen, remove
+ if (enemy.x < -120 || enemy.x > 2048 + 120 || enemy.y < -120 || enemy.y > 2732 + 120) {
+ enemy.destroy();
+ enemies.splice(i, 1);
+ continue;
+ }
+ // If enemy collides with hero, game over
+ if (isColliding(enemy, hero, 50, 50)) {
+ LK.effects.flashScreen(0xff0000, 800);
+ LK.showGameOver();
+ return;
+ }
+ // If hero is slashing and enemy in arc, destroy enemy
+ if (hero.slashActive && isInSlashArc(enemy, hero, hero.slashDir)) {
+ // Only allow one hit per slash per enemy
+ if (!enemy.isHit) {
+ enemy.flashHit();
+ LK.getSound('hit').play();
+ // Remove after short delay for flash
+ (function (e, idx) {
+ LK.setTimeout(function () {
+ if (enemies.indexOf(e) !== -1) {
+ e.destroy();
+ enemies.splice(enemies.indexOf(e), 1);
+ // Score
+ score++;
+ scoreTxt.setText(score);
+ }
+ }, 80);
+ })(enemy, i);
+ }
+ }
+ }
+ // Spawn enemies
+ ticksSinceSpawn++;
+ var spawnRate = Math.max(ENEMY_SPAWN_INTERVAL - (wave - 1) * 4, 24); // faster per wave
+ if (ticksSinceSpawn >= spawnRate && enemies.length < ENEMY_MAX) {
+ spawnEnemy();
+ ticksSinceSpawn = 0;
+ }
+ // Increase wave every 10 kills
+ var newWave = Math.floor(score / 10) + 1;
+ if (newWave > wave) {
+ wave = newWave;
+ // Flash hero
+ LK.effects.flashObject(hero, 0x00ff00, 400);
+ }
+};
\ No newline at end of file
Give me an animation of a hit.. In-Game asset. 2d. High contrast. No shadows
Create a pixel art turkish character. In-Game asset. 2d. High contrast. No shadows
draw me zombie enemie. In-Game asset. 2d. High contrast. No shadows
draw me pixel art sword. In-Game asset. 2d. High contrast. No shadows
place floor draw me. In-Game asset. 2d. High contrast. No shadows