User prompt
bullets kill enemies
Code edit (1 edits merged)
Please save this source code
User prompt
powerup2 gives the player a gun for 10 shots, when pushing the button the player fires a bullet instead of jumping.
User prompt
at the top of the screen an an indicator for each power up that shows how much time remains on them
User prompt
move the power up bar to the top of the screen
User prompt
add a bar at the bottom of the screen to show how much time is left on the power ups
Code edit (1 edits merged)
Please save this source code
User prompt
powerUp3 should make the player immune to death for 3 seconds
User prompt
if the one of the enemies and the player collide on the ground, the player dies, if the player collides with the enemy when he is coming down from a jump the enemy dies
User prompt
the player is still dying when landin on the enemies
User prompt
if the player lands on top of an enemy kill the enemy instead of the player
User prompt
the player should jump slightly higher and remain in the air slightly longer
User prompt
it is too difficult for the player to jump over the enemies
User prompt
the power ups and treasure are too high for the player to reach
User prompt
the player jumps too high and does not come back down to the ground
User prompt
move the potholes up to the grassline and make them brown, so they look like holes in the grass
User prompt
player and enemies should be above the grass line so it looks like they are walking on the grass
User prompt
the ground should be indicated as a green 'grass' line
User prompt
draw the ground about 1/3 from the bottom of the screen
User prompt
slow down the scroll
User prompt
potholes are holes in the ground that the player must jump over
User prompt
player and enemies should be on the ground
User prompt
allow for different types of enemies, treasure and power ups
User prompt
the game is too high on the screen move it down
Initial prompt
runnr runnr
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyType = Math.floor(Math.random() * 3); if (enemyType == 0) { var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -5; } else if (enemyType == 1) { var enemyGraphics = self.attachAsset('enemy2', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -7; } else { var enemyGraphics = self.attachAsset('enemy3', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; } self.update = function () { self.x += self.speed; if (self.x < -50) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.jumpPower = -15; self.isJumping = false; self.update = function () { if (self.isJumping) { self.y += self.jumpPower; self.jumpPower += 1; // Gravity effect if (self.y >= 200) { // Ground level self.y = 200; self.isJumping = false; self.jumpPower = -15; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; } }; }); // Pothole class var Pothole = Container.expand(function () { var self = Container.call(this); var potholeGraphics = self.attachAsset('pothole', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x -= 3; if (self.x < -50) { self.destroy(); } }; }); // PowerUp class var PowerUp = Container.expand(function () { var self = Container.call(this); var powerUpType = Math.floor(Math.random() * 3); if (powerUpType == 0) { var powerUpGraphics = self.attachAsset('powerUp', { anchorX: 0.5, anchorY: 0.5 }); self.value = 50; } else if (powerUpType == 1) { var powerUpGraphics = self.attachAsset('powerUp2', { anchorX: 0.5, anchorY: 0.5 }); self.value = 100; } else { var powerUpGraphics = self.attachAsset('powerUp3', { anchorX: 0.5, anchorY: 0.5 }); self.value = 150; } self.update = function () { self.x -= 5; if (self.x < -50) { self.destroy(); } }; }); // Treasure class var Treasure = Container.expand(function () { var self = Container.call(this); var treasureType = Math.floor(Math.random() * 3); if (treasureType == 0) { var treasureGraphics = self.attachAsset('treasure', { anchorX: 0.5, anchorY: 0.5 }); self.value = 10; } else if (treasureType == 1) { var treasureGraphics = self.attachAsset('treasure2', { anchorX: 0.5, anchorY: 0.5 }); self.value = 20; } else { var treasureGraphics = self.attachAsset('treasure3', { anchorX: 0.5, anchorY: 0.5 }); self.value = 30; } self.update = function () { self.x -= 5; if (self.x < -50) { self.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var hero = game.addChild(new Hero()); hero.x = 200; hero.y = 2732 - hero.height; var enemies = []; var potholes = []; var treasures = []; var powerUps = []; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); var score = 0; function spawnEnemy() { var enemy = new Enemy(); enemy.x = 2048; enemy.y = 2732 - enemy.height; enemies.push(enemy); game.addChild(enemy); } function spawnPothole() { var pothole = new Pothole(); pothole.x = 2048; pothole.y = 250; potholes.push(pothole); game.addChild(pothole); } function spawnTreasure() { var treasure = new Treasure(); treasure.x = 2048; treasure.y = 150; treasures.push(treasure); game.addChild(treasure); } function spawnPowerUp() { var powerUp = new PowerUp(); powerUp.x = 2048; powerUp.y = 100; powerUps.push(powerUp); game.addChild(powerUp); } game.down = function (x, y, obj) { hero.jump(); }; game.update = function () { hero.update(); for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].update(); if (hero.intersects(enemies[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof Pothole) { game.children[i].update(); if (hero.intersects(game.children[i])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } for (var i = treasures.length - 1; i >= 0; i--) { treasures[i].update(); if (hero.intersects(treasures[i])) { score += 10; scoreTxt.setText(score); treasures[i].destroy(); treasures.splice(i, 1); } } for (var i = powerUps.length - 1; i >= 0; i--) { powerUps[i].update(); if (hero.intersects(powerUps[i])) { score += 50; scoreTxt.setText(score); powerUps[i].destroy(); powerUps.splice(i, 1); } } if (LK.ticks % 60 == 0) { spawnEnemy(); } if (LK.ticks % 120 == 0) { var pothole = new Pothole(); pothole.x = 2048; pothole.y = 2732 - pothole.height; game.addChild(pothole); } if (LK.ticks % 180 == 0) { spawnTreasure(); } if (LK.ticks % 240 == 0) { spawnPowerUp(); } };
===================================================================
--- original.js
+++ change.js
@@ -67,9 +67,9 @@
anchorX: 0.5,
anchorY: 0.5
});
self.update = function () {
- self.x -= 5;
+ self.x -= 3;
if (self.x < -50) {
self.destroy();
}
};
toy gun. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon bullet, sideways, flying right, with empty background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
suit of armour, no background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gold coin. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon bomb, no shadow, no background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gold bar. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
treasure chest. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cloud in bright blue sky.
bright blue sky over a grassy meadow.
dark green tree, plain background. Single Game Texture. In-Game asset. 2d. Blank background. No shadows.
a tall thin bunch of grass. Single Game Texture. In-Game asset. 2d. Blank background. No shadows.