Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: santa is not defined' in this line: 'var gift = new ChristmasGift(santa.y);' Line Number: 86
User prompt
Fix Bug: 'Uncaught ReferenceError: santa is not defined' in this line: 'var gift = new ChristmasGift(santa.y);' Line Number: 86
User prompt
store santa as a global variable
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: consle is not defined' in this line: 'consle.log("nu");' Line Number: 47
Code edit (4 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: targetTotalDistance is not defined' in this line: 'console.log(self.totalDistance, targetTotalDistance);' Line Number: 45
Code edit (2 edits merged)
Please save this source code
User prompt
if a snowball has passed its target, destroy it
Code edit (1 edits merged)
Please save this source code
User prompt
snowball targetTotalDistance should be distance to aim
User prompt
store a total distance travelled + a target totat distance for snowballs
User prompt
make enemies move with a random speed
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: self.instersects is not a function' in this line: 'if (self.instersects(self.aim)) self.destroy();' Line Number: 41
Code edit (14 edits merged)
Please save this source code
User prompt
destroy the snowball when it hits its aim
User prompt
associate the current aim with the thrown snowball
User prompt
remove snowball as the reach the aim
User prompt
snowballs should be thrown from santa in a tradjectory upwards and then land on aim
User prompt
snowballs should be thrown in 3d, slightly upwards and then land on aim
User prompt
Fix Bug: 'ReferenceError: santa is not defined' in this line: 'var halfDistanceToTarget = Math.sqrt(Math.pow(self.targetX - santa.x, 2) + Math.pow(self.targetY - santa.y, 2)) / 2;' Line Number: 39
User prompt
deaccellerate snowballs as they approach halv way to aim and then accelerate again
User prompt
create a parable for snowballs, making them look like they are throw up an angle to then land on the aim
var Aim = Container.expand(function () { var self = Container.call(this); var aimGraphics = self.createAsset('aim', 'Aim Graphics', .5, .5); }); var ParticleSplash = Container.expand(function () { var self = Container.call(this); var particleSplashGraphics = self.createAsset('particleSplash', 'Particle Splash Graphics', .5, .5); var randomScale = 0.5 + Math.random() * 0.5; self.scale.x = randomScale; self.scale.y = randomScale; self.directionX = Math.random() * 2 - 1; self.directionY = Math.random() * 2 - 1; self.animate = function () { self.alpha -= 0.01; self.x += self.directionX; self.y += self.directionY; 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); self.aim = arguments[0]; var snowballGraphics = self.createAsset('snowball', 'Snowball Graphics', .5, .5); self.speed = -5; self.targetX = self.aim.x; self.targetY = self.aim.y; self.speedX = 0; self.speedY = 0; self.totalDistance = 0; self.targetTotalDistance = Math.sqrt(Math.pow(self.targetX - self.x, 2) + Math.pow(self.y - self.targetY, 2)); self.move = function () { var distance = Math.sqrt(self.speedX * self.speedX + self.speedY * self.speedY); self.totalDistance += distance; self.x += self.speedX; self.y += self.speedY; console.log(self.totalDistance, self.targetTotalDistance); if (self.y < -50 || self.totalDistance > self.targetTotalDistance) { console.log("nu"); if (self.aim) self.aim.destroy(); self.destroy(); } }; }); var ZombieKid = Container.expand(function () { var self = Container.call(this); var zombieKidGraphics = self.createAsset('zombieKid', 'Zombie Kid Graphics', .5, .5); self.speed = Math.random() * 2 + 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 ChristmasGift = Container.expand(function (santaY) { var self = Container.call(this); var christmasGiftGraphics = self.createAsset('christmasGifts', 'Christmas Gifts Graphics', 0.5, 1); self.x = Math.random() * 1024 + 512; self.y = Math.random() * (2732 - santaY - 200) + santaY + 200; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background', 'Full Screen Background', 0, 0); background.width = 2048; background.height = 2732; self.isThrowing = false; self.addChildAt(background, 0); var santa = self.addChild(new Santa()); santa.x = 2048 / 2; santa.y = 2732 - santa.height - 2732 / 8; var progressBar = self.addChild(new ProgressBar()); progressBar.x = 2048 - progressBar.width; progressBar.y = 2732 - progressBar.height; var christmasGifts = []; for (var i = 0; i < 50; i++) { var gift = new ChristmasGift(santa.y); christmasGifts.push(gift); self.addChild(gift); } 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); isThrowing = true; var event = obj.event; var pos = event.getLocalPosition(self); santa.baseRotation = Math.atan2(pos.y - santa.y, pos.x - santa.x) + Math.PI * 0.6; self.aimPosition = pos; var aim = new Aim(); self.currentAim = aim; aim.x = pos.x; aim.y = pos.y; var progress = 0; aim.scale.x = aim.scale.y = 0.5 + progress * 0.5; self.addChild(aim); aim.tweenToAlpha = function (targetAlpha, duration) { var step = (1 - targetAlpha) / (duration * 60); var fadeInterval = LK.setInterval(function () { aim.alpha -= step; if (aim.alpha <= targetAlpha) { LK.clearInterval(fadeInterval); aim.destroy(); } }, 1000 / 60); }; aim.tweenToAlpha(0, 3); }); stage.on('up', function (obj) { if (self.aim) { self.aim.destroy(); self.aim = null; } progressBar.updateProgress(0); santa.rotation = santa.baseRotation; isThrowing = false; if (snowballs.length < 5 && self.aimPosition) { var newSnowball = new Snowball(self.currentAim); newSnowball.x = santa.x; newSnowball.y = santa.y; newSnowball.targetX = self.aimPosition.x; newSnowball.targetY = self.aimPosition.y; newSnowball.aim = self.currentAim; newSnowball.init(); 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; snowballs.push(newSnowball); self.addChild(newSnowball); self.aimPosition = null; } self.currentAim = null; }); LK.on('tick', function () { if (touchStartTime > 0 && isThrowing) { var progress = Math.min((LK.ticks - touchStartTime) / 30, 1); progressBar.updateProgress(progress); santa.rotation = santa.baseRotation + progress * Math.PI * 2 / 10; if (self.aim) { self.aim.scale.x = self.aim.scale.y = 0.5 + progressBarGraphics.scale.x * 0.5; } if (self.currentAim) { self.currentAim.scale.x = 0.2 + progress; self.currentAim.scale.y = 0.2 + 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.directionX *= snowballs[a].speedY; particleSplash.directionY *= snowballs[a].speedY; self.addChild(particleSplash); } zombieKids[b].destroy(); zombieKids.splice(b, 1); if (snowballs[a].aim) snowballs[a].aim.destroy(); 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
@@ -74,17 +74,17 @@
background.width = 2048;
background.height = 2732;
self.isThrowing = false;
self.addChildAt(background, 0);
- globalSanta = self.addChild(new Santa());
- globalSanta.x = 2048 / 2;
- globalSanta.y = 2732 - globalSanta.height - 2732 / 8;
+ var santa = self.addChild(new Santa());
+ santa.x = 2048 / 2;
+ santa.y = 2732 - santa.height - 2732 / 8;
var progressBar = self.addChild(new ProgressBar());
progressBar.x = 2048 - progressBar.width;
progressBar.y = 2732 - progressBar.height;
var christmasGifts = [];
for (var i = 0; i < 50; i++) {
- var gift = new ChristmasGift(globalSanta.y);
+ var gift = new ChristmasGift(santa.y);
christmasGifts.push(gift);
self.addChild(gift);
}
var scoreTxt = new Text2('0', {
@@ -141,8 +141,9 @@
newSnowball.y = santa.y;
newSnowball.targetX = self.aimPosition.x;
newSnowball.targetY = self.aimPosition.y;
newSnowball.aim = self.currentAim;
+ newSnowball.init();
var dx = newSnowball.targetX - newSnowball.x;
var dy = newSnowball.targetY - newSnowball.y;
var distance = Math.sqrt(dx * dx + dy * dy);
var throwSpeed = 5;
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.