User prompt
when special object receives a bullet, it shouldn't be able to receive anymore bullets momentarily
Code edit (1 edits merged)
Please save this source code
User prompt
increase the delay before the bullet affects special object
Code edit (1 edits merged)
Please save this source code
User prompt
Make the pushback of the SpecialObject temporary, after which it continues to go back down.
Code edit (1 edits merged)
Please save this source code
User prompt
make the pushback less effective
User prompt
make the pushback less effective
User prompt
the pushback is just temporary, once it's finished, it continues to go back down again
Code edit (1 edits merged)
Please save this source code
User prompt
the special object should revert to moving down again after it went backwards
Code edit (4 edits merged)
Please save this source code
User prompt
make sure special object can go down again once it went backwards
Code edit (1 edits merged)
Please save this source code
User prompt
reduce the speed at which special object moves backwards if (specialObject) { specialObject.move(); bullets.forEach(function (bullet, bulletIndex) { if (bullet.intersects(specialObject)) { specialObject.hit(); bullet.destroy(); bullets.splice(bulletIndex, 1); remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString()); } });
User prompt
modify the bullet collision logic with the special object to trigger the push back effect
User prompt
add a method to the specialobject class to push it in the opposite direction when hit by a bullet
User prompt
if special object is spawned, start respawning ennemy
User prompt
if (score >= 50) { do nothing
User prompt
enemySpawnRate *= 1.01;
User prompt
if (score >= 50) { enemySpawnRate *= 1.05; enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate);
User prompt
if (score >= 50) { enemySpawnRate *= 0.05 enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate);
User prompt
delete LK.clearInterval(enemySpawnTimer);
User prompt
when enemy leave playspace destroy enemy
User prompt
delete: enemySpawnRate /= 3; enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate);
var SpecialObject = Container.expand(function () {
var self = Container.call(this);
var specialObjectGraphics = self.createAsset('specialObject', 'Special Object', .5, .5);
specialObjectGraphics.scale.x *= 4;
self.speed = 0.7;
self.move = function () {
self.y += self.speed;
};
});
var GraySquare = Container.expand(function () {
var self = Container.call(this);
var graySquareGraphics = self.createAsset('graySquare', 'Gray Square', .5, .5);
graySquareGraphics.width = 150;
graySquareGraphics.height = 150;
graySquareGraphics.tint = 0x808080;
});
var GreenPowerup = Container.expand(function () {
var self = Container.call(this);
var powerupGraphics = self.createAsset('greenPowerup', 'Green Powerup', .5, .5);
self.amplitude = 10;
self.frequency = 0.05;
self.baseY = self.y;
self.move = function () {
self.y = self.baseY + self.amplitude * Math.sin(LK.ticks * self.frequency);
};
});
var BloodSplatter = Container.expand(function () {
var self = Container.call(this);
var scale = (0.5 + Math.random() * 0.5) * 2.5;
var splatterGraphics = self.createAsset('bloodSplatter', 'Blood splatter effect', .5, .5);
splatterGraphics.scale.set(scale, scale);
self.lifeSpan = 500;
self.on('tick', function () {
self.lifeSpan -= 16.6667;
if (self.lifeSpan <= 0) {
LK.setTimeout(function () {
self.destroy();
}, 3000);
}
});
});
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa character', .5, .5);
santaGraphics.rotation = -Math.PI / 2;
self.direction = 1;
self.speed = 15;
self.move = function () {
if (self.x >= 2048 - this.width * 0.6 || self.x <= this.width * 0.6) {
self.direction *= -1;
santaGraphics.scale.y *= -1;
}
self.x += self.speed * self.direction;
};
self.fire = function () {
this.direction *= -1;
santaGraphics.scale.y *= -1;
};
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var scale = 0.5 + Math.random() * 0.5;
var bulletGraphics = self.createAsset('bullet', 'Bullet Graphics', .5, .5);
bulletGraphics.scale.set(scale, scale);
self.speed = 20;
self.move = function () {
self.y -= self.speed;
};
});
var YellowEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('yellowEnemy', 'Yellow Enemy character', .5, .5);
self.speed = 3.75;
self.scaleIncrement = 0.2;
self.scaleTimer = 0;
self.move = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
self.scaleTimer += 1 / 60;
if (self.scaleTimer >= 1) {
self.scale.x += self.scaleIncrement;
self.scale.y += self.scaleIncrement;
self.scaleTimer = 0;
}
};
});
var BlueEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('blueEnemy', 'Blue Enemy character', .5, .5);
self.speed = 6.25;
self.teleportTimer = 0;
self.teleportInterval = 1;
self.move = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
self.teleportTimer += 1 / 60;
if (self.teleportTimer >= self.teleportInterval) {
var teleportDirection = Math.random() < 0.5 ? -200 : 200;
self.x += Math.max(0, Math.min(2048 - self.width, self.x + teleportDirection)) - self.x;
self.teleportTimer = 0;
}
};
});
var RedEnemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('redEnemy', 'Red Enemy character', .5, .5);
self.speed = 10;
self.move = function () {
self.y += self.speed;
if (self.y > 2732) {
self.destroy();
}
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Game background', 0, 0);
background.width = 2048;
background.height = 2732;
self.addChildAt(background, 0);
var santa = self.addChild(new Santa());
var greenPowerup;
var greenPowerupSpawnTimer;
var score = 0;
var specialObject;
var specialObjectSpawned = false;
var scoreTxt = new Text2(score.toString(), {
size: 100,
fill: "#FFA500"
});
scoreTxt.y += 94;
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var remainingBulletsTxt = new Text2('Bullets: 5', {
size: 70,
fill: "#FFA500"
});
remainingBulletsTxt.y = scoreTxt.height + 114;
remainingBulletsTxt.anchor.set(0.5, 0);
LK.gui.topCenter.addChild(remainingBulletsTxt);
var bullets = [];
var enemies = [];
santa.x = 2048 / 2;
santa.y = 2732 - santa.height;
var spawnEnemy = function () {
var enemyType = Math.random();
var enemy;
if (enemyType < 0.33) {
enemy = new YellowEnemy();
} else if (enemyType < 0.66) {
enemy = new BlueEnemy();
} else {
enemy = new RedEnemy();
}
var boundaryPadding = enemy.width;
enemy.x = Math.random() * (2048 - boundaryPadding * 2) + boundaryPadding;
enemy.y = 0;
enemies.push(enemy);
if (specialObject && specialObject.parent === self) {
self.addChildAt(enemy, self.getChildIndex(specialObject));
} else {
if (specialObject && specialObject.parent === self) {
self.addChildAt(enemy, self.getChildIndex(specialObject) - 1);
} else {
self.addChild(enemy);
}
}
};
var fireBullet = function () {
if (bullets.length < 5) {
santa.fire();
var bullet = new Bullet();
bullet.x = santa.x;
bullet.y = santa.y - santa.height / 2 - bullet.height / 2;
var graySquare = new GraySquare();
graySquare.x = bullet.x;
graySquare.y = bullet.y + 50;
self.addChild(graySquare);
LK.setTimeout(function () {
graySquare.destroy();
}, 500);
bullets.push(bullet);
self.addChild(bullet);
bullet.move();
remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString());
}
};
stage.on('down', function (obj) {
if (santa.x > santa.width * 0.6 && santa.x < 2048 - santa.width * 0.6) {
fireBullet();
}
});
LK.on('tick', function () {
santa.move();
bullets.forEach(function (bullet, bulletIndex) {
bullet.move();
if (bullet.y < -bullet.height) {
bullet.destroy();
bullets.splice(bulletIndex, 1);
remainingBulletsTxt.setText('Bullets: ' + (5 - bullets.length).toString());
return;
}
enemies.forEach(function (enemy, enemyIndex) {
if (bullet.intersects(enemy)) {
bullet.destroy();
var splatter = new BloodSplatter();
splatter.x = enemy.x;
splatter.y = enemy.y;
self.addChild(splatter);
enemy.destroy();
enemies.forEach(function (e) {
e.speed *= 1.1;
});
score += 1;
if (score >= 50) {
enemySpawnRate *= 0.95;
LK.clearInterval(enemySpawnTimer);
enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate);
}
if (score >= 99 && !specialObjectSpawned) {
specialObject = new SpecialObject();
specialObject.x = 2048 / 2;
specialObject.y = -1300;
self.addChild(specialObject);
specialObjectSpawned = true;
LK.clearInterval(enemySpawnTimer);
var deathText = new Text2('Death Is Inevitable', {
size: 150,
fill: '#000000',
align: 'center'
});
deathText.anchor.set(0.5, 0.5);
deathText.x = 2048 / 4 + 225;
deathText.y = 2732 / 2 - deathText.height / 2 - 300;
LK.gui.addChild(deathText);
var toggleTransparency = function () {
deathText.alpha = deathText.alpha === 1 ? 0 : 1;
};
var transparencyInterval = LK.setInterval(toggleTransparency, 500);
LK.setTimeout(function () {
LK.clearInterval(transparencyInterval);
deathText.destroy();
}, 5000);
}
scoreTxt.setText(score.toString());
santa.speed += 1;
bullets.splice(bulletIndex, 1);
enemies.splice(enemyIndex, 1);
remainingBulletsTxt.setText('Bullets: ' + (4 - bullets.length).toString());
} else if (greenPowerup && bullet.intersects(greenPowerup)) {
bullets.splice(bulletIndex, 1);
bullet.destroy();
enemies.forEach(function (e) {
var splatter = new BloodSplatter();
splatter.x = e.x;
splatter.y = e.y;
self.addChild(splatter);
e.destroy();
score += 1;
});
enemies.length = 0;
greenPowerup.destroy();
LK.effects.flashScreen(0x808080, 1000);
santa.speed = 15;
greenPowerup = undefined;
scoreTxt.setText(score.toString());
remainingBulletsTxt.setText('Bullets: ' + (4 - bullets.length).toString());
}
});
});
if (specialObject) {
specialObject.move();
if (santa.intersects(specialObject)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
isGameOver = true;
}
}
enemies.forEach(function (enemy) {
enemy.move();
if (santa.intersects(enemy)) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
isGameOver = true;
}
});
});
var enemySpawnRate = 1000 / 1.75;
var enemySpawnTimer = LK.setInterval(spawnEnemy, enemySpawnRate);
LK.on('tick', function () {});
greenPowerupSpawnTimer = LK.setInterval(function () {
if (greenPowerup && !greenPowerup.isDestroyed) {
return;
}
greenPowerup = new GreenPowerup();
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var randomOffsetX = (Math.random() - 0.5) * 1200;
var randomOffsetY = (Math.random() - 0.5) * 1200;
greenPowerup.x = centerX + randomOffsetX - greenPowerup.width / 2;
greenPowerup.y = centerY + randomOffsetY - greenPowerup.height / 2;
greenPowerup.move = function () {
this.angle += 0.05;
this.x = this.center.x + this.radius * Math.cos(this.angle);
this.y = this.center.y + this.radius * Math.sin(this.angle);
};
self.addChild(greenPowerup);
}, 15000);
});
a top view of a 16 bit sprite santa with a bazooka Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a christmas ornament Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eyed christmas elf Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a blood splatter Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eye reindeer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit sprite of a red eye mother christmas Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit top view background of a christmas field set in hell Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit smoke Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit wall of skulls with red eyes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
"Death Is Inevitable" Text Bubble Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
16 bit CHRISTMAS bomb power up icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.