/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Acid = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('acid', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = 1;
self.speed = 2;
self.lastX = 0;
self.update = function () {
self.lastX = self.x;
self.x += self.direction * self.speed;
if (self.x <= 75 || self.x >= 1973) {
self.direction *= -1;
}
};
return self;
});
var Animal = Container.expand(function (type) {
var self = Container.call(this);
self.animalType = type;
self.isSelected = false;
self.speed = 3;
self.lastX = 0;
self.lastY = 0;
var graphics = self.attachAsset(type, {
anchorX: 0.5,
anchorY: 0.5
});
// Animal specific properties
if (type === 'owl' || type === 'crow') {
self.canFly = true;
self.speed = 4;
} else if (type === 'shark' || type === 'otter') {
self.canSwim = true;
self.speed = 5;
} else if (type === 'bear' || type === 'trex') {
self.hasStrength = true;
self.speed = 2;
}
self.select = function () {
self.isSelected = true;
graphics.tint = 0xFFFFFF;
tween(graphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200
});
};
self.deselect = function () {
self.isSelected = false;
graphics.tint = 0xFFFFFF;
tween(graphics, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200
});
};
self.moveTo = function (targetX, targetY) {
var dx = targetX - self.x;
var dy = targetY - self.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 5) {
self.x += dx / distance * self.speed;
self.y += dy / distance * self.speed;
}
};
self.update = function () {
self.lastX = self.x;
self.lastY = self.y;
// Keep animals within bounds
if (self.x < 50) self.x = 50;
if (self.x > 1998) self.x = 1998;
if (self.y < 50) self.y = 50;
if (self.y > 2682) self.y = 2682;
};
return self;
});
var Collectible = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('collectible', {
anchorX: 0.5,
anchorY: 0.5
});
self.collected = false;
self.pulse = 0;
self.update = function () {
if (!self.collected) {
self.pulse += 0.1;
graphics.scaleX = 1 + Math.sin(self.pulse) * 0.2;
graphics.scaleY = 1 + Math.sin(self.pulse) * 0.2;
}
};
self.collect = function () {
if (!self.collected) {
self.collected = true;
LK.getSound('collect').play();
tween(graphics, {
alpha: 0,
scaleX: 2,
scaleY: 2
}, {
duration: 300
});
}
};
return self;
});
var Wall = Container.expand(function () {
var self = Container.call(this);
var graphics = self.attachAsset('wall', {
anchorX: 0.5,
anchorY: 0.5
});
self.direction = 1;
self.speed = 1;
self.lastY = 0;
self.update = function () {
self.lastY = self.y;
self.y += self.direction * self.speed;
if (self.y <= 100 || self.y >= 2632) {
self.direction *= -1;
}
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x2F1B14
});
/****
* Game Code
****/
// Game variables
var animals = [];
var animalTypes = ['koala', 'otter', 'bear', 'trex', 'lion', 'owl', 'crow', 'shark', 'cow'];
var selectedAnimal = null;
var selectedIndex = 0;
var targetX = 0;
var targetY = 0;
var isMoving = false;
var acids = [];
var walls = [];
var collectibles = [];
var collectiblesFound = 0;
var totalCollectibles = 6;
var currentLevel = 1;
var animalsEscaped = 0;
// Background
var background = game.attachAsset('stomach_bg', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Create exit
var exit = game.attachAsset('exit', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 150
});
// Create animals
for (var i = 0; i < animalTypes.length; i++) {
var animal = new Animal(animalTypes[i]);
animal.x = 200 + i % 3 * 150;
animal.y = 2400 + Math.floor(i / 3) * 100;
animals.push(animal);
game.addChild(animal);
}
// Select first animal
selectedAnimal = animals[0];
selectedAnimal.select();
// Create hazards
for (var i = 0; i < 4; i++) {
var acid = new Acid();
acid.x = 200 + i * 400;
acid.y = 800 + i * 300;
acids.push(acid);
game.addChild(acid);
}
for (var i = 0; i < 3; i++) {
var wall = new Wall();
wall.x = 300 + i * 600;
wall.y = 1200 + i * 200;
walls.push(wall);
game.addChild(wall);
}
// Create collectibles
for (var i = 0; i < totalCollectibles; i++) {
var collectible = new Collectible();
collectible.x = 300 + i % 2 * 1400;
collectible.y = 600 + Math.floor(i / 2) * 400;
collectibles.push(collectible);
game.addChild(collectible);
}
// UI
var instructionText = new Text2('Tap to select animal, tap again to move', {
size: 60,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.top.addChild(instructionText);
var scoreText = new Text2('Collectibles: 0/' + totalCollectibles, {
size: 80,
fill: 0xFFD700
});
scoreText.anchor.set(0, 0);
scoreText.x = 150;
scoreText.y = 100;
LK.gui.topLeft.addChild(scoreText);
var animalText = new Text2('Animal: ' + selectedAnimal.animalType.toUpperCase(), {
size: 70,
fill: 0x87CEEB
});
animalText.anchor.set(1, 0);
LK.gui.topRight.addChild(animalText);
// Event handlers
game.down = function (x, y, obj) {
// Check if clicking on an animal
var clickedAnimal = null;
for (var i = 0; i < animals.length; i++) {
var animal = animals[i];
var dx = x - animal.x;
var dy = y - animal.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 50) {
clickedAnimal = animal;
break;
}
}
if (clickedAnimal) {
// Select new animal
if (selectedAnimal) {
selectedAnimal.deselect();
}
selectedAnimal = clickedAnimal;
selectedAnimal.select();
selectedIndex = animals.indexOf(selectedAnimal);
animalText.setText('Animal: ' + selectedAnimal.animalType.toUpperCase());
LK.getSound('switch').play();
} else {
// Move selected animal
if (selectedAnimal) {
targetX = x;
targetY = y;
isMoving = true;
}
}
};
// Game update loop
game.update = function () {
// Move selected animal
if (isMoving && selectedAnimal) {
selectedAnimal.moveTo(targetX, targetY);
var dx = targetX - selectedAnimal.x;
var dy = targetY - selectedAnimal.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 10) {
isMoving = false;
}
}
// Check collisions with acids
for (var i = 0; i < acids.length; i++) {
var acid = acids[i];
for (var j = 0; j < animals.length; j++) {
var animal = animals[j];
if (animal.intersects(acid)) {
// Reset animal position
animal.x = 200 + j % 3 * 150;
animal.y = 2400 + Math.floor(j / 3) * 100;
LK.getSound('danger').play();
LK.effects.flashScreen(0xFF0000, 500);
break;
}
}
}
// Check collisions with walls
for (var i = 0; i < walls.length; i++) {
var wall = walls[i];
for (var j = 0; j < animals.length; j++) {
var animal = animals[j];
if (animal.intersects(wall)) {
// Push animal away from wall
var dx = animal.x - wall.x;
var dy = animal.y - wall.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > 0) {
animal.x = wall.x + dx / distance * 100;
animal.y = wall.y + dy / distance * 100;
}
}
}
}
// Check collectible collection
for (var i = 0; i < collectibles.length; i++) {
var collectible = collectibles[i];
if (!collectible.collected) {
for (var j = 0; j < animals.length; j++) {
var animal = animals[j];
if (animal.intersects(collectible)) {
collectible.collect();
collectiblesFound++;
scoreText.setText('Collectibles: ' + collectiblesFound + '/' + totalCollectibles);
break;
}
}
}
}
// Check exit condition
if (collectiblesFound >= totalCollectibles) {
for (var i = 0; i < animals.length; i++) {
var animal = animals[i];
if (animal.intersects(exit)) {
animalsEscaped++;
animal.x = -100; // Move off screen
animal.y = -100;
if (animalsEscaped >= animals.length) {
LK.setScore(100);
LK.showYouWin();
}
break;
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,340 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Acid = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('acid', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.direction = 1;
+ self.speed = 2;
+ self.lastX = 0;
+ self.update = function () {
+ self.lastX = self.x;
+ self.x += self.direction * self.speed;
+ if (self.x <= 75 || self.x >= 1973) {
+ self.direction *= -1;
+ }
+ };
+ return self;
+});
+var Animal = Container.expand(function (type) {
+ var self = Container.call(this);
+ self.animalType = type;
+ self.isSelected = false;
+ self.speed = 3;
+ self.lastX = 0;
+ self.lastY = 0;
+ var graphics = self.attachAsset(type, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Animal specific properties
+ if (type === 'owl' || type === 'crow') {
+ self.canFly = true;
+ self.speed = 4;
+ } else if (type === 'shark' || type === 'otter') {
+ self.canSwim = true;
+ self.speed = 5;
+ } else if (type === 'bear' || type === 'trex') {
+ self.hasStrength = true;
+ self.speed = 2;
+ }
+ self.select = function () {
+ self.isSelected = true;
+ graphics.tint = 0xFFFFFF;
+ tween(graphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 200
+ });
+ };
+ self.deselect = function () {
+ self.isSelected = false;
+ graphics.tint = 0xFFFFFF;
+ tween(graphics, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 200
+ });
+ };
+ self.moveTo = function (targetX, targetY) {
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 5) {
+ self.x += dx / distance * self.speed;
+ self.y += dy / distance * self.speed;
+ }
+ };
+ self.update = function () {
+ self.lastX = self.x;
+ self.lastY = self.y;
+ // Keep animals within bounds
+ if (self.x < 50) self.x = 50;
+ if (self.x > 1998) self.x = 1998;
+ if (self.y < 50) self.y = 50;
+ if (self.y > 2682) self.y = 2682;
+ };
+ return self;
+});
+var Collectible = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('collectible', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.collected = false;
+ self.pulse = 0;
+ self.update = function () {
+ if (!self.collected) {
+ self.pulse += 0.1;
+ graphics.scaleX = 1 + Math.sin(self.pulse) * 0.2;
+ graphics.scaleY = 1 + Math.sin(self.pulse) * 0.2;
+ }
+ };
+ self.collect = function () {
+ if (!self.collected) {
+ self.collected = true;
+ LK.getSound('collect').play();
+ tween(graphics, {
+ alpha: 0,
+ scaleX: 2,
+ scaleY: 2
+ }, {
+ duration: 300
+ });
+ }
+ };
+ return self;
+});
+var Wall = Container.expand(function () {
+ var self = Container.call(this);
+ var graphics = self.attachAsset('wall', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.direction = 1;
+ self.speed = 1;
+ self.lastY = 0;
+ self.update = function () {
+ self.lastY = self.y;
+ self.y += self.direction * self.speed;
+ if (self.y <= 100 || self.y >= 2632) {
+ self.direction *= -1;
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x2F1B14
+});
+
+/****
+* Game Code
+****/
+// Game variables
+var animals = [];
+var animalTypes = ['koala', 'otter', 'bear', 'trex', 'lion', 'owl', 'crow', 'shark', 'cow'];
+var selectedAnimal = null;
+var selectedIndex = 0;
+var targetX = 0;
+var targetY = 0;
+var isMoving = false;
+var acids = [];
+var walls = [];
+var collectibles = [];
+var collectiblesFound = 0;
+var totalCollectibles = 6;
+var currentLevel = 1;
+var animalsEscaped = 0;
+// Background
+var background = game.attachAsset('stomach_bg', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0
+});
+// Create exit
+var exit = game.attachAsset('exit', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 150
+});
+// Create animals
+for (var i = 0; i < animalTypes.length; i++) {
+ var animal = new Animal(animalTypes[i]);
+ animal.x = 200 + i % 3 * 150;
+ animal.y = 2400 + Math.floor(i / 3) * 100;
+ animals.push(animal);
+ game.addChild(animal);
+}
+// Select first animal
+selectedAnimal = animals[0];
+selectedAnimal.select();
+// Create hazards
+for (var i = 0; i < 4; i++) {
+ var acid = new Acid();
+ acid.x = 200 + i * 400;
+ acid.y = 800 + i * 300;
+ acids.push(acid);
+ game.addChild(acid);
+}
+for (var i = 0; i < 3; i++) {
+ var wall = new Wall();
+ wall.x = 300 + i * 600;
+ wall.y = 1200 + i * 200;
+ walls.push(wall);
+ game.addChild(wall);
+}
+// Create collectibles
+for (var i = 0; i < totalCollectibles; i++) {
+ var collectible = new Collectible();
+ collectible.x = 300 + i % 2 * 1400;
+ collectible.y = 600 + Math.floor(i / 2) * 400;
+ collectibles.push(collectible);
+ game.addChild(collectible);
+}
+// UI
+var instructionText = new Text2('Tap to select animal, tap again to move', {
+ size: 60,
+ fill: 0xFFFFFF
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.top.addChild(instructionText);
+var scoreText = new Text2('Collectibles: 0/' + totalCollectibles, {
+ size: 80,
+ fill: 0xFFD700
+});
+scoreText.anchor.set(0, 0);
+scoreText.x = 150;
+scoreText.y = 100;
+LK.gui.topLeft.addChild(scoreText);
+var animalText = new Text2('Animal: ' + selectedAnimal.animalType.toUpperCase(), {
+ size: 70,
+ fill: 0x87CEEB
+});
+animalText.anchor.set(1, 0);
+LK.gui.topRight.addChild(animalText);
+// Event handlers
+game.down = function (x, y, obj) {
+ // Check if clicking on an animal
+ var clickedAnimal = null;
+ for (var i = 0; i < animals.length; i++) {
+ var animal = animals[i];
+ var dx = x - animal.x;
+ var dy = y - animal.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 50) {
+ clickedAnimal = animal;
+ break;
+ }
+ }
+ if (clickedAnimal) {
+ // Select new animal
+ if (selectedAnimal) {
+ selectedAnimal.deselect();
+ }
+ selectedAnimal = clickedAnimal;
+ selectedAnimal.select();
+ selectedIndex = animals.indexOf(selectedAnimal);
+ animalText.setText('Animal: ' + selectedAnimal.animalType.toUpperCase());
+ LK.getSound('switch').play();
+ } else {
+ // Move selected animal
+ if (selectedAnimal) {
+ targetX = x;
+ targetY = y;
+ isMoving = true;
+ }
+ }
+};
+// Game update loop
+game.update = function () {
+ // Move selected animal
+ if (isMoving && selectedAnimal) {
+ selectedAnimal.moveTo(targetX, targetY);
+ var dx = targetX - selectedAnimal.x;
+ var dy = targetY - selectedAnimal.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 10) {
+ isMoving = false;
+ }
+ }
+ // Check collisions with acids
+ for (var i = 0; i < acids.length; i++) {
+ var acid = acids[i];
+ for (var j = 0; j < animals.length; j++) {
+ var animal = animals[j];
+ if (animal.intersects(acid)) {
+ // Reset animal position
+ animal.x = 200 + j % 3 * 150;
+ animal.y = 2400 + Math.floor(j / 3) * 100;
+ LK.getSound('danger').play();
+ LK.effects.flashScreen(0xFF0000, 500);
+ break;
+ }
+ }
+ }
+ // Check collisions with walls
+ for (var i = 0; i < walls.length; i++) {
+ var wall = walls[i];
+ for (var j = 0; j < animals.length; j++) {
+ var animal = animals[j];
+ if (animal.intersects(wall)) {
+ // Push animal away from wall
+ var dx = animal.x - wall.x;
+ var dy = animal.y - wall.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance > 0) {
+ animal.x = wall.x + dx / distance * 100;
+ animal.y = wall.y + dy / distance * 100;
+ }
+ }
+ }
+ }
+ // Check collectible collection
+ for (var i = 0; i < collectibles.length; i++) {
+ var collectible = collectibles[i];
+ if (!collectible.collected) {
+ for (var j = 0; j < animals.length; j++) {
+ var animal = animals[j];
+ if (animal.intersects(collectible)) {
+ collectible.collect();
+ collectiblesFound++;
+ scoreText.setText('Collectibles: ' + collectiblesFound + '/' + totalCollectibles);
+ break;
+ }
+ }
+ }
+ }
+ // Check exit condition
+ if (collectiblesFound >= totalCollectibles) {
+ for (var i = 0; i < animals.length; i++) {
+ var animal = animals[i];
+ if (animal.intersects(exit)) {
+ animalsEscaped++;
+ animal.x = -100; // Move off screen
+ animal.y = -100;
+ if (animalsEscaped >= animals.length) {
+ LK.setScore(100);
+ LK.showYouWin();
+ }
+ break;
+ }
+ }
+ }
+};
\ No newline at end of file