User prompt
add +1 to score when sgbarrel is destroyed
User prompt
remove and delete sgposter02
Code edit (2 edits merged)
Please save this source code
User prompt
remove sgposter1 initialiation
User prompt
remove any sgposter01 duplicate4s
User prompt
there should only be one sgposter01 and one sgposter02 on screen
User prompt
sgposter01 &02 shouldnt be moving on start
User prompt
give sgPoster01 & sgPoster02 similar behavior to sgBeans, including click interactions and automatic destruction when off-screen.
User prompt
Initialize the sgPoster02 asset on screen
User prompt
initialize sgposter01
Code edit (3 edits merged)
Please save this source code
User prompt
instantiate brokenbarrel for only 1 second
User prompt
destroy sgBrokenBarrel after 1 second
User prompt
when sgbarrel is left clicked, play sound barreltHit01
User prompt
anytime target10 or target5 are left clicked, play hitcan02
User prompt
anytime target10 or target5 destroys itself, playsound hitcan02
User prompt
anytime target10 or target5 destroys itself, play canHit02
User prompt
anytime target10 or target5 destroys itself, play hitcan02
User prompt
anytime target10 or target5 destroys itself, play canhit02
User prompt
anytime target10 or target5 destroys itself, play hitcan02
User prompt
anytime target10 or target5 destroys itself, replace it for 0.5 seconds with sgcloudsmoke
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
all sgtargets100 should have the same sound when they are left clicked
Code edit (1 edits merged)
Please save this source code
/**** * Classes ****/ // Create a class for the sg_Notes asset var Note = Container.expand(function () { var self = Container.call(this); // Attach the sg_Notes asset to the Note instance var noteGraphics = self.attachAsset('sg_Notes', { anchorX: 0.5, anchorY: 0.5 }); // Set the initial speed of the note self.speed = 1.25; // This is automatically called every game tick, if the note is attached! self.update = function () { self.y -= self.speed; // Destroy the note if it goes off screen if (self.y < -50) { self.destroy(); } }; }); var Tumbleweed = Container.expand(function () { var self = Container.call(this); var tumbleweedGraphics = self.attachAsset('sgTumbleWeed', { anchorX: 0.5, anchorY: 0.4 }); self.speedX = 6; self.speedY = 0; self.rotationSpeed = 0.075; self.update = function () { self.x += self.speedX; self.rotation += self.rotationSpeed; if (self.x > 2048) { self.destroy(); } }; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize the sgBarrel asset on screen var sgBarrel = game.addChild(LK.getAsset('sgBarrel', { anchorX: 0.5, anchorY: 0.5, x: 1000, y: 1500 })); // Add a click event to the sgBarrel asset sgBarrel.down = function (x, y, obj) { // Destroy the sgBarrel asset this.destroy(); // Instantiate sgBrokenBarrel at the same position var sgBrokenBarrel = game.addChild(LK.getAsset('sgBrokenBarrel', { anchorX: 0.5, anchorY: 0.5, x: this.x, y: this.y })); }; function spawnTumbleweed() { var tumbleweed = new Tumbleweed(); tumbleweed.x = 100; tumbleweed.y = 2800; game.addChild(tumbleweed); var nextSpawnTime = Math.random() * 20000 + 30000; // 20 to 30 seconds LK.setTimeout(spawnTumbleweed, nextSpawnTime); } LK.setTimeout(spawnTumbleweed, 10000); // Initialize the sgFrame01 asset on screen var sgFrame01 = game.addChild(LK.getAsset('sgFrame01', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2600 / 2 })); // Initialize the sgDesertRock asset on screen var sgDesertRock = game.addChild(LK.getAsset('sgDesertRock', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 2900 })); // Initialize the sgGecko asset on screen after sgDesertRock var sgGecko = game.addChild(LK.getAsset('sgGecko', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 2375 })); // Add a click event to the sgGecko asset sgGecko.down = function (x, y, obj) { // Play sgGeckoNoise sound LK.getSound('sgGeckoNoise').play(); // Destroy the sgGecko asset this.destroy(); // Instantiate sgCloudPuff at the same position var sgCloudPuff = game.addChild(LK.getAsset('sgCloudPuff', { anchorX: 0.5, anchorY: 0.5, x: this.x - 25, y: this.y })); // After 1 second, destroy sgCloudPuff and instantiate sgTarget100 LK.setTimeout(function () { sgCloudPuff.destroy(); var sgTarget100 = game.addChild(LK.getAsset('sgTarget100', { anchorX: 0.5, anchorY: 0.5, x: sgCloudPuff.x, y: sgCloudPuff.y })); // Add pulsing effect to sgTarget100 sgTarget100.update = function () { this.scale.x = 1 + 0.1 * Math.sin(LK.ticks * 0.1); this.scale.y = 1 + 0.1 * Math.sin(LK.ticks * 0.1); }; // Add a click event to the sgTarget100 asset to destroy it and replace it with a flashing number 100 for 1 second sgTarget100.down = function (x, y, obj) { // Play getSound02 sound LK.getSound('getSound02').play(); // Destroy the sgTarget100 asset this.destroy(); // Add 100 to the score score += 100; scoreTxt.setText(score); // Create a text asset for the number 100 var number100 = new Text2('100', { size: 50, fill: "#00FF00" // Green color }); // Position the number 100 at the same position as the sgTarget100 asset number100.x = this.x - 50; number100.y = this.y - 30; // Add the number 100 to the game game.addChild(number100); // Make the number 100 flash for 1 second var flashInterval = LK.setInterval(function () { number100.visible = !number100.visible; }, 100); LK.setTimeout(function () { LK.clearInterval(flashInterval); number100.visible = true; }, 1000); // After 1 second, destroy the number 100 LK.setTimeout(function () { number100.destroy(); }, 1000); }; }, 1000); }; // Initialize the sgTarget100 asset on screen var sgTarget100 = game.addChild(LK.getAsset('sgTarget100', { anchorX: 0.5, anchorY: 0.5, x: 300, y: 1000 })); // Add pulsing effect to sgTarget100 sgTarget100.update = function () { this.scale.x = 1 + 0.1 * Math.sin(LK.ticks * 0.1); this.scale.y = 1 + 0.1 * Math.sin(LK.ticks * 0.1); }; // Add a click event to the sgTarget100 asset to destroy it and replace it with a flashing number 100 for 1 second sgTarget100.down = function (x, y, obj) { // Destroy the sgTarget100 asset this.destroy(); // Add 100 to the score score += 100; scoreTxt.setText(score); // Create a text asset for the number 100 var number100 = new Text2('100', { size: 50, fill: "#00FF00" // Green color }); // Position the number 100 at the same position as the sgTarget100 asset number100.x = this.x - 50; number100.y = this.y - 30; // Add the number 100 to the game game.addChild(number100); // Make the number 100 flash for 1 second var flashInterval = LK.setInterval(function () { number100.visible = !number100.visible; }, 100); LK.setTimeout(function () { LK.clearInterval(flashInterval); number100.visible = true; }, 1000); // After 1 second, destroy the number 100 LK.setTimeout(function () { number100.destroy(); }, 1000); }; // Initialize variables var scoreTxt; var score = 0; var isPianoPlaying = false; // Initialize the saloonPiano asset on screen var saloonPiano = game.addChild(LK.getAsset('saloonPiano', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); // Add a click event to the piano saloonPiano.down = function (x, y, obj) { // If the piano jingle is not playing, play it if (!isPianoPlaying) { isPianoPlaying = true; LK.getSound('saloonPianoJingle01').play(); // After 5 seconds, set isPianoPlaying to false and hide sg_notes LK.setTimeout(function () { isPianoPlaying = false; note.visible = false; }, 3250); // Create sg_Notes above saloonPiano when piano jingle is playing var note = new Note(); note.x = saloonPiano.x; note.y = saloonPiano.y - 100; game.addChild(note); } }; // Initialize the sgSign01 asset on screen and center it at the top var sgSign01 = LK.gui.top.addChild(LK.getAsset('sg_Sign01', { anchorX: 0.5, anchorY: 0, x: 0, y: -150 })); // Add a click event to the sg_Sign01 asset to make it swing for 5 seconds sgSign01.down = function (x, y, obj) { // Check if the sign is already swinging if (this.isSwinging) { return; } this.isSwinging = true; var swingDuration = 5000; // 5 seconds in milliseconds var swingFrequency = 1 / swingDuration; // Frequency of the oscillation var swingAmplitude = 1; // The maximum rotation angle var startTime = Date.now(); // Play chainNoises sound once at the start of the swinging LK.getSound('chainNoises').play(); this.update = function () { var currentTime = Date.now(); var timePassed = currentTime - startTime; if (timePassed < swingDuration) { this.rotation = swingAmplitude * Math.sin(2 * Math.PI * swingFrequency * timePassed); } else { this.rotation = 0; this.update = function () {}; this.isSwinging = false; } }; game.update = this.update.bind(this); }; // Initialize the sg_Beans01 asset on screen var sgBeans01 = game.addChild(LK.getAsset('sgBeans01', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2000 / 2 })); // Initialize the sgCactus asset on screen var sgCactus = game.addChild(LK.getAsset('sgCactus', { anchorX: 0.5, anchorY: 0.5, x: 2000, y: 2500 })); // Initialize the sgCharacter asset on screen var sgCharacter = game.addChild(LK.getAsset('sgCharacter', { anchorX: 0.5, anchorY: 0.5, x: 900 / 2, y: 4750 / 2 })); // Add a click event to the sgCharacter asset to trigger game over sgCharacter.down = function (x, y, obj) { LK.effects.flashScreen(0xff0000, 1000); LK.setTimeout(function () { LK.showGameOver(); }, 250); }; // Create score text scoreTxt = new Text2('0', { size: 150, fill: "#000000" }); scoreTxt.anchor.set(0.5, 0); game.addChild(scoreTxt); scoreTxt.x = sgCharacter.x; scoreTxt.y = sgCharacter.y + 85; // Add a click event to the sg_Beans01 asset to make it fall off the screen sgBeans01.down = function (x, y, obj) { // Add 1 to the score if (!this.clicked) { score += 1; scoreTxt.setText(score); this.clicked = true; } // Play canHit or canHit02 sound randomly if (Math.random() > 0.5) { LK.getSound('canHit').play(); } else { LK.getSound('canHit02').play(); } // Define initial velocity, gravity and angular velocity var velocityX = Math.random() * 20 - 10; // Random velocity between -10 and 10 var velocityY = Math.random() * 10 + 5; // Random velocity between 5 and 15 var gravity = 0.5; var angularVelocity = Math.random() * 0.2 - 0.1; // Random angular velocity between -0.1 and 0.1 this.update = function () { // Apply gravity to velocity velocityY += gravity; // Apply velocity to y position this.y += velocityY; // Apply velocity to x position this.x += velocityX; // Apply angular velocity to rotation this.rotation += angularVelocity; // Destroy the bean can if it goes off screen if (this.y > 2732 || this.x < 0 || this.x > 2048) { this.destroy(); } }; game.update = this.update.bind(this); }; // Initialize the sgGlassBottle01 asset on screen var sgGlassBottle01 = game.addChild(LK.getAsset('sgGlassBottle01', { anchorX: 0.5, anchorY: 0.5, x: 2848 / 2, y: 2732 / 2 })); // Add a click event to the sgGlassBottle01 asset to play glassHit01 or glassHit02 sound and destroy the asset sgGlassBottle01.down = function (x, y, obj) { // Play glassHit01 or glassHit02 sound randomly if (Math.random() > 0.5) { LK.getSound('glassHit01').play(); } else { LK.getSound('glassHit02').play(); } // Replace the glass bottle with broken glass bottle this.destroy(); // Add 1 to the score score += 1; scoreTxt.setText(score); var sgBrokenGlassBottle01 = game.addChild(LK.getAsset('sgBrokenGlassBottle01', { anchorX: 0.5, anchorY: 0.5, x: this.x, y: this.y })); // After 0.5 second, destroy the broken glass bottle LK.setTimeout(function () { sgBrokenGlassBottle01.destroy(); }, 500); }; // Initialize the sgTarget5 asset on screen var sgTarget5 = game.addChild(LK.getAsset('sgTarget5', { anchorX: 0.5, anchorY: 0.5, x: 1200 / 2, y: 2732 / 2 })); // Add a click event to the sgTarget5 asset to destroy it and replace it with a flashing number 5 for 1 second sgTarget5.down = function (x, y, obj) { // Destroy the sgTarget5 asset this.destroy(); // Add 5 to the score score += 5; scoreTxt.setText(score); // Create a text asset for the number 5 var number5 = new Text2('5', { size: 75, fill: "#ffffff" }); // Position the number 5 at the same position as the sgTarget5 asset number5.x = this.x - 25; number5.y = this.y - 50; // Add the number 5 to the game game.addChild(number5); // Make the number 5 flash for 1 second var flashInterval = LK.setInterval(function () { number5.visible = !number5.visible; }, 100); LK.setTimeout(function () { LK.clearInterval(flashInterval); number5.visible = true; }, 1000); // After 1 second, destroy the number 5 LK.setTimeout(function () { number5.destroy(); }, 1000); }; // Initialize the sgTarget25 asset on screen var sgTarget25 = game.addChild(LK.getAsset('sgTarget25', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); // Add rotation animation to sgTarget25 sgTarget25.update = function () { this.scale.x = Math.sin(LK.ticks * 0.1); // Adjust the flip speed as needed }; // Add a click event to the sgTarget25 asset to destroy it and replace it with a flashing number 25 for 1 second sgTarget25.down = function (x, y, obj) { // Play getSound01 sound LK.getSound('getSound01').play(); // Destroy the sgTarget25 asset this.destroy(); // Add 25 to the score score += 25; scoreTxt.setText(score); // Create a text asset for the number 25 var number25 = new Text2('25', { size: 75, fill: "#FFD700" // Gold color }); // Position the number 25 at the same position as the sgTarget25 asset number25.x = this.x - 40; number25.y = this.y - 30; // Add the number 25 to the game game.addChild(number25); // Make the number 25 flash for 1 second var flashInterval = LK.setInterval(function () { number25.visible = !number25.visible; }, 100); LK.setTimeout(function () { LK.clearInterval(flashInterval); number25.visible = true; }, 1000); // After 1 second, destroy the number 25 LK.setTimeout(function () { number25.destroy(); }, 1000); }; // Initialize the sgTarget10 asset on screen var sgTarget10 = game.addChild(LK.getAsset('sgTarget10', { anchorX: 0.5, anchorY: 0.5, x: 1500, y: 1500 })); // Add a click event to the sgTarget10 asset to destroy it and replace it with a flashing number 10 for 1 second sgTarget10.down = function (x, y, obj) { // Destroy the sgTarget10 asset this.destroy(); // Add 10 to the score score += 10; scoreTxt.setText(score); // Create a text asset for the number 10 var number10 = new Text2('10', { size: 75, fill: "#ADD8E6" // Light blue color }); // Position the number 10 at the same position as the sgTarget10 asset number10.x = this.x - 40; number10.y = this.y - 30; // Add the number 10 to the game game.addChild(number10); // Make the number 10 flash for 1 second var flashInterval = LK.setInterval(function () { number10.visible = !number10.visible; }, 100); LK.setTimeout(function () { LK.clearInterval(flashInterval); number10.visible = true; }, 1000); // After 1 second, destroy the number 10 LK.setTimeout(function () { number10.destroy(); }, 1000); }; // Handle game updates sgTarget25.update(); sgTarget100.update(); // Add a click event to the game to create a sgCrosshair asset at the clicked position game.down = function (x, y, obj) { // Create a sgCrosshair asset at the clicked position var sgCrosshair = game.addChild(LK.getAsset('sgCrosshair', { anchorX: 0.5, anchorY: 0.5, x: x, y: y })); // Play bulletHit01 or bulletHit02 sound randomly if (Math.random() > 0.5) { LK.getSound('bulletHit01').play(); } // After 0.5 second, destroy the sgCrosshair asset LK.setTimeout(function () { sgCrosshair.destroy(); }, 500); }; ; ;
/****
* Classes
****/
// Create a class for the sg_Notes asset
var Note = Container.expand(function () {
var self = Container.call(this);
// Attach the sg_Notes asset to the Note instance
var noteGraphics = self.attachAsset('sg_Notes', {
anchorX: 0.5,
anchorY: 0.5
});
// Set the initial speed of the note
self.speed = 1.25;
// This is automatically called every game tick, if the note is attached!
self.update = function () {
self.y -= self.speed;
// Destroy the note if it goes off screen
if (self.y < -50) {
self.destroy();
}
};
});
var Tumbleweed = Container.expand(function () {
var self = Container.call(this);
var tumbleweedGraphics = self.attachAsset('sgTumbleWeed', {
anchorX: 0.5,
anchorY: 0.4
});
self.speedX = 6;
self.speedY = 0;
self.rotationSpeed = 0.075;
self.update = function () {
self.x += self.speedX;
self.rotation += self.rotationSpeed;
if (self.x > 2048) {
self.destroy();
}
};
});
/****
* Initialize Game
****/
//<Assets used in the game will automatically appear here>
var game = new LK.Game({
backgroundColor: 0x000000 //Init game with black background
});
/****
* Game Code
****/
// Initialize the sgBarrel asset on screen
var sgBarrel = game.addChild(LK.getAsset('sgBarrel', {
anchorX: 0.5,
anchorY: 0.5,
x: 1000,
y: 1500
}));
// Add a click event to the sgBarrel asset
sgBarrel.down = function (x, y, obj) {
// Destroy the sgBarrel asset
this.destroy();
// Instantiate sgBrokenBarrel at the same position
var sgBrokenBarrel = game.addChild(LK.getAsset('sgBrokenBarrel', {
anchorX: 0.5,
anchorY: 0.5,
x: this.x,
y: this.y
}));
};
function spawnTumbleweed() {
var tumbleweed = new Tumbleweed();
tumbleweed.x = 100;
tumbleweed.y = 2800;
game.addChild(tumbleweed);
var nextSpawnTime = Math.random() * 20000 + 30000; // 20 to 30 seconds
LK.setTimeout(spawnTumbleweed, nextSpawnTime);
}
LK.setTimeout(spawnTumbleweed, 10000);
// Initialize the sgFrame01 asset on screen
var sgFrame01 = game.addChild(LK.getAsset('sgFrame01', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2600 / 2
}));
// Initialize the sgDesertRock asset on screen
var sgDesertRock = game.addChild(LK.getAsset('sgDesertRock', {
anchorX: 0.5,
anchorY: 0.5,
x: 1500,
y: 2900
}));
// Initialize the sgGecko asset on screen after sgDesertRock
var sgGecko = game.addChild(LK.getAsset('sgGecko', {
anchorX: 0.5,
anchorY: 0.5,
x: 1500,
y: 2375
}));
// Add a click event to the sgGecko asset
sgGecko.down = function (x, y, obj) {
// Play sgGeckoNoise sound
LK.getSound('sgGeckoNoise').play();
// Destroy the sgGecko asset
this.destroy();
// Instantiate sgCloudPuff at the same position
var sgCloudPuff = game.addChild(LK.getAsset('sgCloudPuff', {
anchorX: 0.5,
anchorY: 0.5,
x: this.x - 25,
y: this.y
}));
// After 1 second, destroy sgCloudPuff and instantiate sgTarget100
LK.setTimeout(function () {
sgCloudPuff.destroy();
var sgTarget100 = game.addChild(LK.getAsset('sgTarget100', {
anchorX: 0.5,
anchorY: 0.5,
x: sgCloudPuff.x,
y: sgCloudPuff.y
}));
// Add pulsing effect to sgTarget100
sgTarget100.update = function () {
this.scale.x = 1 + 0.1 * Math.sin(LK.ticks * 0.1);
this.scale.y = 1 + 0.1 * Math.sin(LK.ticks * 0.1);
};
// Add a click event to the sgTarget100 asset to destroy it and replace it with a flashing number 100 for 1 second
sgTarget100.down = function (x, y, obj) {
// Play getSound02 sound
LK.getSound('getSound02').play();
// Destroy the sgTarget100 asset
this.destroy();
// Add 100 to the score
score += 100;
scoreTxt.setText(score);
// Create a text asset for the number 100
var number100 = new Text2('100', {
size: 50,
fill: "#00FF00" // Green color
});
// Position the number 100 at the same position as the sgTarget100 asset
number100.x = this.x - 50;
number100.y = this.y - 30;
// Add the number 100 to the game
game.addChild(number100);
// Make the number 100 flash for 1 second
var flashInterval = LK.setInterval(function () {
number100.visible = !number100.visible;
}, 100);
LK.setTimeout(function () {
LK.clearInterval(flashInterval);
number100.visible = true;
}, 1000);
// After 1 second, destroy the number 100
LK.setTimeout(function () {
number100.destroy();
}, 1000);
};
}, 1000);
};
// Initialize the sgTarget100 asset on screen
var sgTarget100 = game.addChild(LK.getAsset('sgTarget100', {
anchorX: 0.5,
anchorY: 0.5,
x: 300,
y: 1000
}));
// Add pulsing effect to sgTarget100
sgTarget100.update = function () {
this.scale.x = 1 + 0.1 * Math.sin(LK.ticks * 0.1);
this.scale.y = 1 + 0.1 * Math.sin(LK.ticks * 0.1);
};
// Add a click event to the sgTarget100 asset to destroy it and replace it with a flashing number 100 for 1 second
sgTarget100.down = function (x, y, obj) {
// Destroy the sgTarget100 asset
this.destroy();
// Add 100 to the score
score += 100;
scoreTxt.setText(score);
// Create a text asset for the number 100
var number100 = new Text2('100', {
size: 50,
fill: "#00FF00" // Green color
});
// Position the number 100 at the same position as the sgTarget100 asset
number100.x = this.x - 50;
number100.y = this.y - 30;
// Add the number 100 to the game
game.addChild(number100);
// Make the number 100 flash for 1 second
var flashInterval = LK.setInterval(function () {
number100.visible = !number100.visible;
}, 100);
LK.setTimeout(function () {
LK.clearInterval(flashInterval);
number100.visible = true;
}, 1000);
// After 1 second, destroy the number 100
LK.setTimeout(function () {
number100.destroy();
}, 1000);
};
// Initialize variables
var scoreTxt;
var score = 0;
var isPianoPlaying = false;
// Initialize the saloonPiano asset on screen
var saloonPiano = game.addChild(LK.getAsset('saloonPiano', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
}));
// Add a click event to the piano
saloonPiano.down = function (x, y, obj) {
// If the piano jingle is not playing, play it
if (!isPianoPlaying) {
isPianoPlaying = true;
LK.getSound('saloonPianoJingle01').play();
// After 5 seconds, set isPianoPlaying to false and hide sg_notes
LK.setTimeout(function () {
isPianoPlaying = false;
note.visible = false;
}, 3250);
// Create sg_Notes above saloonPiano when piano jingle is playing
var note = new Note();
note.x = saloonPiano.x;
note.y = saloonPiano.y - 100;
game.addChild(note);
}
};
// Initialize the sgSign01 asset on screen and center it at the top
var sgSign01 = LK.gui.top.addChild(LK.getAsset('sg_Sign01', {
anchorX: 0.5,
anchorY: 0,
x: 0,
y: -150
}));
// Add a click event to the sg_Sign01 asset to make it swing for 5 seconds
sgSign01.down = function (x, y, obj) {
// Check if the sign is already swinging
if (this.isSwinging) {
return;
}
this.isSwinging = true;
var swingDuration = 5000; // 5 seconds in milliseconds
var swingFrequency = 1 / swingDuration; // Frequency of the oscillation
var swingAmplitude = 1; // The maximum rotation angle
var startTime = Date.now();
// Play chainNoises sound once at the start of the swinging
LK.getSound('chainNoises').play();
this.update = function () {
var currentTime = Date.now();
var timePassed = currentTime - startTime;
if (timePassed < swingDuration) {
this.rotation = swingAmplitude * Math.sin(2 * Math.PI * swingFrequency * timePassed);
} else {
this.rotation = 0;
this.update = function () {};
this.isSwinging = false;
}
};
game.update = this.update.bind(this);
};
// Initialize the sg_Beans01 asset on screen
var sgBeans01 = game.addChild(LK.getAsset('sgBeans01', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2000 / 2
}));
// Initialize the sgCactus asset on screen
var sgCactus = game.addChild(LK.getAsset('sgCactus', {
anchorX: 0.5,
anchorY: 0.5,
x: 2000,
y: 2500
}));
// Initialize the sgCharacter asset on screen
var sgCharacter = game.addChild(LK.getAsset('sgCharacter', {
anchorX: 0.5,
anchorY: 0.5,
x: 900 / 2,
y: 4750 / 2
}));
// Add a click event to the sgCharacter asset to trigger game over
sgCharacter.down = function (x, y, obj) {
LK.effects.flashScreen(0xff0000, 1000);
LK.setTimeout(function () {
LK.showGameOver();
}, 250);
};
// Create score text
scoreTxt = new Text2('0', {
size: 150,
fill: "#000000"
});
scoreTxt.anchor.set(0.5, 0);
game.addChild(scoreTxt);
scoreTxt.x = sgCharacter.x;
scoreTxt.y = sgCharacter.y + 85;
// Add a click event to the sg_Beans01 asset to make it fall off the screen
sgBeans01.down = function (x, y, obj) {
// Add 1 to the score
if (!this.clicked) {
score += 1;
scoreTxt.setText(score);
this.clicked = true;
}
// Play canHit or canHit02 sound randomly
if (Math.random() > 0.5) {
LK.getSound('canHit').play();
} else {
LK.getSound('canHit02').play();
}
// Define initial velocity, gravity and angular velocity
var velocityX = Math.random() * 20 - 10; // Random velocity between -10 and 10
var velocityY = Math.random() * 10 + 5; // Random velocity between 5 and 15
var gravity = 0.5;
var angularVelocity = Math.random() * 0.2 - 0.1; // Random angular velocity between -0.1 and 0.1
this.update = function () {
// Apply gravity to velocity
velocityY += gravity;
// Apply velocity to y position
this.y += velocityY;
// Apply velocity to x position
this.x += velocityX;
// Apply angular velocity to rotation
this.rotation += angularVelocity;
// Destroy the bean can if it goes off screen
if (this.y > 2732 || this.x < 0 || this.x > 2048) {
this.destroy();
}
};
game.update = this.update.bind(this);
};
// Initialize the sgGlassBottle01 asset on screen
var sgGlassBottle01 = game.addChild(LK.getAsset('sgGlassBottle01', {
anchorX: 0.5,
anchorY: 0.5,
x: 2848 / 2,
y: 2732 / 2
}));
// Add a click event to the sgGlassBottle01 asset to play glassHit01 or glassHit02 sound and destroy the asset
sgGlassBottle01.down = function (x, y, obj) {
// Play glassHit01 or glassHit02 sound randomly
if (Math.random() > 0.5) {
LK.getSound('glassHit01').play();
} else {
LK.getSound('glassHit02').play();
}
// Replace the glass bottle with broken glass bottle
this.destroy();
// Add 1 to the score
score += 1;
scoreTxt.setText(score);
var sgBrokenGlassBottle01 = game.addChild(LK.getAsset('sgBrokenGlassBottle01', {
anchorX: 0.5,
anchorY: 0.5,
x: this.x,
y: this.y
}));
// After 0.5 second, destroy the broken glass bottle
LK.setTimeout(function () {
sgBrokenGlassBottle01.destroy();
}, 500);
};
// Initialize the sgTarget5 asset on screen
var sgTarget5 = game.addChild(LK.getAsset('sgTarget5', {
anchorX: 0.5,
anchorY: 0.5,
x: 1200 / 2,
y: 2732 / 2
}));
// Add a click event to the sgTarget5 asset to destroy it and replace it with a flashing number 5 for 1 second
sgTarget5.down = function (x, y, obj) {
// Destroy the sgTarget5 asset
this.destroy();
// Add 5 to the score
score += 5;
scoreTxt.setText(score);
// Create a text asset for the number 5
var number5 = new Text2('5', {
size: 75,
fill: "#ffffff"
});
// Position the number 5 at the same position as the sgTarget5 asset
number5.x = this.x - 25;
number5.y = this.y - 50;
// Add the number 5 to the game
game.addChild(number5);
// Make the number 5 flash for 1 second
var flashInterval = LK.setInterval(function () {
number5.visible = !number5.visible;
}, 100);
LK.setTimeout(function () {
LK.clearInterval(flashInterval);
number5.visible = true;
}, 1000);
// After 1 second, destroy the number 5
LK.setTimeout(function () {
number5.destroy();
}, 1000);
};
// Initialize the sgTarget25 asset on screen
var sgTarget25 = game.addChild(LK.getAsset('sgTarget25', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
}));
// Add rotation animation to sgTarget25
sgTarget25.update = function () {
this.scale.x = Math.sin(LK.ticks * 0.1); // Adjust the flip speed as needed
};
// Add a click event to the sgTarget25 asset to destroy it and replace it with a flashing number 25 for 1 second
sgTarget25.down = function (x, y, obj) {
// Play getSound01 sound
LK.getSound('getSound01').play();
// Destroy the sgTarget25 asset
this.destroy();
// Add 25 to the score
score += 25;
scoreTxt.setText(score);
// Create a text asset for the number 25
var number25 = new Text2('25', {
size: 75,
fill: "#FFD700" // Gold color
});
// Position the number 25 at the same position as the sgTarget25 asset
number25.x = this.x - 40;
number25.y = this.y - 30;
// Add the number 25 to the game
game.addChild(number25);
// Make the number 25 flash for 1 second
var flashInterval = LK.setInterval(function () {
number25.visible = !number25.visible;
}, 100);
LK.setTimeout(function () {
LK.clearInterval(flashInterval);
number25.visible = true;
}, 1000);
// After 1 second, destroy the number 25
LK.setTimeout(function () {
number25.destroy();
}, 1000);
};
// Initialize the sgTarget10 asset on screen
var sgTarget10 = game.addChild(LK.getAsset('sgTarget10', {
anchorX: 0.5,
anchorY: 0.5,
x: 1500,
y: 1500
}));
// Add a click event to the sgTarget10 asset to destroy it and replace it with a flashing number 10 for 1 second
sgTarget10.down = function (x, y, obj) {
// Destroy the sgTarget10 asset
this.destroy();
// Add 10 to the score
score += 10;
scoreTxt.setText(score);
// Create a text asset for the number 10
var number10 = new Text2('10', {
size: 75,
fill: "#ADD8E6" // Light blue color
});
// Position the number 10 at the same position as the sgTarget10 asset
number10.x = this.x - 40;
number10.y = this.y - 30;
// Add the number 10 to the game
game.addChild(number10);
// Make the number 10 flash for 1 second
var flashInterval = LK.setInterval(function () {
number10.visible = !number10.visible;
}, 100);
LK.setTimeout(function () {
LK.clearInterval(flashInterval);
number10.visible = true;
}, 1000);
// After 1 second, destroy the number 10
LK.setTimeout(function () {
number10.destroy();
}, 1000);
};
// Handle game updates
sgTarget25.update();
sgTarget100.update();
// Add a click event to the game to create a sgCrosshair asset at the clicked position
game.down = function (x, y, obj) {
// Create a sgCrosshair asset at the clicked position
var sgCrosshair = game.addChild(LK.getAsset('sgCrosshair', {
anchorX: 0.5,
anchorY: 0.5,
x: x,
y: y
}));
// Play bulletHit01 or bulletHit02 sound randomly
if (Math.random() > 0.5) {
LK.getSound('bulletHit01').play();
}
// After 0.5 second, destroy the sgCrosshair asset
LK.setTimeout(function () {
sgCrosshair.destroy();
}, 500);
};
;
;
wild west saloon piano real life. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
front facing western shooting gallery wooden frame. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white musical note on a empty background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western baked beans can. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western glass beer bottle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western shooting target with 5 written on it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western shooting target with 10 written on it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
vertical exploded glass beer bottle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
vertical red curtain. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pretty blond human cowgirl holding a sign. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western gold star with 25 written on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a western shining green diamond. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a cactus. The goal is to capture a lively and playful location.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a desert rock. The goal is to capture a lively and playful location.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a desert tumble weed. The goal is to capture a lively and playful location.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western barrel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon gecko with a cowboy hat. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon smoke puff. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western destroyed barrel. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cloud of smoke. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a single brown dust particle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western wanted poster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d western toy train side view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
train smoke. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western toy train wagon side profile. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a single wildvine with spikes and flowers dangling.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
J+G ingrained in a heart, on wood by a knife. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a western shooting gallery ranking charts written rookie (70) skilled(220) legendary (400). Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
wood bullet hole. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
empty western saloon, just the floor, ceiling and walls.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
front facing western shooting gallery wooden sign hanging from chains that is written "Whiskey Saloon". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
upper torso of a western cartoon barman getting ready to throw a bottle of whiskey.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western cowboy toy shooting. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western target dummy. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
grawlix in a speech bubble, make sure it looks something like this !#@* and theres an angry icon. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western bottle of whiskey.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
orange damage splash.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
cartoon pie drawn top view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
add an apron, add a bow in the hair, remove the hat
purple damage splash. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Tap to shoot! in a western style speech bubble.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Red x western inspired. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
western inspired letters that spell "Score". Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
saloonPianoJingle01
Sound effect
chainNoises
Sound effect
canHit
Sound effect
canHit02
Sound effect
glassHit01
Sound effect
glassHit02
Sound effect
bulletHit01
Sound effect
sgGeckoNoise
Sound effect
getSound02
Sound effect
getSound01
Sound effect
barreltHit01
Sound effect
sgSaloonMusic
Sound effect
sgYeehaw
Sound effect
sgTrainSound01
Sound effect
sgTrainsSound02
Sound effect
sgGrunt
Sound effect
sgRicochet
Sound effect
sgOof
Sound effect
sgfemaleoof
Sound effect
sgfemaleow
Sound effect
sgsquish
Sound effect