Code edit (16 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
loop the ambience sound as soon as it has fully loaded
Code edit (1 edits merged)
Please save this source code
User prompt
play the gameover sound on game over
User prompt
play the squirrelsound when the squirrel first becomes visible on stage
Code edit (1 edits merged)
Please save this source code
User prompt
play the honeysplash sound whenever a honey is collected
User prompt
play the beebuzz sound whenever a new bee first enters the visible portion of the stage
/**** * Classes ****/ // Bear class var Bear = Container.expand(function () { var self = Container.call(this); var bearGraphics = self.attachAsset('bear', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () {}; }); // Bee class var Bee = Container.expand(function () { var self = Container.call(this); var beeGraphics = self.attachAsset('bee', { anchorX: 0.5, anchorY: 0.5 }); //self.speed = 10; self.speed = 6 + Math.random() * 9; self.dead = false; self.hasEnteredStage = false; self.update = function () { if (!self.hasEnteredStage && self.y > -200) { LK.getSound('BeeBuzz').play(); self.hasEnteredStage = true; } self.x += self.speed; if (LK.ticks % 5 == 0) { self.scale.x *= -1; } self.y += updriftSpeed; if (self.speed > 0) { if (self.x > 2248) { self.dead = true; } } else { if (self.x < -200) { self.dead = true; } } if (self.y > 3000) { self.dead = true; } }; }); // Cloud class var Cloud = Container.expand(function () { var self = Container.call(this); var cloudGraphics = self.attachAsset('cloud', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { //self.x += windSpeed * 0.2; self.x += 0.2; if (self.x > self.width / 2 + 2048) { self.x = 0 - self.width / 2 - 200; } }; }); // Dust class var Dust = Container.expand(function () { var self = Container.call(this); var dustGraphics = self.attachAsset('dust', { anchorX: 0.5, anchorY: 0.5 }); self.modifier = 0.5 + Math.random() * 0.5; self.update = function () { self.x += windSpeed * 2 * self.modifier; self.y += updriftSpeed + Math.random() * 2; if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) { self.x = Math.random() < 0.5 ? 0 : 2048; self.y = Math.random() * 2732; } }; }); var GameOverScreen = Container.expand(function () { var self = Container.call(this); var gameOverGraphics = self.attachAsset('gameover', { anchorX: 0.45, anchorY: 0.5, x: 1024, y: 1366 }); var gameOverText = new Text2('Time for the long climb down :)', { size: 90, weight: 800, strokeThickness: 10, strokeColor: '0x000000', fill: "#ffffdd", font: "'Arial Black'", align: 'center' }); gameOverText.x = 1024 - gameOverText.width / 2; gameOverText.y = 2000; self.addChild(gameOverText); self.visible = false; self.show = function () { game.setChildIndex(self, game.children.length - 1); self.visible = true; LK.getSound('GameOver').play(); }; }); var GameOverScreen2 = Container.expand(function () { var self = Container.call(this); var gameOverGraphics = self.attachAsset('gameover2', { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 1366 }); var gameOverText = new Text2('Off to other adventures :)', { size: 90, weight: 800, strokeThickness: 10, strokeColor: '0x000000', fill: "#ffffdd", font: "'Arial Black'", align: 'center' }); gameOverText.x = 1024 - gameOverText.width / 2; gameOverText.y = 2000; self.addChild(gameOverText); self.visible = false; self.show = function () { game.setChildIndex(self, game.children.length - 1); self.visible = true; LK.getSound('GameOverFlying').play(); }; }); // Honey class var Honey = Container.expand(function () { var self = Container.call(this); var honeyGraphics = self.attachAsset('honey', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Honey update logic self.y += updriftSpeed; }; }); var HoneycombFragment = Container.expand(function () { var self = Container.call(this); var fragmentGraphics = self.attachAsset('honeycombFragment', { anchorX: 0.5, anchorY: 0.5 }); self.scale.x = 1.5 - Math.random() * 0.75; self.scale.y = 1.5 - Math.random() * 0.75; self.speedX = (Math.random() - 0.5) * 10; self.speedY = (Math.random() - 0.5) * 10; self.update = function () { self.x += self.speedX; self.y += self.speedY; self.speedY += 0.5; // gravity effect if (self.y > 2732) { self.destroy(); } }; }); var Sign = Container.expand(function () { var self = Container.call(this); self.visible = false; self.show = function (type) { self.visible = true; self.attachAsset(type, { anchorX: 0.5, anchorY: 0.5, x: 1024, y: 2300 }); LK.setTimeout(function () { self.visible = false; }, 5000); }; }); //<Assets used in the game will automatically appear here> var TreeContainer = Container.expand(function () { var self = Container.call(this); }); // Initialize game variables var TrunkPart = Container.expand(function () { var self = Container.call(this); var g1 = self.attachAsset('tree-part', { anchorX: 0.5, anchorY: 0.5 }); var g2 = self.attachAsset('tree-part-flipped', { anchorX: 0.5, anchorY: 0.5, y: 562.3 }); }); var TwoHeadedSquirrel = Container.expand(function () { var self = Container.call(this); var hatGraphics = self.attachAsset('twoheadedSquirrel', { anchorX: 0.5, anchorY: 0.5 }); self.hasEnteredStage = false; self.update = function () { self.y += updriftSpeed; if (!self.hasEnteredStage && self.y > -200) { LK.getSound('SquirrelSound').play(); self.hasEnteredStage = true; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ /* TODO * Sounds - game over, honey collect, baloon pop, mayeb bees, birds, maybe start sound as balloon takes off from ground. wind gust. * Optional: Add other stuff that can be spotted. A lumberjack having lunch. A bird. */ var background; var glitchCover; var bear; var treeContainer; var tree; var firstSegment; var treeSegments = []; var bees = []; var honeys = []; var clouds = []; var score = 0; var scoreTxt; var windSpeed = 8; var windDirection = true; var lastBranchSpawn = 0; var treeBranches = []; var updriftSpeed = 16; var lastSideSpawnLeftRight = false; var totalHeight = 0; var gameStarted = false; var gameEnded = false; var beeSpawnFrequency = 0.1; var branchPos = [[300, 130], [250, 340], [600, 220], [500, 250], [1700, 175], [1800, 340], [1400, 220], [1500, 250]]; var squirrelSpotted = false; var yummySign, honeySign; //var ambiencePlaying = false; var am = LK.getSound('Ambience'); // Initialize game elements function initGame() { yummySign = new Sign(); honeySign = new Sign(); game.addChild(yummySign); game.addChild(honeySign); // Create background background = game.addChild(LK.getAsset('background', { anchorX: 0.0, anchorY: 0.0, x: -500, y: 0 })); glitchCover = game.addChild(LK.getAsset('glitchcover', { anchorX: 0.5, anchorY: 0.5, x: 150, y: 940 })); // Spawn three clouds randomly around the top of the screen for (var i = 0; i < 3; i++) { var cloud = new Cloud(); cloud.x = i == 0 ? 100 : i == 1 ? 1050 : 2100; cloud.y = i == 0 ? 350 : i == 1 ? 300 : 400; //Math.random() * 500; clouds.push(cloud); game.addChild(cloud); } treeContainer = new TreeContainer(); game.addChild(treeContainer); // Create tree //tree = game.addChild(LK.getAsset('tree', { tree = treeContainer.addChild(LK.getAsset('tree', { anchorX: 0.5, anchorY: 0.0, x: 1024 - 8, y: 0 })); // Create tree part firstSegment = new TrunkPart(); firstSegment.x = 1024; // - 8; firstSegment.y = -400; //game.addChild(firstSegment); treeContainer.addChild(firstSegment); treeSegments.push(firstSegment); // Create bear bear = new Bear(); bear.x = 500; bear.y = 2400; game.addChild(bear); // Create score text scoreTxt = new Text2('0', { size: 100, weight: 800, strokeThickness: 10, strokeColor: '0x000000', fill: "#ffffdd", font: "'Arial Black'" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); yummySign = new Sign(); honeySign = new Sign(); game.addChild(yummySign); game.addChild(honeySign); gameOverScreen = new GameOverScreen(); game.addChild(gameOverScreen); gameOverScreen2 = new GameOverScreen2(); game.addChild(gameOverScreen2); } // Update game elements game.update = function () { /*if (LK.ticks > 120 && !ambiencePlaying) { // Loop the ambience sound as soon as it has fully loaded //LK.getSound('Ambience').loop(true).play(); // Loop the ambience sound as soon as it has fully loaded LK.getSound('Ambience').play(); ambiencePlaying = true; }*/ //console.log(am); if (LK.ticks > 120 && !am.isPlaying) { am.play(); } if (gameStarted && !gameEnded) { totalHeight += updriftSpeed; bear.x += windSpeed; if (bear.x < -150 || bear.x > 2200) { gameOverScreen2.show(); gameEnded = true; LK.setTimeout(function () { LK.showGameOver(); }, 6000); } if (bear.y > 1600) { bear.y -= updriftSpeed; } else { if (background.y < 1200) { background.y += updriftSpeed; glitchCover.y += updriftSpeed; } if (tree.y < 2732) { tree.y += updriftSpeed; } for (var i = 0; i < treeSegments.length; i++) { treeSegments[i].y += updriftSpeed; } for (var i = 0; i < treeBranches.length; i++) { treeBranches[i].y += updriftSpeed; } if (firstSegment.y > -1) { var t = new TrunkPart(); t.x = 1024; // - 8; t.y = -1120; //game.addChild(t); treeContainer.addChild(t); firstSegment = t; treeSegments.push(t); } // Update honeys for (var i = 0; i < honeys.length; i++) { //honeys[i].update(); if (bear.intersects(honeys[i])) { //if (!honeys[i] instanceof TwoHeadedSquirrel) { score += 10; scoreTxt.setText('' + score); LK.setScore(score); for (var j = 0; j < 10; j++) { var fragment = new HoneycombFragment(); fragment.x = honeys[i].x; fragment.y = honeys[i].y; game.addChild(fragment); } LK.getSound('HoneySplash').play(); honeys[i].destroy(); honeys.splice(i, 1); if (score % 100 === 0) { //updriftSpeed++; beeSpawnFrequency += 0.05; if (Math.random() < 0.5) { yummySign.show('yummysign'); } else { honeySign.show('honeysign'); } } i--; } } } // Spawn a branch every once in a while. if (totalHeight > 500 && totalHeight - lastBranchSpawn >= 300) { lastBranchSpawn = totalHeight; var branchType = 0; //Math.floor(Math.random() * 8) + 1; // Random branch type between 1 and 4 var flipped = lastSideSpawnLeftRight; if (flipped) { branchType = Math.floor(Math.random() * 4) + 1; } else { branchType = Math.floor(Math.random() * 4) + 5; } lastSideSpawnLeftRight = !lastSideSpawnLeftRight; //var flipped = Math.random() < 0.5 ? 1 : -1; var xx = 1024; var branch = treeContainer.addChildAt(LK.getAsset('tree-branch-' + branchType, { anchorX: 0.5, anchorY: 0.0, x: 1024, y: -1600 }), treeContainer.children.length - 1); if (branchType < 5) { branch.x -= branch.width / 2 + 50; } else { branch.x += branch.width / 2 + 50; } //lastBranchSpawn = LK.ticks; treeBranches.push(branch); //Check if this branch should have a beehive on it. if (Math.random() < 0.3 && treeBranches.length > 6) { // Add new honey if needed var honey = new Honey(); //var branchPos = [[300, 130], [250, 340], [600, 220], [500, 250], [1700, 175], [1800, 340], [1400, 220], [1500, 250]]; honey.x = branchPos[branchType - 1][0]; honey.y = branchPos[branchType - 1][1] - 1600; honeys.push(honey); game.addChild(honey); } //Check for two-headed squirrel spawn if (!squirrelSpotted && score > 200) { if (Math.random() < 0.05) { squirrelSpotted = true; var squirrel = new TwoHeadedSquirrel(); squirrel.x = branchPos[branchType - 1][0]; squirrel.y = branchPos[branchType - 1][1] - 1600 - 200; honeys.push(squirrel); game.addChild(squirrel); } } // Check for bee swarm spawn. if (Math.random() < beeSpawnFrequency) { var b = new Bee(); b.x = Math.random() < 0.5 ? -500 : 2548; //b.y = 200; b.y = -600; b.speed *= b.x == -500 ? 1 : -1; bees.push(b); game.addChild(b); } } // Remove off-screen branches. for (var i = treeBranches.length - 1; i > 0; i--) { var t = treeBranches[i]; if (t.y > 3000) { treeBranches.splice(i, 1); t.destroy(); } } // Remove off-screen tree segments. for (var i = treeSegments.length - 1; i > 0; i--) { var t = treeSegments[i]; if (t.y > 3000) { treeSegments.splice(i, 1); t.destroy(); } } // Remove off-screen honeys. for (var i = honeys.length - 1; i > 0; i--) { var t = honeys[i]; if (t.y > 3000) { honeys.splice(i, 1); t.destroy(); } } // Remove off-screen bees. for (var i = bees.length - 1; i > 0; i--) { var b = bees[i]; var dx = bear.x - b.x; var dy = bear.y - b.y; dx *= dx; dy *= dy; if (dx + dy < 40000) { gameOverScreen.show(); gameEnded = true; LK.setTimeout(function () { LK.showGameOver(); }, 3000); } if (b.dead) { bees.splice(i, 1); b.destroy(); } } for (var i = game.children.length - 1; i >= 0; i--) { if (game.children[i] instanceof HoneycombFragment) { game.children[i].update(); } } } }; // Handle touch/mouse events game.down = function (x, y, obj) { // bear.x = x; // bear.y = y; //windDirection = !windDirection; if (!gameStarted) { gameStarted = true; instructionTxt.destroy(); LK.getSound('LiftOff').play(); } else { windSpeed *= -1; bear.scale.x *= -1; } }; game.move = function (x, y, obj) { // bear.x = x; // bear.y = y; }; // Initialize game initGame(); // Add instruction text var instructionTxt = new Text2('Collect as much honey from the tree\nas you can.\n\nOnce in the air - just tap\nto change direction.\n\nTeddy, Set, Go!', { size: 65, weight: 800, strokeThickness: 10, strokeColor: '0x000000', fill: "#ffffdd", font: "'Arial Black'", align: 'center' }); instructionTxt.anchor.set(0.5, 0); LK.gui.center.addChild(instructionTxt);
===================================================================
--- original.js
+++ change.js
@@ -94,9 +94,9 @@
font: "'Arial Black'",
align: 'center'
});
gameOverText.x = 1024 - gameOverText.width / 2;
- gameOverText.y = 2200;
+ gameOverText.y = 2000;
self.addChild(gameOverText);
self.visible = false;
self.show = function () {
game.setChildIndex(self, game.children.length - 1);
@@ -121,9 +121,9 @@
font: "'Arial Black'",
align: 'center'
});
gameOverText.x = 1024 - gameOverText.width / 2;
- gameOverText.y = 2200;
+ gameOverText.y = 2000;
self.addChild(gameOverText);
self.visible = false;
self.show = function () {
game.setChildIndex(self, game.children.length - 1);
@@ -174,9 +174,9 @@
y: 2300
});
LK.setTimeout(function () {
self.visible = false;
- }, 4000);
+ }, 5000);
};
});
//<Assets used in the game will automatically appear here>
var TreeContainer = Container.expand(function () {
@@ -250,9 +250,10 @@
var beeSpawnFrequency = 0.1;
var branchPos = [[300, 130], [250, 340], [600, 220], [500, 250], [1700, 175], [1800, 340], [1400, 220], [1500, 250]];
var squirrelSpotted = false;
var yummySign, honeySign;
-var ambiencePlaying = false;
+//var ambiencePlaying = false;
+var am = LK.getSound('Ambience');
// Initialize game elements
function initGame() {
yummySign = new Sign();
honeySign = new Sign();
@@ -322,12 +323,18 @@
game.addChild(gameOverScreen2);
}
// Update game elements
game.update = function () {
- if (LK.ticks > 120 && !ambiencePlaying) {
+ /*if (LK.ticks > 120 && !ambiencePlaying) {
// Loop the ambience sound as soon as it has fully loaded
- LK.getSound('Ambience').loop(true).play();
+ //LK.getSound('Ambience').loop(true).play();
+ // Loop the ambience sound as soon as it has fully loaded
+ LK.getSound('Ambience').play();
ambiencePlaying = true;
+ }*/
+ //console.log(am);
+ if (LK.ticks > 120 && !am.isPlaying) {
+ am.play();
}
if (gameStarted && !gameEnded) {
totalHeight += updriftSpeed;
bear.x += windSpeed;
delete the inpainte area
pixelart. A redwood tree branch .. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete all the inpainted areas and replace them with mere transparency.
Pixelart - a cool splash screen style text saying 'Yummy!' golden yellow brown honey colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cool splash screen style text saying 'Delicious Honey!' golden yellow brown honey colors. high-resolution pixel art.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art. some angry bees.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art. a full screen illustration. a likeable and very content little bear cub with a punctured and deflated red baloon is looking down from an incredibly tall redwood tree, inspecting where to get a foothold in order to climb down. The baloon has a puncture in it, from a bee sting, where air is visible flowing out of it, deflating it. the bear's face and fur is smeared a bit with all the delicious golden yellow honey he just ate, which he is enjoying and feeling satiated from. The picture should adhere to the bear's perspective, looking down the tall tree trunk towards the green meadow beneath him. It's a bright summer day with a clear blue sky. Mountains in the distance.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art. a full screen illustration. a likeable and very satiated and content little bear cub with a red baloon is flying away from an incredibly tall redwood tree at considerable height. It's a bright summer day with a clear blue sky. Forest covered mountains in the distance. The overall feel should be happy complacency, even in a place of peril.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. a crouching two-headed squirrel.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.