User prompt
store crucifixPickups in its own array and use instead
User prompt
Fix Bug: 'TypeError: self.hasChildOfType is not a function' in this line: 'if (Math.random() < 0.01 && !self.hasChildOfType(CrucifixPickup)) {' Line Number: 174
User prompt
create a new crucifix pickup with a 1% drop chance when an enemy is destroyed, only one is allowed to drop at a time
User prompt
Only spawn a new health pickup if the healthPickups length is < 5
User prompt
health pickups should be stored in their own array, iterate through that when checking collision with the player
User prompt
change bullet travelDistance from 800 to 1000
User prompt
Reduce bullet spawn from % 20 to % 60
User prompt
instead of j-- use break in the enemy bullet for loop
User prompt
bullets are not destroyed when colliding with an enemy
User prompt
destroy bullets that collide with the player if their speed is < 0
User prompt
on mouse down set the hero targetPos to the mouse position
User prompt
Move hero scaling logic into mouse move event
User prompt
invert the hero x scale if the shootPos is to the left of the hero position
User prompt
change the score colour to white
User prompt
change the font size to 120 and make the font bold
User prompt
move the score to the left with a margin of 50, make the colour black and font size 100, and change the font to monospace
User prompt
✅ Change the score font to courier and make it bold
User prompt
change the score font to courier new and make it bold
User prompt
change the score colour to black and give it a left margin of 50
User prompt
reduce the size of the score text and move it to the left
User prompt
reduce the size of the score text to 100
User prompt
destroy the play button when it is pressed
User prompt
remove the popup, but keep the play button
User prompt
remove the popup
User prompt
Add the text: "Welcome" to the top of the popup image
var BloodSplatter = Container.expand(function () { var self = Container.call(this); var splatterGraphics = self.createAsset('bloodSplatter', 'Blood Splatter', .5, .5); self.lifetime = 0.2; LK.setTimeout(function () { self.destroy(); }, self.lifetime * 1000); }); var HealingPickup = Container.expand(function () { var self = Container.call(this); var pickupGraphics = self.createAsset('healingPickup', 'Healing Pickup', .5, .5); }); var Bullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5); self.speed = 30; self.travelDistance = 800; self.move = function () { self.x += self.speed * Math.cos(self.angle); self.y += self.speed * Math.sin(self.angle); self.rotation += 0.2; if (self.travelDistance > 0) { self.travelDistance -= self.speed; } else if (self.speed > -30) { self.speed -= 0.75; } }; }); var Enemy = Container.expand(function (hero) { var self = Container.call(this); var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5); self.creationTick = LK.ticks; self.move = function () { var dx = hero.x - self.x; var dy = hero.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 50) { self.x += dx / distance * 1.8; self.y += dy / distance * 1.8 + Math.sin((LK.ticks - self.creationTick) / 10) * 2; } }; }); var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5); self.health = 100; self.healthBarBorder = self.createAsset('healthBarBorder', 'Health Bar Border', 0.5, 1); self.healthBarBorder.y = -115; self.healthBar = self.createAsset('healthBar', 'Health Bar', 0.5, 1); self.healthBar.y = -120; self.healthBarBorder.x = self.healthBar.x; self.healthBarBorder.width = self.healthBar.width + 10; self.healthBarBorder.height = self.healthBar.height + 10; self.move = function () { self.healthBar.scale.x = self.health / 100; if (self.targetPos) { var dx = self.targetPos.x - self.x; var dy = self.targetPos.y - self.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance > 5) { self.x += dx / distance * 10; self.y += dy / distance * 10; } else { self.x = self.targetPos.x; self.y = self.targetPos.y; self.targetPos = null; } } }; }); var Game = Container.expand(function () { var self = Container.call(this); var isPaused = true; var grass = self.createAsset('grass', 'Grass Background', 0, 0); grass.width = 2048; grass.height = 2732; self.addChild(grass); var hero = new Hero(); var canMove = false; var score = 0; var scoreTxt = new Text2('Score: ' + score, { size: 150, fill: '#ffffff' }); LK.gui.topCenter.addChild(scoreTxt); var heroBullets = []; var enemyBullets = []; var enemies = []; hero.x = 2048 / 2; hero.y = 2732 / 2; self.targetPos = null; stage.on('down', function (obj) { canMove = true; }); stage.on('up', function (obj) { canMove = false; hero.targetPos = null; }); var shootPos = null; stage.on('move', function (obj) { if (canMove) { hero.targetPos = obj.event.getLocalPosition(self); } shootPos = obj.event.getLocalPosition(self); }); self.addChild(hero); var spawnEnemy = function () { var side = Math.floor(Math.random() * 4); var enemy = new Enemy(hero); switch (side) { case 0: enemy.x = Math.random() * 2048; enemy.y = 0; break; case 1: enemy.x = 2048; enemy.y = Math.random() * 2732; break; case 2: enemy.x = Math.random() * 2048; enemy.y = 2732; break; case 3: enemy.x = 0; enemy.y = Math.random() * 2732; break; } enemies.push(enemy); self.addChild(enemy); }; LK.on('tick', function () { if (!isPaused) { hero.move(); for (var i = 0; i < heroBullets.length; i++) { heroBullets[i].move(); if (heroBullets[i].x < 0 || heroBullets[i].x > 2048 || heroBullets[i].y < 0 || heroBullets[i].y > 2732) { heroBullets[i].destroy(); heroBullets.splice(i, 1); i--; } } for (var i = 0; i < enemyBullets.length; i++) { enemyBullets[i].move(); } for (var i = 0; i < enemies.length; i++) { enemies[i].move(); for (var j = 0; j < heroBullets.length; j++) { if (heroBullets[j].intersects(enemies[i])) { if (Math.random() < 0.1) { var pickup = new HealingPickup(); pickup.x = enemies[i].x; pickup.y = enemies[i].y; self.addChild(pickup); } heroBullets[j].destroy(); heroBullets.splice(j, 1); var bloodSplatter = new BloodSplatter(); bloodSplatter.x = enemies[i].x; bloodSplatter.y = enemies[i].y; self.addChild(bloodSplatter); enemies[i].destroy(); enemies.splice(i, 1); score++; scoreTxt.setText('Score: ' + score); i--; j--; } } if (hero.intersects(enemies[i])) { hero.health -= 1; if (hero.health <= 0) { LK.showGameOver(); } } } for (var i = 0; i < self.children.length; i++) { if (self.children[i] instanceof HealingPickup && hero.intersects(self.children[i])) { hero.health = Math.min(100, hero.health + 10); self.children[i].destroy(); } } if (LK.ticks % Math.max(10, 30 - Math.floor(score / 10)) === 0) { spawnEnemy(); } if (LK.ticks % 20 === 0 && shootPos) { var bullet = new Bullet(); bullet.x = hero.x; bullet.y = hero.y; var dx = shootPos.x - hero.x; var dy = shootPos.y - hero.y; bullet.angle = Math.atan2(dy, dx); heroBullets.push(bullet); self.addChild(bullet); } } }); });
===================================================================
--- original.js
+++ change.js
@@ -71,21 +71,8 @@
var Game = Container.expand(function () {
var self = Container.call(this);
var isPaused = true;
var grass = self.createAsset('grass', 'Grass Background', 0, 0);
- var popup = LK.getAsset('popup', 'Game Instructions Popup', 0.5, 0.5);
- LK.gui.center.addChild(popup);
- var welcomeText = new Text2('Welcome', {
- size: 150,
- fill: '#ffffff'
- });
- popup.addChild(welcomeText);
- welcomeText.y = -popup.height / 2 + welcomeText.height;
- var playButton = popup.addChild(LK.getAsset('playButton', 'Play Button', 0.5, 0.5));
- playButton.on('down', function () {
- isPaused = false;
- popup.destroy();
- });
grass.width = 2048;
grass.height = 2732;
self.addChild(grass);
var hero = new Hero();
pixel art cross with blue accents Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a white orb with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a pulsating white heart with a halo. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a dark goo projectile with red highlights. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art tall blue fireball. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an evil fantasy sword facing downward. Minor red details. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
backgroundAmbient
Sound effect
heroHealed
Sound effect
pickupExperience
Sound effect
heroLeveled
Sound effect
weaponCrossImpact
Sound effect
heroImpact
Sound effect
enemyDeath
Sound effect
pickupWeapon
Sound effect
pickupCrucifix
Sound effect
weaponCrossLaunch
Sound effect
heroDeath
Sound effect
enemyRoar
Sound effect
clockChime
Sound effect