User prompt
Fix Bug: 'ReferenceError: speedMultiplier is not defined' in this line: 'particleSplash.speedMultiplier = speedMultiplier;' Line Number: 113
User prompt
Fix Bug: 'ReferenceError: speedMultiplier is not defined' in this line: 'particleSplash.speedMultiplier = speedMultiplier;' Line Number: 112
User prompt
speed of particlesplash should depend on throw speed
User prompt
spawn an array of 10 particlespashes instead of 1
User prompt
Increse the number of particles for faster throws
User prompt
move the particles in random directions from the center
User prompt
show a particle splash effect when a snowball hits its target
User prompt
revert last change
User prompt
when a snowball hit a kid the kid should explode into particles
User prompt
place the progressbar to the right bottom
User prompt
add a progressbar to visualise touchtime
User prompt
allow a maximum of 5 snowballs at a time
Code edit (1 edits merged)
Please save this source code
User prompt
add a variable to control throw speed with a start value of one. The variable should be multipled with speedMultiplier
User prompt
increase throw speed by 5
User prompt
showballs should be thrown faster if time between down event and up event i longer
User prompt
snowballs should be triggered on up event
User prompt
The game is over when a zombie kid reaches the bottom of the screen
User prompt
When a zombiekid is hit, score is increased by one
User prompt
Add a score counter in the top
User prompt
When a snowball hits a zombie kid the user should be a point
User prompt
Throw direction left/right should be reversed
User prompt
The snowballs throw direction should be up, no down
User prompt
When the user taps the screen, throw a snowball that way
User prompt
Make the enemies (zombie kids) approach from the top and move towards santa
var ParticleSplash = Container.expand(function () {
var self = Container.call(this);
var particleSplashGraphics = self.createAsset('particleSplash', 'Particle Splash Graphics', .5, .5);
self.directionX = Math.random() * 2 - 1;
self.directionY = Math.random() * 2 - 1;
self.speedMultiplier = 1;
self.animate = function () {
self.alpha -= 0.01;
self.x += self.directionX * self.speedMultiplier;
self.y += self.directionY * self.speedMultiplier;
if (self.alpha <= 0) {
self.destroy();
}
};
});
var ProgressBar = Container.expand(function () {
var self = Container.call(this);
var progressBarGraphics = self.createAsset('progressBar', 'Progress Bar Graphics', 0, .5);
self.updateProgress = function (progress) {
progressBarGraphics.scale.x = progress;
};
});
var Snowball = Container.expand(function () {
var self = Container.call(this);
var snowballGraphics = self.createAsset('snowball', 'Snowball Graphics', .5, .5);
self.speed = -5;
self.targetX = 0;
self.targetY = 0;
self.speedX = 0;
self.speedY = 0;
self.move = function () {
self.x += self.speedX;
self.y += self.speedY;
};
});
var ZombieKid = Container.expand(function () {
var self = Container.call(this);
var zombieKidGraphics = self.createAsset('zombieKid', 'Zombie Kid Graphics', .5, .5);
self.speed = 1;
self.move = function () {
self.y += self.speed;
};
});
var Santa = Container.expand(function () {
var self = Container.call(this);
var santaGraphics = self.createAsset('santa', 'Santa Graphics', .5, .5);
});
var Game = Container.expand(function () {
var self = Container.call(this);
LK.stageContainer.setBackgroundColor(0x008080);
var santa = self.addChild(new Santa());
santa.x = 2048 / 2;
santa.y = 2732 - santa.height;
var progressBar = self.addChild(new ProgressBar());
progressBar.x = 2048 - progressBar.width;
progressBar.y = 2732 - progressBar.height;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff"
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
self.updateScoreDisplay = function () {
scoreTxt.setText(LK.getScore().toString());
};
self.updateScoreDisplay();
var snowballs = [];
var zombieKids = [];
var touchStartTime = 0;
stage.on('down', function (obj) {
touchStartTime = LK.ticks;
progressBar.updateProgress(0);
});
stage.on('up', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(self);
progressBar.updateProgress(0);
if (snowballs.length < 5) {
var newSnowball = new Snowball();
newSnowball.x = santa.x;
newSnowball.y = santa.y;
newSnowball.targetX = pos.x;
newSnowball.targetY = pos.y;
var dx = newSnowball.targetX - newSnowball.x;
var dy = newSnowball.targetY - newSnowball.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var throwSpeed = 5;
var touchDuration = LK.ticks - touchStartTime;
var speedMultiplier = Math.min(touchDuration / 30, 10) * throwSpeed;
newSnowball.speedX = -dx / distance * newSnowball.speed * speedMultiplier;
newSnowball.speedY = -Math.abs(dy / distance * newSnowball.speed) * speedMultiplier;
newSnowball.speedMultiplier = speedMultiplier;
snowballs.push(newSnowball);
self.addChild(newSnowball);
var particleSplashSpeedMultiplier = speedMultiplier;
}
});
LK.on('tick', function () {
if (touchStartTime > 0) {
var progress = Math.min((LK.ticks - touchStartTime) / 30, 1);
progressBar.updateProgress(progress);
}
for (var a = snowballs.length - 1; a >= 0; a--) {
if (snowballs[a]) {
snowballs[a].move();
for (var b = zombieKids.length - 1; b >= 0; b--) {
if (zombieKids[b] && snowballs[a].intersects(zombieKids[b])) {
LK.setScore(LK.getScore() + 1);
self.updateScoreDisplay();
for (var i = 0; i < 10; i++) {
var particleSplash = new ParticleSplash();
particleSplash.x = snowballs[a].x;
particleSplash.y = snowballs[a].y;
particleSplash.speedMultiplier = particleSplashSpeedMultiplier;
self.addChild(particleSplash);
}
zombieKids[b].destroy();
zombieKids.splice(b, 1);
snowballs[a].destroy();
snowballs.splice(a, 1);
break;
}
}
if (snowballs[a] && snowballs[a].y < -50) {
snowballs[a].destroy();
snowballs.splice(a, 1);
}
}
}
for (var b = zombieKids.length - 1; b >= 0; b--) {
if (zombieKids[b]) {
zombieKids[b].move();
}
if (zombieKids[b].y > 2732) {
LK.showGameOver();
}
}
for (var c = self.children.length - 1; c >= 0; c--) {
if (self.children[c] instanceof ParticleSplash) {
self.children[c].animate();
}
}
if (LK.ticks % 60 == 0) {
var newZombieKid = new ZombieKid();
newZombieKid.x = Math.random() * (2048 - newZombieKid.width);
newZombieKid.y = -newZombieKid.height;
zombieKids.push(newZombieKid);
self.addChild(newZombieKid);
}
});
});
===================================================================
--- original.js
+++ change.js
@@ -91,8 +91,9 @@
newSnowball.speedY = -Math.abs(dy / distance * newSnowball.speed) * speedMultiplier;
newSnowball.speedMultiplier = speedMultiplier;
snowballs.push(newSnowball);
self.addChild(newSnowball);
+ var particleSplashSpeedMultiplier = speedMultiplier;
}
});
LK.on('tick', function () {
if (touchStartTime > 0) {
@@ -109,9 +110,9 @@
for (var i = 0; i < 10; i++) {
var particleSplash = new ParticleSplash();
particleSplash.x = snowballs[a].x;
particleSplash.y = snowballs[a].y;
- particleSplash.speedMultiplier = speedMultiplier;
+ particleSplash.speedMultiplier = particleSplashSpeedMultiplier;
self.addChild(particleSplash);
}
zombieKids[b].destroy();
zombieKids.splice(b, 1);
a christmas gift Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
red crosshair Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snowball of soft snow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas gift with glowing green wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas gift in beautiful glowing wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas gift beautifully wrapped in green glowing wrapping paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Snowy flat surface viewed from above at nighttime Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an empty painting with a winter styled frame Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a kid thief in wearing a black hoodie. Also looking like a zombie Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A button with the text "play". Winter theme Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A winter themed button, with no text Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A buy upgrade button, winter theme, no text Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a wide white sheet of paper Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a snowball Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a snowball
A game over screen for the game "Snowball Santa". Santa is very sad because all the presents has been stolen from ninja kids. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A wooden sign with text "UPGRADES" in a winter theme. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark purple hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark colored hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A ninja kid thief, full body, with a dark colored hoodie. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a precious colorful glowing gem with snow and ice on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a logo for the game "Snowball santa" with the text "Snowball Santa". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A beautiful winter snowy christmas landscape with ninja thieves kids lurking. Christmas gifts are hidden in the snow. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.