User prompt
Start the hobbit mirroring animation only after countdown ends
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'hobbit.y = track.y;' Line Number: 99
User prompt
Place the hobbit initially on the track When the game starts
User prompt
Create a simple animation for the hobbit running by alternating between the hobbit asset and a mirrored version of that asset every half a second
User prompt
Have game start when player hits start button then the countdown begins after that
User prompt
Game starts with a countdown from 3 to 1.
User prompt
Top down view, player controls hobbit by moving hobbit left and right. Tap screen to jump
Initial prompt
Hobbit Run
/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Define the Hobbit class var Hobbit = Container.expand(function () { var self = Container.call(this); self.animationState = 0; self.hobbitGraphics = self.attachAsset('hobbit', { anchorX: 0.5, anchorY: 0.5 }); self.switchAsset = function () { if (self.animationState == 0) { self.hobbitGraphics = self.attachAsset('hobbitMirrored', { anchorX: 0.5, anchorY: 0.5 }); self.animationState = 1; } else { self.hobbitGraphics = self.attachAsset('hobbit', { anchorX: 0.5, anchorY: 0.5 }); self.animationState = 0; } }; self.speed = 5; self.update = function () { // Update logic for the hobbit if (this.jumping) { this.jumpSpeed -= this.gravity; this.y -= this.jumpSpeed; if (this.y > this.ground) { this.y = this.ground; this.jumping = false; } } if (countdown == 0 && LK.ticks % 30 == 0) { this.switchAsset(); } }; self.jump = function () { if (!this.jumping) { this.jumping = true; this.jumpSpeed = this.jumpPower; } }; }); // Define the StartButton class var StartButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.attachAsset('button', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Update logic for the start button }; }); // Define the Track class var Track = Container.expand(function () { var self = Container.call(this); var trackGraphics = self.attachAsset('track', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Update logic for the track }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize the start button var startButton = LK.gui.center.addChild(new StartButton()); startButton.x = 2048 / 2; startButton.y = 2732 / 2; // Initialize game variables var track = game.addChild(new Track()); track.x = 2048 / 2; track.y = 2732 / 2; var hobbit = game.addChild(new Hobbit()); hobbit.x = 2048 / 2; hobbit.y = track.y; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var countdownTxt = new Text2('3', { size: 150, fill: "#ffffff" }); countdownTxt.anchor.set(0.5, 0); LK.gui.center.addChild(countdownTxt); var score = 0; var countdown = 3; var dragNode = null; // Handle move events function handleMove(x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; } } // Mouse or touch move on game object game.move = handleMove; // Allow dragging of the hobbit to start from anywhere game.down = function (x, y, obj) { if (obj.target == startButton) { startButton.destroy(); countdownTxt.setText(countdown); } else if (countdown == 0) { dragNode = hobbit; handleMove(x, y, obj); hobbit.jump(); } }; // Mouse or touch up on game object game.up = function (x, y, obj) { dragNode = null; }; // Update game logic game.update = function () { if (startButton.destroyed && hobbit.countdown > 0) { if (LK.ticks % 60 == 0) { // every second hobbit.countdown -= 1; countdownTxt.setText(hobbit.countdown); if (hobbit.countdown == 0) { countdownTxt.destroy(); } } } else if (hobbit.countdown == 0) { // Update score score += 1; scoreTxt.setText(score); } // Check if hobbit is off track if (!hobbit.intersects(track)) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }; self.countdown = 3;
===================================================================
--- original.js
+++ change.js
@@ -35,9 +35,9 @@
this.y = this.ground;
this.jumping = false;
}
}
- if (LK.ticks % 30 == 0) {
+ if (countdown == 0 && LK.ticks % 30 == 0) {
this.switchAsset();
}
};
self.jump = function () {
@@ -131,18 +131,18 @@
dragNode = null;
};
// Update game logic
game.update = function () {
- if (startButton.destroyed && countdown > 0) {
+ if (startButton.destroyed && hobbit.countdown > 0) {
if (LK.ticks % 60 == 0) {
// every second
- countdown -= 1;
- countdownTxt.setText(countdown);
- if (countdown == 0) {
+ hobbit.countdown -= 1;
+ countdownTxt.setText(hobbit.countdown);
+ if (hobbit.countdown == 0) {
countdownTxt.destroy();
}
}
- } else if (countdown == 0) {
+ } else if (hobbit.countdown == 0) {
// Update score
score += 1;
scoreTxt.setText(score);
}
@@ -150,5 +150,6 @@
if (!hobbit.intersects(track)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
-};
\ No newline at end of file
+};
+self.countdown = 3;
\ No newline at end of file
A retro pixel art start button. Forest theme, 16 bit, hobbit themed game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A 16 bit pixel art horizon line of a pastural hobbit village. A beautiful verdant village in the distance with rolling hills and blue skies. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pixel art gradient from black to grassy green. Mostly green rectangle.
A 16 bit potato. Delicious, hearty potato 🥔 no border, no UI. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pixel art sprite of a hobbit. Top down view from behind so the player only sees the hobbits top of head. Full body Top down aerial view, from behind, he is running, Nintendo art style 16 bit, retro. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art boulder with dirt and blades of grass around the bottom. No ground or background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.