Code edit (1 edits merged)
Please save this source code
User prompt
in the character update method, call the update method of the right and left arms, using the runAlpha as the alpha value
User prompt
Add a runAlpha variable to the Character class and increase its value by 0.02 in the update method, additionally, reduce the value by 1 if the value is >= 1
User prompt
Add a runAlpha variable to the Character class and increase its value in the update method
User prompt
Add an alpha = 0 variable to the character and increase its value by 0.02 in the update method reducing the value by 1 if it's value >= 1
User prompt
add an arm swinging animation to the CharacterArm's update function, these should be constructed from sinusoidal equations based on the alpha
User prompt
The CharacterArm and CharacterLeg classes should have empty update methods that takes in an alpha value
User prompt
Create an CharacterArm class and a CharacterLeg class, these should contain the respective upper and lower component images instead of the Character class
User prompt
add a basic running animation to the character in the update method
User prompt
the character should have 2 legs and 2 arms
User prompt
add an ontick even to the game which should call the created character's update method
User prompt
add an empty update function to the character class
User prompt
display a character in the middle of the screen
User prompt
Create a Character class that's a side-view of a person. It should be composed of different individual body parts: upper and lower arms, upper and lower legs, and the body (which will include the head).
User prompt
Remove all the code in the game
Initial prompt
Road Runners
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 3; self.update = function () { self.y += self.speed; // Check if enemy goes off screen if (self.y > 2732) { self.y = -100; // Reset enemy position } }; }); // Assets will be automatically created and loaded by the LK engine based on usage in the game code. // Player class var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Player update logic, if needed }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize player var player = game.addChild(new Player()); player.x = 1024; // Center horizontally player.y = 2400; // Position towards the bottom of the screen // Initialize enemies var enemies = []; for (var i = 0; i < 5; i++) { var enemy = new Enemy(); enemy.x = Math.random() * 2048; // Random horizontal position enemy.y = Math.random() * -2732; // Random vertical position above the screen game.addChild(enemy); enemies.push(enemy); } // Handle touch movement var dragNode = null; game.down = function (x, y, obj) { dragNode = player; }; game.move = function (x, y, obj) { if (dragNode) { dragNode.x = x; dragNode.y = y; } }; game.up = function (x, y, obj) { dragNode = null; }; // Game update function game.update = function () { // Check for collisions between player and enemies for (var i = 0; i < enemies.length; i++) { if (player.intersects(enemies[i])) { // Flash screen red for 1 second (1000ms) to indicate collision LK.effects.flashScreen(0xff0000, 1000); // Show game over LK.showGameOver(); break; // Exit the loop to avoid multiple game over calls } } };
/****
* Classes
****/
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 3;
self.update = function () {
self.y += self.speed;
// Check if enemy goes off screen
if (self.y > 2732) {
self.y = -100; // Reset enemy position
}
};
});
// Assets will be automatically created and loaded by the LK engine based on usage in the game code.
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
// Player update logic, if needed
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize player
var player = game.addChild(new Player());
player.x = 1024; // Center horizontally
player.y = 2400; // Position towards the bottom of the screen
// Initialize enemies
var enemies = [];
for (var i = 0; i < 5; i++) {
var enemy = new Enemy();
enemy.x = Math.random() * 2048; // Random horizontal position
enemy.y = Math.random() * -2732; // Random vertical position above the screen
game.addChild(enemy);
enemies.push(enemy);
}
// Handle touch movement
var dragNode = null;
game.down = function (x, y, obj) {
dragNode = player;
};
game.move = function (x, y, obj) {
if (dragNode) {
dragNode.x = x;
dragNode.y = y;
}
};
game.up = function (x, y, obj) {
dragNode = null;
};
// Game update function
game.update = function () {
// Check for collisions between player and enemies
for (var i = 0; i < enemies.length; i++) {
if (player.intersects(enemies[i])) {
// Flash screen red for 1 second (1000ms) to indicate collision
LK.effects.flashScreen(0xff0000, 1000);
// Show game over
LK.showGameOver();
break; // Exit the loop to avoid multiple game over calls
}
}
};
white
white
circle sliced into many pieces, flat image. 2d, white background, shadowless.
pixel art of a tall, tree. game asset, 2d, white background, shadowless.
Pixel art street lamp. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art cloud. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art sun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.