User prompt
make the woods look more realistic make a sound when the wood explodes use a better effect for the sound of the wood breaking
User prompt
The timer bar should look better, have a hit animation, have an explosion animation after the tree explodes. The character should be more realistic, look like an anime and be an old kunfu master, have long moustache, long eyebrows and a long single beard, all white, look like a funny kunfu master
User prompt
He doesn't look like Jackie Chan and the character should be more realistic and focused on woods!!!!
User prompt
Make the yellow box a karate master and it will resemble Jackie Chan
User prompt
Let the clouds be more realistic, let them be all over the screen, slightly transparent and make it look like we are in the sky without affecting the gameplay.
User prompt
Let the clouds be more vivid and realistic, let them move slowly, and let the snowflakes pass from everywhere, not from a certain area.
User prompt
Let it snow lightly and the game takes place in the sky among the clouds.
User prompt
Let it snow lightly
Code edit (1 edits merged)
Please save this source code
User prompt
Timber Chop Frenzy
Initial prompt
Create an arcade-style reflex game similar to Timberman. The player controls a lumberjack standing next to a tall tree. The goal is to chop the tree by tapping. Each tap breaks one section of the tree and gives 1 point. Tree branches randomly appear on either the left or right side of the trunk. The player must switch sides (left/right) to avoid the branches. If the player is on the same side as a branch when they chop, the game ends. Controls: - Tap to chop the tree - Swipe left or right to switch sides The tree is made of multiple repeating segments stacked vertically. When a segment is chopped, a new one appears on top. Add a timer: the player must keep chopping quickly to stay alive. If the player stops or is too slow, the game ends.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ // Lumberjack: The player character var Lumberjack = Container.expand(function () { var self = Container.call(this); // Side: 'left' or 'right' self.side = 'left'; // Character body var jack = self.attachAsset('lumberjack', { anchorX: 0.5, anchorY: 1 }); // Set side ('left' or 'right') self.setSide = function (side) { self.side = side; if (side === 'left') { self.x = treeX - trunkWidth / 2 - jack.width / 2 - 40; self.scaleX = 1; } else { self.x = treeX + trunkWidth / 2 + jack.width / 2 + 40; self.scaleX = -1; } }; // Chop animation self.chop = function () { // Animate a quick scale for feedback tween(self, { scaleY: 0.85 }, { duration: 60, easing: tween.cubicOut, onFinish: function onFinish() { tween(self, { scaleY: 1 }, { duration: 80, easing: tween.cubicIn }); } }); }; return self; }); // TreeSegment: A single segment of the tree, may have a branch (left/right/none) var TreeSegment = Container.expand(function () { var self = Container.call(this); // Default: no branch self.branch = 'none'; // 'left', 'right', 'none' // Tree trunk var trunk = self.attachAsset('treeTrunk', { anchorX: 0.5, anchorY: 0.5 }); // Branch (if any) self.branchNode = null; // Set up the segment (branchSide: 'left', 'right', or 'none') self.setup = function (branchSide) { self.branch = branchSide; if (self.branchNode) { self.removeChild(self.branchNode); self.branchNode = null; } if (branchSide === 'left') { self.branchNode = self.attachAsset('treeBranch', { anchorX: 1, anchorY: 0.5, x: -trunk.width / 2, y: 0 }); } else if (branchSide === 'right') { self.branchNode = self.attachAsset('treeBranch', { anchorX: 0, anchorY: 0.5, x: trunk.width / 2, y: 0, flipX: 1 }); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x6ec6f1 // Light blue sky }); /**** * Game Code ****/ // --- Game Variables --- // --- Asset Initialization (auto by LK engine) --- // Tree trunk segment // Branch // Lumberjack // Chop sound // Fail sound var treeSegments = []; // Array of TreeSegment var treeX = 2048 / 2; var treeBaseY = 2732 - 350; // Y position of the bottom segment var trunkWidth = 180; var trunkHeight = 120; var visibleSegments = 10; // Number of segments visible on screen var branchChance = 0.35; // Probability of a branch per segment var lastBranch = 'none'; // To avoid impossible patterns var player = null; var scoreTxt = null; var timerBar = null; var timeLeft = 2000; // ms, time before game over var maxTime = 2000; // ms, resets to this on chop var timerInterval = null; var isGameOver = false; // --- UI Setup --- scoreTxt = new Text2('0', { size: 120, fill: "#fff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); timerBar = LK.getAsset('timerBar', { width: 800, height: 32, color: 0x00b050, shape: 'box', anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 120 }); LK.gui.top.addChild(timerBar); // --- Tree Setup --- function randomBranch(prevBranch) { // Avoid two branches on the same side in a row var r = Math.random(); if (r < branchChance) { if (prevBranch === 'left') return 'right'; if (prevBranch === 'right') return 'left'; return Math.random() < 0.5 ? 'left' : 'right'; } return 'none'; } function createInitialTree() { var prev = 'none'; for (var i = 0; i < visibleSegments + 2; i++) { var seg = new TreeSegment(); var branch = randomBranch(prev); seg.setup(branch); seg.x = treeX; seg.y = treeBaseY - i * trunkHeight; treeSegments.push(seg); game.addChild(seg); prev = branch; } } function shiftTree() { // Remove bottom segment var bottom = treeSegments.shift(); bottom.destroy(); // Move all segments down for (var i = 0; i < treeSegments.length; i++) { tween(treeSegments[i], { y: treeBaseY - i * trunkHeight }, { duration: 80, easing: tween.cubicOut }); } // Add new segment at the top var prevBranch = treeSegments[treeSegments.length - 1].branch; var newSeg = new TreeSegment(); var branch = randomBranch(prevBranch); newSeg.setup(branch); newSeg.x = treeX; newSeg.y = treeSegments[treeSegments.length - 1].y - trunkHeight; treeSegments.push(newSeg); game.addChild(newSeg); } // --- Player Setup --- player = new Lumberjack(); player.setSide('left'); player.y = treeBaseY + trunkHeight / 2 + 10; game.addChild(player); // --- Game State --- var score = 0; // --- Timer --- function resetTimer() { timeLeft = maxTime; updateTimerBar(); } function updateTimerBar() { var pct = Math.max(0, timeLeft / maxTime); timerBar.width = 800 * pct; if (pct > 0.5) { timerBar.tint = 0x00b050; } else if (pct > 0.2) { timerBar.tint = 0xffc300; } else { timerBar.tint = 0xff0000; } } // --- Game Over --- function triggerGameOver() { if (isGameOver) return; isGameOver = true; LK.effects.flashScreen(0xff0000, 800); LK.getSound('fail').play(); LK.showGameOver(); } // --- Chop Action --- function chop() { if (isGameOver) return; // Check for collision with branch on current side at the bottom segment var bottomSeg = treeSegments[0]; if (bottomSeg.branch === player.side) { triggerGameOver(); return; } // Chop: remove bottom, shift tree, add new at top shiftTree(); // Animate player player.chop(); // Play sound LK.getSound('chop').play(); // Score score += 1; LK.setScore(score); scoreTxt.setText(score); // Reset timer, but make it a bit shorter as score increases maxTime = Math.max(800, 2000 - score * 10); resetTimer(); } // --- Input Handling --- var touchStartX = null; var touchStartY = null; var dragThreshold = 40; // px function handleDown(x, y, obj) { touchStartX = x; touchStartY = y; } function handleUp(x, y, obj) { if (isGameOver) return; if (touchStartX === null || touchStartY === null) return; var dx = x - touchStartX; var dy = y - touchStartY; // Swipe detection if (Math.abs(dx) > dragThreshold && Math.abs(dx) > Math.abs(dy)) { // Horizontal swipe if (dx > 0 && player.side === 'left') { player.setSide('right'); } else if (dx < 0 && player.side === 'right') { player.setSide('left'); } } else if (Math.abs(dx) < dragThreshold && Math.abs(dy) < dragThreshold) { // Tap: chop chop(); } touchStartX = null; touchStartY = null; } game.down = handleDown; game.up = handleUp; // --- Main Update Loop --- game.update = function () { if (isGameOver) return; // Timer timeLeft -= 1000 / 60; updateTimerBar(); if (timeLeft <= 0) { triggerGameOver(); } }; // --- Game Initialization --- function resetGame() { // Remove old tree for (var i = 0; i < treeSegments.length; i++) { treeSegments[i].destroy(); } treeSegments = []; // Reset variables score = 0; LK.setScore(0); scoreTxt.setText('0'); isGameOver = false; maxTime = 2000; resetTimer(); // Recreate tree createInitialTree(); // Reset player player.setSide('left'); player.y = treeBaseY + trunkHeight / 2 + 10; } // --- Start Game --- resetGame();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,301 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+// Lumberjack: The player character
+var Lumberjack = Container.expand(function () {
+ var self = Container.call(this);
+ // Side: 'left' or 'right'
+ self.side = 'left';
+ // Character body
+ var jack = self.attachAsset('lumberjack', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ // Set side ('left' or 'right')
+ self.setSide = function (side) {
+ self.side = side;
+ if (side === 'left') {
+ self.x = treeX - trunkWidth / 2 - jack.width / 2 - 40;
+ self.scaleX = 1;
+ } else {
+ self.x = treeX + trunkWidth / 2 + jack.width / 2 + 40;
+ self.scaleX = -1;
+ }
+ };
+ // Chop animation
+ self.chop = function () {
+ // Animate a quick scale for feedback
+ tween(self, {
+ scaleY: 0.85
+ }, {
+ duration: 60,
+ easing: tween.cubicOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ scaleY: 1
+ }, {
+ duration: 80,
+ easing: tween.cubicIn
+ });
+ }
+ });
+ };
+ return self;
+});
+// TreeSegment: A single segment of the tree, may have a branch (left/right/none)
+var TreeSegment = Container.expand(function () {
+ var self = Container.call(this);
+ // Default: no branch
+ self.branch = 'none'; // 'left', 'right', 'none'
+ // Tree trunk
+ var trunk = self.attachAsset('treeTrunk', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Branch (if any)
+ self.branchNode = null;
+ // Set up the segment (branchSide: 'left', 'right', or 'none')
+ self.setup = function (branchSide) {
+ self.branch = branchSide;
+ if (self.branchNode) {
+ self.removeChild(self.branchNode);
+ self.branchNode = null;
+ }
+ if (branchSide === 'left') {
+ self.branchNode = self.attachAsset('treeBranch', {
+ anchorX: 1,
+ anchorY: 0.5,
+ x: -trunk.width / 2,
+ y: 0
+ });
+ } else if (branchSide === 'right') {
+ self.branchNode = self.attachAsset('treeBranch', {
+ anchorX: 0,
+ anchorY: 0.5,
+ x: trunk.width / 2,
+ y: 0,
+ flipX: 1
+ });
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x6ec6f1 // Light blue sky
+});
+
+/****
+* Game Code
+****/
+// --- Game Variables ---
+// --- Asset Initialization (auto by LK engine) ---
+// Tree trunk segment
+// Branch
+// Lumberjack
+// Chop sound
+// Fail sound
+var treeSegments = []; // Array of TreeSegment
+var treeX = 2048 / 2;
+var treeBaseY = 2732 - 350; // Y position of the bottom segment
+var trunkWidth = 180;
+var trunkHeight = 120;
+var visibleSegments = 10; // Number of segments visible on screen
+var branchChance = 0.35; // Probability of a branch per segment
+var lastBranch = 'none'; // To avoid impossible patterns
+var player = null;
+var scoreTxt = null;
+var timerBar = null;
+var timeLeft = 2000; // ms, time before game over
+var maxTime = 2000; // ms, resets to this on chop
+var timerInterval = null;
+var isGameOver = false;
+// --- UI Setup ---
+scoreTxt = new Text2('0', {
+ size: 120,
+ fill: "#fff"
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+timerBar = LK.getAsset('timerBar', {
+ width: 800,
+ height: 32,
+ color: 0x00b050,
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 2048 / 2,
+ y: 120
+});
+LK.gui.top.addChild(timerBar);
+// --- Tree Setup ---
+function randomBranch(prevBranch) {
+ // Avoid two branches on the same side in a row
+ var r = Math.random();
+ if (r < branchChance) {
+ if (prevBranch === 'left') return 'right';
+ if (prevBranch === 'right') return 'left';
+ return Math.random() < 0.5 ? 'left' : 'right';
+ }
+ return 'none';
+}
+function createInitialTree() {
+ var prev = 'none';
+ for (var i = 0; i < visibleSegments + 2; i++) {
+ var seg = new TreeSegment();
+ var branch = randomBranch(prev);
+ seg.setup(branch);
+ seg.x = treeX;
+ seg.y = treeBaseY - i * trunkHeight;
+ treeSegments.push(seg);
+ game.addChild(seg);
+ prev = branch;
+ }
+}
+function shiftTree() {
+ // Remove bottom segment
+ var bottom = treeSegments.shift();
+ bottom.destroy();
+ // Move all segments down
+ for (var i = 0; i < treeSegments.length; i++) {
+ tween(treeSegments[i], {
+ y: treeBaseY - i * trunkHeight
+ }, {
+ duration: 80,
+ easing: tween.cubicOut
+ });
+ }
+ // Add new segment at the top
+ var prevBranch = treeSegments[treeSegments.length - 1].branch;
+ var newSeg = new TreeSegment();
+ var branch = randomBranch(prevBranch);
+ newSeg.setup(branch);
+ newSeg.x = treeX;
+ newSeg.y = treeSegments[treeSegments.length - 1].y - trunkHeight;
+ treeSegments.push(newSeg);
+ game.addChild(newSeg);
+}
+// --- Player Setup ---
+player = new Lumberjack();
+player.setSide('left');
+player.y = treeBaseY + trunkHeight / 2 + 10;
+game.addChild(player);
+// --- Game State ---
+var score = 0;
+// --- Timer ---
+function resetTimer() {
+ timeLeft = maxTime;
+ updateTimerBar();
+}
+function updateTimerBar() {
+ var pct = Math.max(0, timeLeft / maxTime);
+ timerBar.width = 800 * pct;
+ if (pct > 0.5) {
+ timerBar.tint = 0x00b050;
+ } else if (pct > 0.2) {
+ timerBar.tint = 0xffc300;
+ } else {
+ timerBar.tint = 0xff0000;
+ }
+}
+// --- Game Over ---
+function triggerGameOver() {
+ if (isGameOver) return;
+ isGameOver = true;
+ LK.effects.flashScreen(0xff0000, 800);
+ LK.getSound('fail').play();
+ LK.showGameOver();
+}
+// --- Chop Action ---
+function chop() {
+ if (isGameOver) return;
+ // Check for collision with branch on current side at the bottom segment
+ var bottomSeg = treeSegments[0];
+ if (bottomSeg.branch === player.side) {
+ triggerGameOver();
+ return;
+ }
+ // Chop: remove bottom, shift tree, add new at top
+ shiftTree();
+ // Animate player
+ player.chop();
+ // Play sound
+ LK.getSound('chop').play();
+ // Score
+ score += 1;
+ LK.setScore(score);
+ scoreTxt.setText(score);
+ // Reset timer, but make it a bit shorter as score increases
+ maxTime = Math.max(800, 2000 - score * 10);
+ resetTimer();
+}
+// --- Input Handling ---
+var touchStartX = null;
+var touchStartY = null;
+var dragThreshold = 40; // px
+function handleDown(x, y, obj) {
+ touchStartX = x;
+ touchStartY = y;
+}
+function handleUp(x, y, obj) {
+ if (isGameOver) return;
+ if (touchStartX === null || touchStartY === null) return;
+ var dx = x - touchStartX;
+ var dy = y - touchStartY;
+ // Swipe detection
+ if (Math.abs(dx) > dragThreshold && Math.abs(dx) > Math.abs(dy)) {
+ // Horizontal swipe
+ if (dx > 0 && player.side === 'left') {
+ player.setSide('right');
+ } else if (dx < 0 && player.side === 'right') {
+ player.setSide('left');
+ }
+ } else if (Math.abs(dx) < dragThreshold && Math.abs(dy) < dragThreshold) {
+ // Tap: chop
+ chop();
+ }
+ touchStartX = null;
+ touchStartY = null;
+}
+game.down = handleDown;
+game.up = handleUp;
+// --- Main Update Loop ---
+game.update = function () {
+ if (isGameOver) return;
+ // Timer
+ timeLeft -= 1000 / 60;
+ updateTimerBar();
+ if (timeLeft <= 0) {
+ triggerGameOver();
+ }
+};
+// --- Game Initialization ---
+function resetGame() {
+ // Remove old tree
+ for (var i = 0; i < treeSegments.length; i++) {
+ treeSegments[i].destroy();
+ }
+ treeSegments = [];
+ // Reset variables
+ score = 0;
+ LK.setScore(0);
+ scoreTxt.setText('0');
+ isGameOver = false;
+ maxTime = 2000;
+ resetTimer();
+ // Recreate tree
+ createInitialTree();
+ // Reset player
+ player.setSide('left');
+ player.y = treeBaseY + trunkHeight / 2 + 10;
+}
+// --- Start Game ---
+resetGame();
\ No newline at end of file