/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var Character = Container.expand(function (characterType) {
var self = Container.call(this);
var graphics = self.attachAsset(characterType, {
anchorX: 0.5,
anchorY: 0.5
});
self.animationTimer = 0;
self.bobDirection = 1;
self.update = function () {
// Idle bobbing animation
self.animationTimer += 0.05;
graphics.y = Math.sin(self.animationTimer) * 5;
// Slight scale breathing effect
var breathScale = 1 + Math.sin(self.animationTimer * 0.5) * 0.05;
graphics.scaleX = breathScale;
graphics.scaleY = breathScale;
};
self.down = function (x, y, obj) {
// Character interaction
tween(graphics, {
rotation: 0.2
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(graphics, {
rotation: 0
}, {
duration: 200,
easing: tween.easeIn
});
}
});
LK.getSound('pop').play();
};
return self;
});
var House = Container.expand(function (houseType, characterType) {
var self = Container.call(this);
// House background
var background = self.attachAsset(houseType, {
anchorX: 0.5,
anchorY: 0.5
});
// Character
var character = self.addChild(new Character(characterType));
character.x = 1024;
character.y = 600;
// Furniture array
self.furniture = [];
self.addFurniture = function (itemType, x, y) {
var item = self.addChild(new InteractiveItem(itemType));
item.x = x;
item.y = y;
self.furniture.push(item);
};
return self;
});
var InteractiveItem = Container.expand(function (itemType, color, width, height) {
var self = Container.call(this);
var graphics = self.attachAsset(itemType, {
anchorX: 0.5,
anchorY: 0.5
});
self.originalScale = 1;
self.isAnimating = false;
self.clickCount = 0;
self.down = function (x, y, obj) {
if (self.isAnimating) return;
self.isAnimating = true;
self.clickCount++;
// Scale animation
tween(graphics, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 150,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(graphics, {
scaleX: self.originalScale,
scaleY: self.originalScale
}, {
duration: 150,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isAnimating = false;
}
});
}
});
// Special interactions for multiple clicks
if (self.clickCount >= 3) {
self.clickCount = 0;
self.triggerSpecialEffect();
}
LK.getSound('click').play();
};
self.triggerSpecialEffect = function () {
// Tint flash effect
var originalTint = graphics.tint;
graphics.tint = 0xFFFFFF;
tween(graphics, {
tint: originalTint
}, {
duration: 500,
easing: tween.easeOut
});
LK.getSound('chime').play();
};
return self;
});
var MenuButton = Container.expand(function (text, houseType) {
var self = Container.call(this);
var bg = self.attachAsset('menuButton', {
anchorX: 0.5,
anchorY: 0.5
});
var label = new Text2(text, {
size: 40,
fill: '#FFFFFF'
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
self.houseType = houseType;
self.down = function (x, y, obj) {
tween(bg, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(bg, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeIn
});
}
});
if (self.houseType) {
showHouse(self.houseType);
} else {
showMainMenu();
}
LK.getSound('click').play();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Sound effects
// Menu elements
// Furniture items
// Characters
// House backgrounds
var currentState = 'menu';
var currentHouse = null;
var menuContainer = null;
var backButton = null;
// House configurations
var houseConfigs = {
'pangoHouse': {
character: 'pango',
furniture: [{
type: 'sofa',
x: 400,
y: 900
}, {
type: 'table',
x: 700,
y: 1000
}, {
type: 'lamp',
x: 200,
y: 700
}, {
type: 'bookshelf',
x: 1600,
y: 800
}, {
type: 'plant',
x: 1800,
y: 1100
}]
},
'piggyHouse': {
character: 'piggy',
furniture: [{
type: 'bed',
x: 300,
y: 800
}, {
type: 'chair',
x: 600,
y: 1000
}, {
type: 'table',
x: 1000,
y: 900
}, {
type: 'clock',
x: 1500,
y: 600
}, {
type: 'plant',
x: 1700,
y: 1000
}]
},
'rabbitHouse': {
character: 'rabbit',
furniture: [{
type: 'sofa',
x: 500,
y: 1000
}, {
type: 'bookshelf',
x: 1400,
y: 700
}, {
type: 'lamp',
x: 800,
y: 600
}, {
type: 'table',
x: 1200,
y: 1100
}, {
type: 'plant',
x: 300,
y: 900
}]
},
'squirrelHouse': {
character: 'squirrel',
furniture: [{
type: 'chair',
x: 400,
y: 900
}, {
type: 'table',
x: 700,
y: 1000
}, {
type: 'bookshelf',
x: 1500,
y: 800
}, {
type: 'lamp',
x: 1800,
y: 700
}, {
type: 'clock',
x: 200,
y: 600
}]
},
'foxHouse': {
character: 'fox',
furniture: [{
type: 'bed',
x: 350,
y: 800
}, {
type: 'sofa',
x: 800,
y: 1000
}, {
type: 'table',
x: 1300,
y: 900
}, {
type: 'plant',
x: 1600,
y: 1100
}, {
type: 'lamp',
x: 500,
y: 600
}]
}
};
function showMainMenu() {
currentState = 'menu';
// Clear current house
if (currentHouse) {
currentHouse.destroy();
currentHouse = null;
}
// Hide back button
if (backButton) {
backButton.visible = false;
}
// Create menu if it doesn't exist
if (!menuContainer) {
menuContainer = game.addChild(new Container());
var title = new Text2('Pango Land', {
size: 80,
fill: '#FFFFFF'
});
title.anchor.set(0.5, 0.5);
title.x = 1024;
title.y = 300;
menuContainer.addChild(title);
var subtitle = new Text2('Choose a house to visit!', {
size: 40,
fill: '#FFFFFF'
});
subtitle.anchor.set(0.5, 0.5);
subtitle.x = 1024;
subtitle.y = 400;
menuContainer.addChild(subtitle);
// House buttons
var buttonData = [{
text: "Pango's House",
type: 'pangoHouse'
}, {
text: "Piggy's House",
type: 'piggyHouse'
}, {
text: "Rabbit's House",
type: 'rabbitHouse'
}, {
text: "Squirrel's House",
type: 'squirrelHouse'
}, {
text: "Fox's House",
type: 'foxHouse'
}];
for (var i = 0; i < buttonData.length; i++) {
var button = menuContainer.addChild(new MenuButton(buttonData[i].text, buttonData[i].type));
button.x = 1024;
button.y = 600 + i * 120;
}
}
menuContainer.visible = true;
}
function showHouse(houseType) {
currentState = 'house';
// Hide menu
if (menuContainer) {
menuContainer.visible = false;
}
// Create house
var config = houseConfigs[houseType];
currentHouse = game.addChild(new House(houseType, config.character));
currentHouse.x = 1024;
currentHouse.y = 900;
// Add furniture
for (var i = 0; i < config.furniture.length; i++) {
var furnitureItem = config.furniture[i];
currentHouse.addFurniture(furnitureItem.type, furnitureItem.x, furnitureItem.y);
}
// Show back button
if (!backButton) {
backButton = game.addChild(new MenuButton('Back', null));
backButton.x = 200;
backButton.y = 150;
}
backButton.visible = true;
}
// Initialize game
showMainMenu();
game.update = function () {
// Game loop handled by individual object updates
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,386 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var Character = Container.expand(function (characterType) {
+ var self = Container.call(this);
+ var graphics = self.attachAsset(characterType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.animationTimer = 0;
+ self.bobDirection = 1;
+ self.update = function () {
+ // Idle bobbing animation
+ self.animationTimer += 0.05;
+ graphics.y = Math.sin(self.animationTimer) * 5;
+ // Slight scale breathing effect
+ var breathScale = 1 + Math.sin(self.animationTimer * 0.5) * 0.05;
+ graphics.scaleX = breathScale;
+ graphics.scaleY = breathScale;
+ };
+ self.down = function (x, y, obj) {
+ // Character interaction
+ tween(graphics, {
+ rotation: 0.2
+ }, {
+ duration: 200,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(graphics, {
+ rotation: 0
+ }, {
+ duration: 200,
+ easing: tween.easeIn
+ });
+ }
+ });
+ LK.getSound('pop').play();
+ };
+ return self;
+});
+var House = Container.expand(function (houseType, characterType) {
+ var self = Container.call(this);
+ // House background
+ var background = self.attachAsset(houseType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Character
+ var character = self.addChild(new Character(characterType));
+ character.x = 1024;
+ character.y = 600;
+ // Furniture array
+ self.furniture = [];
+ self.addFurniture = function (itemType, x, y) {
+ var item = self.addChild(new InteractiveItem(itemType));
+ item.x = x;
+ item.y = y;
+ self.furniture.push(item);
+ };
+ return self;
+});
+var InteractiveItem = Container.expand(function (itemType, color, width, height) {
+ var self = Container.call(this);
+ var graphics = self.attachAsset(itemType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.originalScale = 1;
+ self.isAnimating = false;
+ self.clickCount = 0;
+ self.down = function (x, y, obj) {
+ if (self.isAnimating) return;
+ self.isAnimating = true;
+ self.clickCount++;
+ // Scale animation
+ tween(graphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 150,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(graphics, {
+ scaleX: self.originalScale,
+ scaleY: self.originalScale
+ }, {
+ duration: 150,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.isAnimating = false;
+ }
+ });
+ }
+ });
+ // Special interactions for multiple clicks
+ if (self.clickCount >= 3) {
+ self.clickCount = 0;
+ self.triggerSpecialEffect();
+ }
+ LK.getSound('click').play();
+ };
+ self.triggerSpecialEffect = function () {
+ // Tint flash effect
+ var originalTint = graphics.tint;
+ graphics.tint = 0xFFFFFF;
+ tween(graphics, {
+ tint: originalTint
+ }, {
+ duration: 500,
+ easing: tween.easeOut
+ });
+ LK.getSound('chime').play();
+ };
+ return self;
+});
+var MenuButton = Container.expand(function (text, houseType) {
+ var self = Container.call(this);
+ var bg = self.attachAsset('menuButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var label = new Text2(text, {
+ size: 40,
+ fill: '#FFFFFF'
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ self.houseType = houseType;
+ self.down = function (x, y, obj) {
+ tween(bg, {
+ scaleX: 0.9,
+ scaleY: 0.9
+ }, {
+ duration: 100,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(bg, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ easing: tween.easeIn
+ });
+ }
+ });
+ if (self.houseType) {
+ showHouse(self.houseType);
+ } else {
+ showMainMenu();
+ }
+ LK.getSound('click').play();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87CEEB
+});
+
+/****
+* Game Code
+****/
+// Sound effects
+// Menu elements
+// Furniture items
+// Characters
+// House backgrounds
+var currentState = 'menu';
+var currentHouse = null;
+var menuContainer = null;
+var backButton = null;
+// House configurations
+var houseConfigs = {
+ 'pangoHouse': {
+ character: 'pango',
+ furniture: [{
+ type: 'sofa',
+ x: 400,
+ y: 900
+ }, {
+ type: 'table',
+ x: 700,
+ y: 1000
+ }, {
+ type: 'lamp',
+ x: 200,
+ y: 700
+ }, {
+ type: 'bookshelf',
+ x: 1600,
+ y: 800
+ }, {
+ type: 'plant',
+ x: 1800,
+ y: 1100
+ }]
+ },
+ 'piggyHouse': {
+ character: 'piggy',
+ furniture: [{
+ type: 'bed',
+ x: 300,
+ y: 800
+ }, {
+ type: 'chair',
+ x: 600,
+ y: 1000
+ }, {
+ type: 'table',
+ x: 1000,
+ y: 900
+ }, {
+ type: 'clock',
+ x: 1500,
+ y: 600
+ }, {
+ type: 'plant',
+ x: 1700,
+ y: 1000
+ }]
+ },
+ 'rabbitHouse': {
+ character: 'rabbit',
+ furniture: [{
+ type: 'sofa',
+ x: 500,
+ y: 1000
+ }, {
+ type: 'bookshelf',
+ x: 1400,
+ y: 700
+ }, {
+ type: 'lamp',
+ x: 800,
+ y: 600
+ }, {
+ type: 'table',
+ x: 1200,
+ y: 1100
+ }, {
+ type: 'plant',
+ x: 300,
+ y: 900
+ }]
+ },
+ 'squirrelHouse': {
+ character: 'squirrel',
+ furniture: [{
+ type: 'chair',
+ x: 400,
+ y: 900
+ }, {
+ type: 'table',
+ x: 700,
+ y: 1000
+ }, {
+ type: 'bookshelf',
+ x: 1500,
+ y: 800
+ }, {
+ type: 'lamp',
+ x: 1800,
+ y: 700
+ }, {
+ type: 'clock',
+ x: 200,
+ y: 600
+ }]
+ },
+ 'foxHouse': {
+ character: 'fox',
+ furniture: [{
+ type: 'bed',
+ x: 350,
+ y: 800
+ }, {
+ type: 'sofa',
+ x: 800,
+ y: 1000
+ }, {
+ type: 'table',
+ x: 1300,
+ y: 900
+ }, {
+ type: 'plant',
+ x: 1600,
+ y: 1100
+ }, {
+ type: 'lamp',
+ x: 500,
+ y: 600
+ }]
+ }
+};
+function showMainMenu() {
+ currentState = 'menu';
+ // Clear current house
+ if (currentHouse) {
+ currentHouse.destroy();
+ currentHouse = null;
+ }
+ // Hide back button
+ if (backButton) {
+ backButton.visible = false;
+ }
+ // Create menu if it doesn't exist
+ if (!menuContainer) {
+ menuContainer = game.addChild(new Container());
+ var title = new Text2('Pango Land', {
+ size: 80,
+ fill: '#FFFFFF'
+ });
+ title.anchor.set(0.5, 0.5);
+ title.x = 1024;
+ title.y = 300;
+ menuContainer.addChild(title);
+ var subtitle = new Text2('Choose a house to visit!', {
+ size: 40,
+ fill: '#FFFFFF'
+ });
+ subtitle.anchor.set(0.5, 0.5);
+ subtitle.x = 1024;
+ subtitle.y = 400;
+ menuContainer.addChild(subtitle);
+ // House buttons
+ var buttonData = [{
+ text: "Pango's House",
+ type: 'pangoHouse'
+ }, {
+ text: "Piggy's House",
+ type: 'piggyHouse'
+ }, {
+ text: "Rabbit's House",
+ type: 'rabbitHouse'
+ }, {
+ text: "Squirrel's House",
+ type: 'squirrelHouse'
+ }, {
+ text: "Fox's House",
+ type: 'foxHouse'
+ }];
+ for (var i = 0; i < buttonData.length; i++) {
+ var button = menuContainer.addChild(new MenuButton(buttonData[i].text, buttonData[i].type));
+ button.x = 1024;
+ button.y = 600 + i * 120;
+ }
+ }
+ menuContainer.visible = true;
+}
+function showHouse(houseType) {
+ currentState = 'house';
+ // Hide menu
+ if (menuContainer) {
+ menuContainer.visible = false;
+ }
+ // Create house
+ var config = houseConfigs[houseType];
+ currentHouse = game.addChild(new House(houseType, config.character));
+ currentHouse.x = 1024;
+ currentHouse.y = 900;
+ // Add furniture
+ for (var i = 0; i < config.furniture.length; i++) {
+ var furnitureItem = config.furniture[i];
+ currentHouse.addFurniture(furnitureItem.type, furnitureItem.x, furnitureItem.y);
+ }
+ // Show back button
+ if (!backButton) {
+ backButton = game.addChild(new MenuButton('Back', null));
+ backButton.x = 200;
+ backButton.y = 150;
+ }
+ backButton.visible = true;
+}
+// Initialize game
+showMainMenu();
+game.update = function () {
+ // Game loop handled by individual object updates
+};
\ No newline at end of file