/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x9acd32 // Different vomit green color
});
/****
* Game Code
****/
// Play vomit sound effect at the start of the game with increased volume
var vomitSound = LK.getSound('vomitSound');
vomitSound.volume = 1; // Set volume to maximum
vomitSound.play();
// Add clouds to the game
var clouds = [];
function createCloud(x, y, scaleX, scaleY) {
var cloud = game.addChild(LK.getAsset('vomitGreenCloud', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: scaleX,
scaleY: scaleY,
x: x,
y: y
}));
clouds.push(cloud);
return cloud;
}
createCloud(400, 300, 1.5, 1);
createCloud(1600, 500, 2, 1.5);
createCloud(1000, 1000, 1, 2);
createCloud(800, 1500, 1.2, 1.8);
createCloud(1200, 2000, 1.8, 1.2);
createCloud(600, 1800, 1.3, 1.3);
createCloud(1400, 2200, 1.7, 1.1);
function moveClouds() {
clouds.forEach(function (cloud) {
cloud.x += 3; // Move clouds to the right faster
if (cloud.x > 2048) {
// If cloud goes off screen, reset its position
cloud.x = -cloud.width;
}
});
}
LK.setInterval(moveClouds, 100);
function spawnNewCloud() {
var x = -200; // Start off screen
var y = Math.random() * 2732;
var scaleX = 1 + Math.random();
var scaleY = 1 + Math.random();
createCloud(x, y, scaleX, scaleY);
}
LK.setInterval(spawnNewCloud, 5000);
// Add rockyvomit asset as decoration
var rockyvomitDecoration = game.addChild(LK.getAsset('rockyvomit', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1,
scaleY: 1,
x: 40,
// Move slightly further to the right
y: 40 // Move slightly further down
}));
// Function to spawn Spongy asset
function spawnSpongy() {
var spongy = game.addChild(LK.getAsset('spongy', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: Math.random() * 2048,
y: Math.random() * 2732
}));
// Function to move Spongy to a random position every 3 seconds
function moveSpongy() {
// Generate random x and y coordinates within the game area
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Use the tween plugin to move Spongy to the new position over 3 seconds
tween(spongy, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
// Rotate Spongy to a random direction
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
// Set a timeout to move Spongy again in 3 seconds
LK.setTimeout(moveSpongy, 3000);
}
// Start moving Spongy
moveSpongy();
// Add a counter to track touches
spongy.touchCount = 0;
// Add a mouse down event to Spongy to make it disappear after two touches
spongy.down = function () {
this.touchCount++;
if (this.touchCount >= 2) {
this.destroy();
}
};
}
// Set an interval to spawn Spongy every 10 seconds
LK.setInterval(spawnSpongy, 10000);
// Function to spawn BarfBag asset
function spawnBarfBag() {
var barfBag = game.addChild(LK.getAsset('BarfBag', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: Math.random() * 2048,
y: Math.random() * 2732
}));
// Function to move BarfBag to a random position every 3 seconds
function moveBarfBag() {
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
tween(barfBag, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
LK.setTimeout(moveBarfBag, 3000);
}
// Start moving BarfBag
moveBarfBag();
// Add a counter to track touches
barfBag.touchCount = 0;
// Add a mouse down event to BarfBag to make it disappear after three touches
barfBag.down = function () {
this.touchCount++;
if (this.touchCount >= 3) {
this.destroy();
}
};
}
// Set an interval to spawn BarfBag every 30 seconds
LK.setInterval(spawnBarfBag, 30000);
// Import the tween plugin
// Create a global variable to keep track of the number of Rocky assets
var rockyCount = 3;
// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
var rocky = game.addChild(LK.getAsset('Rocky', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: 950,
y: 800
}));
// Create a function to move Rocky to a random position every 3 seconds
function moveRocky() {
// Generate random x and y coordinates within the game area
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Use the tween plugin to move Rocky to the new position over 3 seconds
tween(rocky, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
// Rotate Rocky to a random direction
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
// Set a timeout to move Rocky again in 3 seconds
LK.setTimeout(moveRocky, 3000);
}
// Start moving Rocky
moveRocky();
// Add a mouse down event to Rocky to make it disappear when clicked
rocky.down = function () {
this.visible = false;
rockyCount--;
if (rockyCount === 0) {
rockyCount += 2;
addRocky();
}
};
// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
var rocky2 = game.addChild(LK.getAsset('Rocky', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: 500,
y: 400
}));
// Add a mouse down event to Rocky2 to make it disappear when clicked
rocky2.down = function () {
this.visible = false;
rockyCount--;
if (rockyCount === 0) {
rockyCount += 2;
addRocky();
}
};
// Create a function to move the second Rocky to a random position every 3 seconds
function moveRocky2() {
// Generate random x and y coordinates within the game area
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Use the tween plugin to move Rocky to the new position over 3 seconds
tween(rocky2, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
// Rotate Rocky to a random direction
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
// Set a timeout to move Rocky again in 3 seconds
LK.setTimeout(moveRocky2, 3000);
}
// Start moving the second Rocky
moveRocky2();
// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
var rocky3 = game.addChild(LK.getAsset('Rocky', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: 300,
y: 200
}));
// Add a mouse down event to Rocky3 to make it disappear when clicked
rocky3.down = function () {
this.visible = false;
rockyCount--;
if (rockyCount === 0) {
rockyCount += 2;
addRocky();
}
};
// Create a function to move the third Rocky to a random position every 3 seconds
function moveRocky3() {
// Generate random x and y coordinates within the game area
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Use the tween plugin to move Rocky to the new position over 3 seconds
tween(rocky3, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
// Rotate Rocky to a random direction
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
// Set a timeout to move Rocky again in 3 seconds
LK.setTimeout(moveRocky3, 3000);
}
// Start moving the third Rocky
moveRocky3();
// Create a function to add new Rocky assets
function addRocky() {
var _loop = function _loop() {
newRocky = game.addChild(LK.getAsset('Rocky', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 4,
scaleY: 4,
x: Math.random() * 2048,
y: Math.random() * 2732
}));
newRocky.down = function () {
this.visible = false;
rockyCount--;
if (rockyCount === 0) {
rockyCount += 2;
addRocky();
}
};
// Create a function to move the new Rocky to a random position every 3 seconds
function moveNewRocky(newRocky) {
// Generate random x and y coordinates within the game area
var randomX = Math.random() * 2048;
var randomY = Math.random() * 2732;
// Use the tween plugin to move Rocky to the new position over 3 seconds
tween(newRocky, {
x: randomX,
y: randomY,
rotation: Math.random() * Math.PI * 2,
// Rotate Rocky to a random direction
onUpdate: function onUpdate() {}
}, {
duration: 3000
});
// Set a timeout to move Rocky again in 3 seconds
LK.setTimeout(function () {
moveNewRocky(newRocky);
}, 3000);
}
moveNewRocky(newRocky);
},
newRocky;
for (var i = 0; i < rockyCount; i++) {
_loop();
}
} ===================================================================
--- original.js
+++ change.js
@@ -1,115 +1,311 @@
-/****
-* Classes
-****/
-// Define a class for bullets
-var Bullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('bullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = -15;
- self.update = function () {
- self.y += self.speed;
- if (self.y < 0) {
- self.destroy();
- }
- };
-});
-// Define a class for enemies
-var Enemy = Container.expand(function () {
- var self = Container.call(this);
- var enemyGraphics = self.attachAsset('enemy', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 5;
- self.update = function () {
- self.y += self.speed;
- if (self.y > 2732) {
- self.y = 0;
- self.x = Math.random() * 2048;
- }
- };
-});
-//<Assets used in the game will automatically appear here>
-//<Write imports for supported plugins here>
-// Define a class for the player character
-var Player = Container.expand(function () {
- var self = Container.call(this);
- var playerGraphics = self.attachAsset('player', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.speed = 10;
- self.update = function () {
- // Player update logic
- };
-});
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x9acd32 // Different vomit green color
});
-/****
+/****
* Game Code
-****/
-// Initialize player
-var player = game.addChild(new Player());
-player.x = 1024;
-player.y = 2500;
-// Initialize enemies
-var enemies = [];
-for (var i = 0; i < 5; i++) {
- var enemy = new Enemy();
- enemy.x = Math.random() * 2048;
- enemy.y = Math.random() * 1000;
- enemies.push(enemy);
- game.addChild(enemy);
+****/
+// Play vomit sound effect at the start of the game with increased volume
+var vomitSound = LK.getSound('vomitSound');
+vomitSound.volume = 1; // Set volume to maximum
+vomitSound.play();
+// Add clouds to the game
+var clouds = [];
+function createCloud(x, y, scaleX, scaleY) {
+ var cloud = game.addChild(LK.getAsset('vomitGreenCloud', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: scaleX,
+ scaleY: scaleY,
+ x: x,
+ y: y
+ }));
+ clouds.push(cloud);
+ return cloud;
}
-// Initialize bullets
-var bullets = [];
-// Handle player movement
-game.move = function (x, y, obj) {
- player.x = x;
- player.y = y;
+createCloud(400, 300, 1.5, 1);
+createCloud(1600, 500, 2, 1.5);
+createCloud(1000, 1000, 1, 2);
+createCloud(800, 1500, 1.2, 1.8);
+createCloud(1200, 2000, 1.8, 1.2);
+createCloud(600, 1800, 1.3, 1.3);
+createCloud(1400, 2200, 1.7, 1.1);
+function moveClouds() {
+ clouds.forEach(function (cloud) {
+ cloud.x += 3; // Move clouds to the right faster
+ if (cloud.x > 2048) {
+ // If cloud goes off screen, reset its position
+ cloud.x = -cloud.width;
+ }
+ });
+}
+LK.setInterval(moveClouds, 100);
+function spawnNewCloud() {
+ var x = -200; // Start off screen
+ var y = Math.random() * 2732;
+ var scaleX = 1 + Math.random();
+ var scaleY = 1 + Math.random();
+ createCloud(x, y, scaleX, scaleY);
+}
+LK.setInterval(spawnNewCloud, 5000);
+// Add rockyvomit asset as decoration
+var rockyvomitDecoration = game.addChild(LK.getAsset('rockyvomit', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1,
+ scaleY: 1,
+ x: 40,
+ // Move slightly further to the right
+ y: 40 // Move slightly further down
+}));
+// Function to spawn Spongy asset
+function spawnSpongy() {
+ var spongy = game.addChild(LK.getAsset('spongy', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: Math.random() * 2048,
+ y: Math.random() * 2732
+ }));
+ // Function to move Spongy to a random position every 3 seconds
+ function moveSpongy() {
+ // Generate random x and y coordinates within the game area
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ // Use the tween plugin to move Spongy to the new position over 3 seconds
+ tween(spongy, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ // Rotate Spongy to a random direction
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ // Set a timeout to move Spongy again in 3 seconds
+ LK.setTimeout(moveSpongy, 3000);
+ }
+ // Start moving Spongy
+ moveSpongy();
+ // Add a counter to track touches
+ spongy.touchCount = 0;
+ // Add a mouse down event to Spongy to make it disappear after two touches
+ spongy.down = function () {
+ this.touchCount++;
+ if (this.touchCount >= 2) {
+ this.destroy();
+ }
+ };
+}
+// Set an interval to spawn Spongy every 10 seconds
+LK.setInterval(spawnSpongy, 10000);
+// Function to spawn BarfBag asset
+function spawnBarfBag() {
+ var barfBag = game.addChild(LK.getAsset('BarfBag', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: Math.random() * 2048,
+ y: Math.random() * 2732
+ }));
+ // Function to move BarfBag to a random position every 3 seconds
+ function moveBarfBag() {
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ tween(barfBag, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ LK.setTimeout(moveBarfBag, 3000);
+ }
+ // Start moving BarfBag
+ moveBarfBag();
+ // Add a counter to track touches
+ barfBag.touchCount = 0;
+ // Add a mouse down event to BarfBag to make it disappear after three touches
+ barfBag.down = function () {
+ this.touchCount++;
+ if (this.touchCount >= 3) {
+ this.destroy();
+ }
+ };
+}
+// Set an interval to spawn BarfBag every 30 seconds
+LK.setInterval(spawnBarfBag, 30000);
+// Import the tween plugin
+// Create a global variable to keep track of the number of Rocky assets
+var rockyCount = 3;
+// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
+var rocky = game.addChild(LK.getAsset('Rocky', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: 950,
+ y: 800
+}));
+// Create a function to move Rocky to a random position every 3 seconds
+function moveRocky() {
+ // Generate random x and y coordinates within the game area
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ // Use the tween plugin to move Rocky to the new position over 3 seconds
+ tween(rocky, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ // Rotate Rocky to a random direction
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ // Set a timeout to move Rocky again in 3 seconds
+ LK.setTimeout(moveRocky, 3000);
+}
+// Start moving Rocky
+moveRocky();
+// Add a mouse down event to Rocky to make it disappear when clicked
+rocky.down = function () {
+ this.visible = false;
+ rockyCount--;
+ if (rockyCount === 0) {
+ rockyCount += 2;
+ addRocky();
+ }
};
-// Handle shooting
-game.down = function (x, y, obj) {
- var bullet = new Bullet();
- bullet.x = player.x;
- bullet.y = player.y;
- bullets.push(bullet);
- game.addChild(bullet);
+// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
+var rocky2 = game.addChild(LK.getAsset('Rocky', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: 500,
+ y: 400
+}));
+// Add a mouse down event to Rocky2 to make it disappear when clicked
+rocky2.down = function () {
+ this.visible = false;
+ rockyCount--;
+ if (rockyCount === 0) {
+ rockyCount += 2;
+ addRocky();
+ }
};
-// Update game state
-game.update = function () {
- // Update enemies
- enemies.forEach(function (enemy) {
- enemy.update();
- if (player.intersects(enemy)) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- }
- });
- // Update bullets
- bullets.forEach(function (bullet, index) {
- bullet.update();
- enemies.forEach(function (enemy, enemyIndex) {
- if (bullet.intersects(enemy)) {
- bullet.destroy();
- bullets.splice(index, 1);
- enemy.destroy();
- enemies.splice(enemyIndex, 1);
- LK.setScore(LK.getScore() + 1);
- }
- });
- });
- // Check win condition
- if (LK.getScore() >= 10) {
- LK.showYouWin();
- }
-};
\ No newline at end of file
+// Create a function to move the second Rocky to a random position every 3 seconds
+function moveRocky2() {
+ // Generate random x and y coordinates within the game area
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ // Use the tween plugin to move Rocky to the new position over 3 seconds
+ tween(rocky2, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ // Rotate Rocky to a random direction
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ // Set a timeout to move Rocky again in 3 seconds
+ LK.setTimeout(moveRocky2, 3000);
+}
+// Start moving the second Rocky
+moveRocky2();
+// Retrieve the 'Rocky' asset, make it 2x bigger, and add it to the game
+var rocky3 = game.addChild(LK.getAsset('Rocky', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: 300,
+ y: 200
+}));
+// Add a mouse down event to Rocky3 to make it disappear when clicked
+rocky3.down = function () {
+ this.visible = false;
+ rockyCount--;
+ if (rockyCount === 0) {
+ rockyCount += 2;
+ addRocky();
+ }
+};
+// Create a function to move the third Rocky to a random position every 3 seconds
+function moveRocky3() {
+ // Generate random x and y coordinates within the game area
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ // Use the tween plugin to move Rocky to the new position over 3 seconds
+ tween(rocky3, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ // Rotate Rocky to a random direction
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ // Set a timeout to move Rocky again in 3 seconds
+ LK.setTimeout(moveRocky3, 3000);
+}
+// Start moving the third Rocky
+moveRocky3();
+// Create a function to add new Rocky assets
+function addRocky() {
+ var _loop = function _loop() {
+ newRocky = game.addChild(LK.getAsset('Rocky', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 4,
+ scaleY: 4,
+ x: Math.random() * 2048,
+ y: Math.random() * 2732
+ }));
+ newRocky.down = function () {
+ this.visible = false;
+ rockyCount--;
+ if (rockyCount === 0) {
+ rockyCount += 2;
+ addRocky();
+ }
+ };
+ // Create a function to move the new Rocky to a random position every 3 seconds
+ function moveNewRocky(newRocky) {
+ // Generate random x and y coordinates within the game area
+ var randomX = Math.random() * 2048;
+ var randomY = Math.random() * 2732;
+ // Use the tween plugin to move Rocky to the new position over 3 seconds
+ tween(newRocky, {
+ x: randomX,
+ y: randomY,
+ rotation: Math.random() * Math.PI * 2,
+ // Rotate Rocky to a random direction
+ onUpdate: function onUpdate() {}
+ }, {
+ duration: 3000
+ });
+ // Set a timeout to move Rocky again in 3 seconds
+ LK.setTimeout(function () {
+ moveNewRocky(newRocky);
+ }, 3000);
+ }
+ moveNewRocky(newRocky);
+ },
+ newRocky;
+ for (var i = 0; i < rockyCount; i++) {
+ _loop();
+ }
+}
\ No newline at end of file