User prompt
Face Camera call button of picking two we pick 4 and we show our face and also add John and Bob βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Can you make the text bigger
User prompt
You can add another player to it the max limit is 10
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 145
User prompt
Code the button of join chat you have to press a random name to chat with or you can pick two of them and you chat with two
User prompt
Fix it
User prompt
Just code It in
User prompt
Add some music
Code edit (1 edits merged)
Please save this source code
User prompt
Wii Menu Simulator
Initial prompt
Wii menu
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var ChatUser = Container.expand(function (userName) {
var self = Container.call(this);
var button = self.attachAsset('userButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.userName = userName;
self.isSelected = false;
var nameText = new Text2(userName, {
size: 30,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
self.addChild(nameText);
self.select = function () {
if (self.isSelected) return;
self.isSelected = true;
button.tint = 0x4CAF50;
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut
});
};
self.deselect = function () {
if (!self.isSelected) return;
self.isSelected = false;
button.tint = 0x1976D2;
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.easeOut
});
};
self.down = function (x, y, obj) {
if (chatMode === 'userSelection') {
if (self.isSelected) {
self.deselect();
var index = selectedChatUsers.indexOf(self);
if (index > -1) {
selectedChatUsers.splice(index, 1);
}
} else {
if (selectedChatUsers.length < 2) {
self.select();
selectedChatUsers.push(self);
}
}
updateStartChatButton();
}
};
return self;
});
var ChatWindow = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('chatWindow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95
});
var messageArea = self.attachAsset('messageBox', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
self.messages = [];
self.messageTexts = [];
var closeButton = self.attachAsset('sendButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: -500
});
var closeText = new Text2('Close', {
size: 25,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 700;
closeText.y = -500;
self.addChild(closeText);
var chatTitleText = new Text2('Chat Room', {
size: 40,
fill: 0xFFFFFF
});
chatTitleText.anchor.set(0.5, 0.5);
chatTitleText.y = -550;
self.addChild(chatTitleText);
self.addMessage = function (userName, message) {
var messageText = userName + ": " + message;
self.messages.push(messageText);
var textObj = new Text2(messageText, {
size: 25,
fill: 0xFFFFFF
});
textObj.anchor.set(0, 0.5);
textObj.x = -750;
textObj.y = -400 + self.messageTexts.length * 40;
self.addChild(textObj);
self.messageTexts.push(textObj);
// Keep only last 15 messages
if (self.messageTexts.length > 15) {
var oldText = self.messageTexts.shift();
self.removeChild(oldText);
// Move remaining messages up
for (var i = 0; i < self.messageTexts.length; i++) {
self.messageTexts[i].y = -400 + i * 40;
}
}
};
self.down = function (x, y, obj) {
var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
// Check if close button was clicked
if (localPos.x > 600 && localPos.x < 800 && localPos.y > -530 && localPos.y < -470) {
closeChatWindow();
}
};
return self;
});
var MiiCharacter = Container.expand(function () {
var self = Container.call(this);
var body = self.attachAsset('miiCharacter', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 2;
self.speedY = (Math.random() - 0.5) * 2;
self.floatOffset = Math.random() * Math.PI * 2;
self.floatSpeed = 0.02 + Math.random() * 0.02;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
// Floating animation
self.floatOffset += self.floatSpeed;
body.y = Math.sin(self.floatOffset) * 10;
// Bounce off edges
if (self.x < 50 || self.x > 1998) {
self.speedX *= -1;
}
if (self.y < 50 || self.y > 2682) {
self.speedY *= -1;
}
// Keep within bounds
self.x = Math.max(50, Math.min(1998, self.x));
self.y = Math.max(50, Math.min(2682, self.y));
};
return self;
});
var WiiChannel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('channelBackground', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9
});
var icon = self.attachAsset('channelIcon', {
anchorX: 0.5,
anchorY: 0.5
});
self.channelName = "";
self.isSelected = false;
self.originalScale = 1;
self.setChannel = function (name, color) {
self.channelName = name;
icon.tint = color;
};
self.select = function () {
if (self.isSelected) return;
self.isSelected = true;
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut
});
LK.getSound('menuSelect').play();
};
self.deselect = function () {
if (!self.isSelected) return;
self.isSelected = false;
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale
}, {
duration: 200,
easing: tween.easeOut
});
};
self.activate = function () {
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.8
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale,
alpha: 1
}, {
duration: 300,
easing: tween.easeIn
});
}
});
};
return self;
});
var WiiCursor = Container.expand(function () {
var self = Container.call(this);
var cursorGraphic = self.attachAsset('cursor', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
// Smooth cursor movement
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
self.x += dx * 0.15;
self.y += dy * 0.15;
// Subtle pulsing animation
var pulse = 1 + Math.sin(Date.now() * 0.005) * 0.1;
cursorGraphic.scaleX = pulse;
cursorGraphic.scaleY = pulse;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game state variables
var channels = [];
var miis = [];
var selectedChannel = null;
var channelGrid = {
rows: 3,
cols: 4,
offsetX: 0,
offsetY: 0
};
// Chat system variables
var chatMode = 'menu'; // 'menu', 'userSelection', 'chatting'
var chatUsers = [];
var selectedChatUsers = [];
var currentChatWindow = null;
var joinChatButton = null;
var startChatButton = null;
var randomChatButton = null;
// Sample user names for chat
var userNames = ["Alex", "Jordan", "Casey", "Riley", "Morgan", "Taylor", "Avery", "Quinn", "Sage", "River", "Blake", "Cameron", "Drew", "Finley", "Hayden"];
// Sample chat messages
var chatMessages = ["Hey everyone!", "How's it going?", "Anyone playing any good games?", "Love the Wii menu!", "This brings back memories", "Who wants to play Wii Sports?", "Check out this new channel!", "The weather forecast looks good", "Anyone seen the news today?", "Mii characters are so cute!"];
// Create background
var background = game.addChild(LK.getAsset('menuBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Create Mii characters in background
for (var i = 0; i < 8; i++) {
var mii = new MiiCharacter();
mii.x = Math.random() * 2048;
mii.y = Math.random() * 2732;
miis.push(mii);
game.addChild(mii);
}
// Create channel grid
var channelNames = ["Disc Channel", "Mii Channel", "Photo Channel", "Wii Shop Channel", "Forecast Channel", "News Channel", "Internet Channel", "Nintendo Channel", "Check Mii Out", "TV Guide", "Wii Speak", "Settings"];
var channelColors = [0x4a90e2, 0x7ed321, 0xf5a623, 0xd0021b, 0x50e3c2, 0xb8e986, 0x9013fe, 0xf8e71c, 0xbd10e0, 0x4a4a4a, 0x417505, 0x8b572a];
// Position channels in grid
var startX = 300;
var startY = 400;
var spacingX = 450;
var spacingY = 400;
for (var i = 0; i < channelNames.length; i++) {
var channel = new WiiChannel();
var row = Math.floor(i / channelGrid.cols);
var col = i % channelGrid.cols;
channel.x = startX + col * spacingX;
channel.y = startY + row * spacingY;
channel.setChannel(channelNames[i], channelColors[i]);
channels.push(channel);
game.addChild(channel);
}
// Create cursor
var cursor = new WiiCursor();
game.addChild(cursor);
// Date/time display
var dateTimeText = new Text2(new Date().toLocaleString(), {
size: 40,
fill: 0xFFFFFF
});
dateTimeText.anchor.set(1, 0);
LK.gui.topRight.addChild(dateTimeText);
// Create Join Chat button
joinChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 150
}));
var joinChatText = new Text2('Join Chat', {
size: 35,
fill: 0xFFFFFF
});
joinChatText.anchor.set(0.5, 0.5);
joinChatText.x = 1024;
joinChatText.y = 150;
game.addChild(joinChatText);
// Initialize chat users
function createChatUsers() {
for (var i = 0; i < userNames.length; i++) {
var chatUser = new ChatUser(userNames[i]);
chatUser.x = 300 + i % 3 * 450;
chatUser.y = 400 + Math.floor(i / 3) * 100;
chatUser.visible = false;
chatUsers.push(chatUser);
game.addChild(chatUser);
}
}
function showUserSelection() {
chatMode = 'userSelection';
// Hide channels and show users
for (var i = 0; i < channels.length; i++) {
channels[i].visible = false;
}
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = true;
}
// Create start chat button
startChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 2500,
alpha: 0.5
}));
var startText = new Text2('Start Chat', {
size: 30,
fill: 0xFFFFFF
});
startText.anchor.set(0.5, 0.5);
startText.x = 800;
startText.y = 2500;
game.addChild(startText);
// Create random chat button
randomChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 2500
}));
var randomText = new Text2('Random Chat', {
size: 30,
fill: 0xFFFFFF
});
randomText.anchor.set(0.5, 0.5);
randomText.x = 1300;
randomText.y = 2500;
game.addChild(randomText);
}
function updateStartChatButton() {
if (startChatButton) {
if (selectedChatUsers.length > 0) {
startChatButton.alpha = 1.0;
} else {
startChatButton.alpha = 0.5;
}
}
}
function startChatWithSelected() {
if (selectedChatUsers.length === 0) return;
chatMode = 'chatting';
// Hide user selection
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = false;
}
if (startChatButton) {
startChatButton.visible = false;
}
if (randomChatButton) {
randomChatButton.visible = false;
}
// Create chat window
currentChatWindow = new ChatWindow();
currentChatWindow.x = 1024;
currentChatWindow.y = 1366;
game.addChild(currentChatWindow);
// Add initial messages
var chatParticipants = selectedChatUsers.slice();
LK.setTimeout(function () {
for (var i = 0; i < chatParticipants.length; i++) {
var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
currentChatWindow.addMessage(chatParticipants[i].userName, randomMessage);
}
}, 1000);
// Continue adding random messages
var messageInterval = LK.setInterval(function () {
if (chatMode === 'chatting' && chatParticipants.length > 0) {
var randomUser = chatParticipants[Math.floor(Math.random() * chatParticipants.length)];
var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
currentChatWindow.addMessage(randomUser.userName, randomMessage);
}
}, 3000);
}
function startRandomChat() {
// Select 1-2 random users
selectedChatUsers = [];
var numUsers = 1 + Math.floor(Math.random() * 2); // 1 or 2 users
for (var i = 0; i < numUsers; i++) {
var randomIndex = Math.floor(Math.random() * chatUsers.length);
var randomUser = chatUsers[randomIndex];
if (selectedChatUsers.indexOf(randomUser) === -1) {
selectedChatUsers.push(randomUser);
randomUser.select();
}
}
LK.setTimeout(function () {
startChatWithSelected();
}, 500);
}
function closeChatWindow() {
chatMode = 'menu';
// Clean up chat
if (currentChatWindow) {
game.removeChild(currentChatWindow);
currentChatWindow = null;
}
// Reset selections
for (var i = 0; i < selectedChatUsers.length; i++) {
selectedChatUsers[i].deselect();
}
selectedChatUsers = [];
// Show channels again
for (var i = 0; i < channels.length; i++) {
channels[i].visible = true;
}
// Hide chat users
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = false;
}
if (startChatButton) {
startChatButton.visible = false;
}
if (randomChatButton) {
randomChatButton.visible = false;
}
}
createChatUsers();
// Start playing background music
LK.playMusic('wiiMenuMusic');
// Touch and interaction handling
var isDragging = false;
var lastTouchX = 0;
var lastTouchY = 0;
game.down = function (x, y, obj) {
isDragging = true;
lastTouchX = x;
lastTouchY = y;
cursor.targetX = x;
cursor.targetY = y;
// Check if touching join chat button
if (chatMode === 'menu') {
var dx = x - 1024;
var dy = y - 150;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
showUserSelection();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching start chat button
if (chatMode === 'userSelection' && startChatButton && selectedChatUsers.length > 0) {
var dx = x - 800;
var dy = y - 2500;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
startChatWithSelected();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching random chat button
if (chatMode === 'userSelection' && randomChatButton) {
var dx = x - 1300;
var dy = y - 2500;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
startRandomChat();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching a channel (only in menu mode)
if (chatMode === 'menu') {
for (var i = 0; i < channels.length; i++) {
var channel = channels[i];
var dx = x - channel.x;
var dy = y - channel.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 200) {
if (selectedChannel && selectedChannel !== channel) {
selectedChannel.deselect();
}
selectedChannel = channel;
channel.select();
break;
}
}
}
};
game.move = function (x, y, obj) {
cursor.targetX = x;
cursor.targetY = y;
if (isDragging) {
var deltaX = x - lastTouchX;
var deltaY = y - lastTouchY;
// Move all channels for scrolling effect
for (var i = 0; i < channels.length; i++) {
channels[i].x += deltaX * 0.5;
channels[i].y += deltaY * 0.5;
}
lastTouchX = x;
lastTouchY = y;
if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
LK.getSound('menuMove').play();
}
}
};
game.up = function (x, y, obj) {
isDragging = false;
if (selectedChannel) {
// Check if still over the selected channel
var dx = x - selectedChannel.x;
var dy = y - selectedChannel.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 200) {
selectedChannel.activate();
LK.getSound('menuSelect').play();
}
}
};
// Game update loop
var timeUpdateCounter = 0;
game.update = function () {
// Update Mii characters
for (var i = 0; i < miis.length; i++) {
// Miis update automatically through their update method
}
// Update cursor
// Cursor updates automatically through its update method
// Update date/time display every 60 frames (1 second)
timeUpdateCounter++;
if (timeUpdateCounter >= 60) {
dateTimeText.setText(new Date().toLocaleString());
timeUpdateCounter = 0;
}
// Keep channels within reasonable bounds
var centerX = 1024;
var centerY = 1366;
var maxOffsetX = 500;
var maxOffsetY = 300;
if (channels.length > 0) {
var avgX = 0;
var avgY = 0;
for (var i = 0; i < channels.length; i++) {
avgX += channels[i].x;
avgY += channels[i].y;
}
avgX /= channels.length;
avgY /= channels.length;
// Gently pull channels back toward center if they drift too far
if (Math.abs(avgX - centerX) > maxOffsetX || Math.abs(avgY - centerY) > maxOffsetY) {
var pullX = (centerX - avgX) * 0.01;
var pullY = (centerY - avgY) * 0.01;
for (var i = 0; i < channels.length; i++) {
channels[i].x += pullX;
channels[i].y += pullY;
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -5,8 +5,131 @@
/****
* Classes
****/
+var ChatUser = Container.expand(function (userName) {
+ var self = Container.call(this);
+ var button = self.attachAsset('userButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.userName = userName;
+ self.isSelected = false;
+ var nameText = new Text2(userName, {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ nameText.anchor.set(0.5, 0.5);
+ self.addChild(nameText);
+ self.select = function () {
+ if (self.isSelected) return;
+ self.isSelected = true;
+ button.tint = 0x4CAF50;
+ tween(self, {
+ scaleX: 1.1,
+ scaleY: 1.1
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ };
+ self.deselect = function () {
+ if (!self.isSelected) return;
+ self.isSelected = false;
+ button.tint = 0x1976D2;
+ tween(self, {
+ scaleX: 1.0,
+ scaleY: 1.0
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
+ };
+ self.down = function (x, y, obj) {
+ if (chatMode === 'userSelection') {
+ if (self.isSelected) {
+ self.deselect();
+ var index = selectedChatUsers.indexOf(self);
+ if (index > -1) {
+ selectedChatUsers.splice(index, 1);
+ }
+ } else {
+ if (selectedChatUsers.length < 2) {
+ self.select();
+ selectedChatUsers.push(self);
+ }
+ }
+ updateStartChatButton();
+ }
+ };
+ return self;
+});
+var ChatWindow = Container.expand(function () {
+ var self = Container.call(this);
+ var background = self.attachAsset('chatWindow', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.95
+ });
+ var messageArea = self.attachAsset('messageBox', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ y: -100
+ });
+ self.messages = [];
+ self.messageTexts = [];
+ var closeButton = self.attachAsset('sendButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 700,
+ y: -500
+ });
+ var closeText = new Text2('Close', {
+ size: 25,
+ fill: 0xFFFFFF
+ });
+ closeText.anchor.set(0.5, 0.5);
+ closeText.x = 700;
+ closeText.y = -500;
+ self.addChild(closeText);
+ var chatTitleText = new Text2('Chat Room', {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ chatTitleText.anchor.set(0.5, 0.5);
+ chatTitleText.y = -550;
+ self.addChild(chatTitleText);
+ self.addMessage = function (userName, message) {
+ var messageText = userName + ": " + message;
+ self.messages.push(messageText);
+ var textObj = new Text2(messageText, {
+ size: 25,
+ fill: 0xFFFFFF
+ });
+ textObj.anchor.set(0, 0.5);
+ textObj.x = -750;
+ textObj.y = -400 + self.messageTexts.length * 40;
+ self.addChild(textObj);
+ self.messageTexts.push(textObj);
+ // Keep only last 15 messages
+ if (self.messageTexts.length > 15) {
+ var oldText = self.messageTexts.shift();
+ self.removeChild(oldText);
+ // Move remaining messages up
+ for (var i = 0; i < self.messageTexts.length; i++) {
+ self.messageTexts[i].y = -400 + i * 40;
+ }
+ }
+ };
+ self.down = function (x, y, obj) {
+ var localPos = self.toLocal(obj.parent.toGlobal(obj.position));
+ // Check if close button was clicked
+ if (localPos.x > 600 && localPos.x < 800 && localPos.y > -530 && localPos.y < -470) {
+ closeChatWindow();
+ }
+ };
+ return self;
+});
var MiiCharacter = Container.expand(function () {
var self = Container.call(this);
var body = self.attachAsset('miiCharacter', {
anchorX: 0.5,
@@ -139,8 +262,20 @@
cols: 4,
offsetX: 0,
offsetY: 0
};
+// Chat system variables
+var chatMode = 'menu'; // 'menu', 'userSelection', 'chatting'
+var chatUsers = [];
+var selectedChatUsers = [];
+var currentChatWindow = null;
+var joinChatButton = null;
+var startChatButton = null;
+var randomChatButton = null;
+// Sample user names for chat
+var userNames = ["Alex", "Jordan", "Casey", "Riley", "Morgan", "Taylor", "Avery", "Quinn", "Sage", "River", "Blake", "Cameron", "Drew", "Finley", "Hayden"];
+// Sample chat messages
+var chatMessages = ["Hey everyone!", "How's it going?", "Anyone playing any good games?", "Love the Wii menu!", "This brings back memories", "Who wants to play Wii Sports?", "Check out this new channel!", "The weather forecast looks good", "Anyone seen the news today?", "Mii characters are so cute!"];
// Create background
var background = game.addChild(LK.getAsset('menuBackground', {
anchorX: 0,
anchorY: 0,
@@ -182,8 +317,163 @@
fill: 0xFFFFFF
});
dateTimeText.anchor.set(1, 0);
LK.gui.topRight.addChild(dateTimeText);
+// Create Join Chat button
+joinChatButton = game.addChild(LK.getAsset('chatButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 150
+}));
+var joinChatText = new Text2('Join Chat', {
+ size: 35,
+ fill: 0xFFFFFF
+});
+joinChatText.anchor.set(0.5, 0.5);
+joinChatText.x = 1024;
+joinChatText.y = 150;
+game.addChild(joinChatText);
+// Initialize chat users
+function createChatUsers() {
+ for (var i = 0; i < userNames.length; i++) {
+ var chatUser = new ChatUser(userNames[i]);
+ chatUser.x = 300 + i % 3 * 450;
+ chatUser.y = 400 + Math.floor(i / 3) * 100;
+ chatUser.visible = false;
+ chatUsers.push(chatUser);
+ game.addChild(chatUser);
+ }
+}
+function showUserSelection() {
+ chatMode = 'userSelection';
+ // Hide channels and show users
+ for (var i = 0; i < channels.length; i++) {
+ channels[i].visible = false;
+ }
+ for (var i = 0; i < chatUsers.length; i++) {
+ chatUsers[i].visible = true;
+ }
+ // Create start chat button
+ startChatButton = game.addChild(LK.getAsset('chatButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 800,
+ y: 2500,
+ alpha: 0.5
+ }));
+ var startText = new Text2('Start Chat', {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ startText.anchor.set(0.5, 0.5);
+ startText.x = 800;
+ startText.y = 2500;
+ game.addChild(startText);
+ // Create random chat button
+ randomChatButton = game.addChild(LK.getAsset('chatButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1300,
+ y: 2500
+ }));
+ var randomText = new Text2('Random Chat', {
+ size: 30,
+ fill: 0xFFFFFF
+ });
+ randomText.anchor.set(0.5, 0.5);
+ randomText.x = 1300;
+ randomText.y = 2500;
+ game.addChild(randomText);
+}
+function updateStartChatButton() {
+ if (startChatButton) {
+ if (selectedChatUsers.length > 0) {
+ startChatButton.alpha = 1.0;
+ } else {
+ startChatButton.alpha = 0.5;
+ }
+ }
+}
+function startChatWithSelected() {
+ if (selectedChatUsers.length === 0) return;
+ chatMode = 'chatting';
+ // Hide user selection
+ for (var i = 0; i < chatUsers.length; i++) {
+ chatUsers[i].visible = false;
+ }
+ if (startChatButton) {
+ startChatButton.visible = false;
+ }
+ if (randomChatButton) {
+ randomChatButton.visible = false;
+ }
+ // Create chat window
+ currentChatWindow = new ChatWindow();
+ currentChatWindow.x = 1024;
+ currentChatWindow.y = 1366;
+ game.addChild(currentChatWindow);
+ // Add initial messages
+ var chatParticipants = selectedChatUsers.slice();
+ LK.setTimeout(function () {
+ for (var i = 0; i < chatParticipants.length; i++) {
+ var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
+ currentChatWindow.addMessage(chatParticipants[i].userName, randomMessage);
+ }
+ }, 1000);
+ // Continue adding random messages
+ var messageInterval = LK.setInterval(function () {
+ if (chatMode === 'chatting' && chatParticipants.length > 0) {
+ var randomUser = chatParticipants[Math.floor(Math.random() * chatParticipants.length)];
+ var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
+ currentChatWindow.addMessage(randomUser.userName, randomMessage);
+ }
+ }, 3000);
+}
+function startRandomChat() {
+ // Select 1-2 random users
+ selectedChatUsers = [];
+ var numUsers = 1 + Math.floor(Math.random() * 2); // 1 or 2 users
+ for (var i = 0; i < numUsers; i++) {
+ var randomIndex = Math.floor(Math.random() * chatUsers.length);
+ var randomUser = chatUsers[randomIndex];
+ if (selectedChatUsers.indexOf(randomUser) === -1) {
+ selectedChatUsers.push(randomUser);
+ randomUser.select();
+ }
+ }
+ LK.setTimeout(function () {
+ startChatWithSelected();
+ }, 500);
+}
+function closeChatWindow() {
+ chatMode = 'menu';
+ // Clean up chat
+ if (currentChatWindow) {
+ game.removeChild(currentChatWindow);
+ currentChatWindow = null;
+ }
+ // Reset selections
+ for (var i = 0; i < selectedChatUsers.length; i++) {
+ selectedChatUsers[i].deselect();
+ }
+ selectedChatUsers = [];
+ // Show channels again
+ for (var i = 0; i < channels.length; i++) {
+ channels[i].visible = true;
+ }
+ // Hide chat users
+ for (var i = 0; i < chatUsers.length; i++) {
+ chatUsers[i].visible = false;
+ }
+ if (startChatButton) {
+ startChatButton.visible = false;
+ }
+ if (randomChatButton) {
+ randomChatButton.visible = false;
+ }
+}
+createChatUsers();
// Start playing background music
LK.playMusic('wiiMenuMusic');
// Touch and interaction handling
var isDragging = false;
@@ -194,21 +484,53 @@
lastTouchX = x;
lastTouchY = y;
cursor.targetX = x;
cursor.targetY = y;
- // Check if touching a channel
- for (var i = 0; i < channels.length; i++) {
- var channel = channels[i];
- var dx = x - channel.x;
- var dy = y - channel.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance < 200) {
- if (selectedChannel && selectedChannel !== channel) {
- selectedChannel.deselect();
+ // Check if touching join chat button
+ if (chatMode === 'menu') {
+ var dx = x - 1024;
+ var dy = y - 150;
+ if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
+ showUserSelection();
+ LK.getSound('menuSelect').play();
+ return;
+ }
+ }
+ // Check if touching start chat button
+ if (chatMode === 'userSelection' && startChatButton && selectedChatUsers.length > 0) {
+ var dx = x - 800;
+ var dy = y - 2500;
+ if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
+ startChatWithSelected();
+ LK.getSound('menuSelect').play();
+ return;
+ }
+ }
+ // Check if touching random chat button
+ if (chatMode === 'userSelection' && randomChatButton) {
+ var dx = x - 1300;
+ var dy = y - 2500;
+ if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
+ startRandomChat();
+ LK.getSound('menuSelect').play();
+ return;
+ }
+ }
+ // Check if touching a channel (only in menu mode)
+ if (chatMode === 'menu') {
+ for (var i = 0; i < channels.length; i++) {
+ var channel = channels[i];
+ var dx = x - channel.x;
+ var dy = y - channel.y;
+ var distance = Math.sqrt(dx * dx + dy * dy);
+ if (distance < 200) {
+ if (selectedChannel && selectedChannel !== channel) {
+ selectedChannel.deselect();
+ }
+ selectedChannel = channel;
+ channel.select();
+ break;
}
- selectedChannel = channel;
- channel.select();
- break;
}
}
};
game.move = function (x, y, obj) {