User prompt
Make it so there’s an app called corrupted and if you press it, it gives you an error with the sound
User prompt
Make the calculator work
User prompt
Make the mouse look more mousy
User prompt
Adam mouse make the mouse walk and make it so you can click on stuff in the screens for the explorer and the app icon looks like the normal one in Windows 98 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Retro OS Simulator 98
Initial prompt
Make a Windows 98 simulator
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var DesktopIcon = Container.expand(function (iconName, x, y) {
var self = Container.call(this);
// Create icon background for selection effect
var iconBg = self.attachAsset('desktopIcon', {
anchorX: 0.5,
anchorY: 0.5,
width: 72,
height: 88
});
iconBg.alpha = 0; // Initially transparent
// Create the actual icon
var icon = self.attachAsset('desktopIcon', {
anchorX: 0.5,
anchorY: 0.5
});
// Set icon color based on type
if (iconName === "My Computer") {
icon.tint = 0x87CEEB; // Light blue
} else if (iconName === "Recycle Bin") {
icon.tint = 0x00FF00; // Green
} else if (iconName === "Notepad") {
icon.tint = 0xFFFFFF; // White
} else if (iconName === "Calculator") {
icon.tint = 0xDDDDDD; // Light gray
} else if (iconName === "Explorer") {
icon.tint = 0xFFD700; // Gold
}
var label = new Text2(iconName, {
size: 24,
fill: 0xFFFFFF
});
label.anchor.set(0.5, 0);
label.y = 40;
self.addChild(label);
self.x = x;
self.y = y;
self.name = iconName;
self.interactive = true;
self.isSelected = false;
self.down = function () {
// Show blue selection background
iconBg.alpha = 0.3;
iconBg.tint = 0x0000FF;
self.isSelected = true;
icon.alpha = 0.7;
LK.getSound('click').play();
};
self.up = function () {
icon.alpha = 1;
// Double-click effect (simplified)
if (self.isSelected) {
createWindow(iconName);
// Reset selection after opening window
LK.setTimeout(function () {
iconBg.alpha = 0;
self.isSelected = false;
}, 300);
}
};
return self;
});
var MouseCursor = Container.expand(function () {
var self = Container.call(this);
// Create cursor shape
var cursorShape = LK.getAsset('desktopIcon', {
anchorX: 0,
anchorY: 0,
width: 32,
height: 32
});
cursorShape.tint = 0xFFFFFF;
self.addChild(cursorShape);
// Track if the cursor is over a clickable element
self.isOverClickable = false;
// Update cursor position
self.updatePosition = function (x, y) {
self.x = x;
self.y = y;
};
// Change cursor when over clickable elements
self.setPointer = function (isPointer) {
self.isOverClickable = isPointer;
if (isPointer) {
cursorShape.tint = 0x0000FF;
} else {
cursorShape.tint = 0xFFFFFF;
}
};
return self;
});
var StartMenu = Container.expand(function () {
var self = Container.call(this);
var menu = self.attachAsset('startMenu', {
anchorX: 0,
anchorY: 1
});
var menuItems = ["Programs", "Documents", "Settings", "Find", "Help", "Run...", "Log Off...", "Shut Down..."];
for (var i = 0; i < menuItems.length; i++) {
var itemText = new Text2(menuItems[i], {
size: 24,
fill: 0x000000
});
itemText.x = 34;
itemText.y = 10 + i * 40;
self.addChild(itemText);
}
self.x = 0;
self.y = 2732; // Bottom of screen
self.visible = false;
return self;
});
var Window = Container.expand(function (title, width, height) {
var self = Container.call(this);
self.isActive = true;
self.width = width || 800;
self.height = height || 600;
var windowBg = self.attachAsset('window', {
anchorX: 0,
anchorY: 0,
width: self.width,
height: self.height
});
var titleBar = self.attachAsset('windowTitle', {
anchorX: 0,
anchorY: 0,
width: self.width,
height: 28
});
var titleText = new Text2(title, {
size: 20,
fill: 0xFFFFFF
});
titleText.x = 10;
titleText.y = 4;
self.addChild(titleText);
var closeButton = self.attachAsset('closeButton', {
anchorX: 0,
anchorY: 0
});
closeButton.x = self.width - 28;
closeButton.y = 2;
closeButton.interactive = true;
var minimizeButton = self.attachAsset('minimizeButton', {
anchorX: 0,
anchorY: 0
});
minimizeButton.x = self.width - 56;
minimizeButton.y = 2;
minimizeButton.interactive = true;
var content = self.attachAsset('programContent', {
anchorX: 0,
anchorY: 0,
width: self.width - 20,
height: self.height - 50
});
content.x = 10;
content.y = 40;
// Program specific content
self.contentArea = new Container();
self.contentArea.x = 10;
self.contentArea.y = 40;
self.addChild(self.contentArea);
self.isDragging = false;
self.dragOffsetX = 0;
self.dragOffsetY = 0;
titleBar.interactive = true;
titleBar.down = function (x, y) {
self.isDragging = true;
self.dragOffsetX = x;
self.dragOffsetY = y;
// Bring window to front
if (self.parent) {
var index = self.parent.children.indexOf(self);
if (index >= 0) {
// Remove from current position
self.parent.children.splice(index, 1);
// Add to end (top)
self.parent.children.push(self);
}
}
};
titleBar.up = function () {
self.isDragging = false;
};
closeButton.down = function () {
closeButton.alpha = 0.7;
LK.getSound('click').play();
};
closeButton.up = function () {
closeWindow(self);
};
minimizeButton.down = function () {
minimizeButton.alpha = 0.7;
LK.getSound('click').play();
};
minimizeButton.up = function () {
minimizeButton.alpha = 1;
minimizeWindow(self);
};
return self;
});
var NotepadWindow = Window.expand(function () {
var self = Window.call(this, "Notepad", 700, 500);
var textArea = new Text2("Start typing here...", {
size: 24,
fill: 0x000000
});
textArea.x = 10;
textArea.y = 10;
self.contentArea.addChild(textArea);
return self;
});
var ExplorerWindow = Window.expand(function () {
var self = Window.call(this, "File Explorer", 800, 600);
var folderStructure = ["My Documents", "My Computer", "Network Neighborhood", "Recycle Bin"];
for (var i = 0; i < folderStructure.length; i++) {
// Create a container for each folder item to handle interactions
var folderItem = new Container();
folderItem.interactive = true;
folderItem.x = 10;
folderItem.y = i * 60 + 10;
var folderIcon = LK.getAsset('desktopIcon', {
anchorX: 0,
anchorY: 0,
width: 48,
height: 48
});
folderIcon.tint = 0xFFFF00;
folderIcon.x = 0;
folderIcon.y = 0;
var folderName = new Text2(folderStructure[i], {
size: 20,
fill: 0x000000
});
folderName.x = 60;
folderName.y = 14;
folderItem.addChild(folderIcon);
folderItem.addChild(folderName);
// Add click functionality
folderItem.name = folderStructure[i];
folderItem.lastSelected = false;
folderItem.down = function () {
this.children[0].tint = 0xCCCC00; // Darker yellow when clicked
LK.getSound('click').play();
};
folderItem.up = function () {
this.children[0].tint = 0xFFFF00; // Back to normal yellow
// Open a new Explorer window or perform folder-specific action
if (this.name === "My Computer") {
createWindow("Explorer");
} else if (this.name === "Recycle Bin") {
var emptyBinWindow = new Window("Empty Recycle Bin?", 400, 200);
emptyBinWindow.x = (2048 - 400) / 2;
emptyBinWindow.y = (2732 - 200) / 2;
game.addChild(emptyBinWindow);
activeWindows.push(emptyBinWindow);
}
};
self.contentArea.addChild(folderItem);
}
return self;
});
var CalculatorWindow = Window.expand(function () {
var self = Window.call(this, "Calculator", 300, 400);
var display = new Text2("0", {
size: 36,
fill: 0x000000
});
display.x = 10;
display.y = 10;
self.contentArea.addChild(display);
var buttonLabels = ["7", "8", "9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", ".", "=", "+"];
var buttonSize = 60;
var padding = 5;
var buttonsPerRow = 4;
for (var i = 0; i < buttonLabels.length; i++) {
var buttonX = i % buttonsPerRow * (buttonSize + padding) + 10;
var buttonY = Math.floor(i / buttonsPerRow) * (buttonSize + padding) + 60;
var buttonBg = LK.getAsset('desktopIcon', {
anchorX: 0,
anchorY: 0,
width: buttonSize,
height: buttonSize
});
buttonBg.x = buttonX;
buttonBg.y = buttonY;
buttonBg.tint = 0xDDDDDD;
var buttonText = new Text2(buttonLabels[i], {
size: 30,
fill: 0x000000
});
buttonText.anchor.set(0.5, 0.5);
buttonText.x = buttonX + buttonSize / 2;
buttonText.y = buttonY + buttonSize / 2;
self.contentArea.addChild(buttonBg);
self.contentArea.addChild(buttonText);
}
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x008080
});
/****
* Game Code
****/
// Global variables
var activeWindows = [];
var startMenuOpen = false;
var dragTarget = null;
var savedWindowPositions = {};
// Create the desktop background
var desktop = game.addChild(LK.getAsset('desktop', {
anchorX: 0,
anchorY: 0,
width: 2048,
height: 2732
}));
// Create the taskbar
var taskbar = game.addChild(LK.getAsset('taskbar', {
anchorX: 0,
anchorY: 1,
width: 2048,
height: 50
}));
taskbar.y = 2732;
// Create the start button
var startButton = game.addChild(LK.getAsset('startButton', {
anchorX: 0,
anchorY: 1,
width: 100,
height: 40
}));
startButton.x = 5;
startButton.y = 2732 - 5;
startButton.interactive = true;
// Create the start menu
var startMenu = game.addChild(new StartMenu());
// Add "Start" text to start button
var startText = new Text2("Start", {
size: 24,
fill: 0x000000
});
startText.x = 35;
startText.y = 2732 - 35;
game.addChild(startText);
// Create desktop icons
var icons = [{
name: "My Computer",
x: 100,
y: 100
}, {
name: "Recycle Bin",
x: 100,
y: 200
}, {
name: "Notepad",
x: 100,
y: 300
}, {
name: "Calculator",
x: 100,
y: 400
}, {
name: "Explorer",
x: 100,
y: 500
}];
icons.forEach(function (icon) {
var desktopIcon = new DesktopIcon(icon.name, icon.x, icon.y);
game.addChild(desktopIcon);
});
// Create time display in taskbar
var timeDisplay = new Text2(getCurrentTime(), {
size: 24,
fill: 0x000000
});
timeDisplay.anchor.set(1, 0.5);
timeDisplay.x = 2048 - 10;
timeDisplay.y = 2732 - 25;
game.addChild(timeDisplay);
// Handle desktop clicks
desktop.interactive = true;
desktop.down = function () {
if (startMenuOpen) {
toggleStartMenu();
}
};
// Start button handling
startButton.down = function () {
startButton.alpha = 0.7;
LK.getSound('click').play();
};
startButton.up = function () {
startButton.alpha = 1;
toggleStartMenu();
};
// Game update function
game.update = function () {
// Update time display every second
if (LK.ticks % 60 === 0) {
timeDisplay.setText(getCurrentTime());
}
// Handle window dragging
if (dragTarget && dragTarget.isDragging) {
dragTarget.x = lastMoveX - dragTarget.dragOffsetX;
dragTarget.y = lastMoveY - dragTarget.dragOffsetY;
// Keep windows within screen bounds
dragTarget.x = Math.max(0, Math.min(2048 - dragTarget.width, dragTarget.x));
dragTarget.y = Math.max(0, Math.min(2732 - 50 - dragTarget.height, dragTarget.y));
}
};
// Track mouse/touch position
var lastMoveX = 0;
var lastMoveY = 0;
game.move = function (x, y) {
lastMoveX = x;
lastMoveY = y;
};
// Handle global mouse up
game.up = function () {
if (dragTarget) {
dragTarget.isDragging = false;
dragTarget = null;
}
};
// Helper functions
function toggleStartMenu() {
startMenuOpen = !startMenuOpen;
startMenu.visible = startMenuOpen;
if (startMenuOpen) {
LK.getSound('click').play();
}
}
function createWindow(type) {
var newWindow;
switch (type) {
case "Notepad":
newWindow = new NotepadWindow();
break;
case "Calculator":
newWindow = new CalculatorWindow();
break;
case "Explorer":
case "My Computer":
newWindow = new ExplorerWindow();
break;
default:
newWindow = new Window(type, 600, 400);
}
// Position window - either from saved position or center
if (savedWindowPositions[type]) {
newWindow.x = savedWindowPositions[type].x;
newWindow.y = savedWindowPositions[type].y;
} else {
newWindow.x = (2048 - newWindow.width) / 2;
newWindow.y = (2732 - 50 - newWindow.height) / 2;
}
// Add Windows 98 style opening animation
newWindow.scale.x = 0.1;
newWindow.scale.y = 0.1;
// Add to active windows and game
activeWindows.push(newWindow);
game.addChild(newWindow);
// Animate window opening
tween(newWindow, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeOut
});
// Set as drag target
dragTarget = newWindow;
// Close start menu if open
if (startMenuOpen) {
toggleStartMenu();
}
// Play sound
LK.getSound('click').play();
return newWindow;
}
function closeWindow(window) {
// Save position
savedWindowPositions[window.children[1].text] = {
x: window.x,
y: window.y
};
// Remove from active windows
var index = activeWindows.indexOf(window);
if (index > -1) {
activeWindows.splice(index, 1);
}
// Remove from game
game.removeChild(window);
window.destroy();
// Clear drag target if it was this window
if (dragTarget === window) {
dragTarget = null;
}
}
function minimizeWindow(window) {
// Just hide for now - in a real implementation we'd add a taskbar button
window.visible = false;
// Remove from active windows but don't destroy
var index = activeWindows.indexOf(window);
if (index > -1) {
activeWindows.splice(index, 1);
}
}
function getCurrentTime() {
var date = new Date();
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0' + minutes : minutes;
return hours + ':' + minutes + ' ' + ampm;
}
// Create mouse cursor
var mouseCursor = new MouseCursor();
game.addChild(mouseCursor);
// Check if cursor is over a clickable element
function updateCursorStyle() {
var isOverClickable = false;
// Check if over a desktop icon
for (var i = 0; i < game.children.length; i++) {
var child = game.children[i];
if (child instanceof DesktopIcon && lastMoveX >= child.x - 32 && lastMoveX <= child.x + 32 && lastMoveY >= child.y - 32 && lastMoveY <= child.y + 32) {
isOverClickable = true;
break;
}
}
// Check if over explorer items in open windows
for (var j = 0; j < activeWindows.length; j++) {
var window = activeWindows[j];
if (window instanceof ExplorerWindow) {
for (var k = 0; k < window.contentArea.children.length; k++) {
var item = window.contentArea.children[k];
if (item.interactive && lastMoveX >= window.x + window.contentArea.x + item.x && lastMoveX <= window.x + window.contentArea.x + item.x + 150 && lastMoveY >= window.y + window.contentArea.y + item.y && lastMoveY <= window.y + window.contentArea.y + item.y + 50) {
isOverClickable = true;
break;
}
}
}
}
// Update cursor style
mouseCursor.setPointer(isOverClickable);
}
// Extend game.move to update mouse cursor
var originalMove = game.move;
game.move = function (x, y) {
originalMove(x, y);
mouseCursor.updatePosition(x, y);
updateCursorStyle();
};
// Play startup sound
LK.setTimeout(function () {
LK.getSound('startup').play();
}, 500); ===================================================================
--- original.js
+++ change.js
@@ -8,12 +8,33 @@
* Classes
****/
var DesktopIcon = Container.expand(function (iconName, x, y) {
var self = Container.call(this);
+ // Create icon background for selection effect
+ var iconBg = self.attachAsset('desktopIcon', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: 72,
+ height: 88
+ });
+ iconBg.alpha = 0; // Initially transparent
+ // Create the actual icon
var icon = self.attachAsset('desktopIcon', {
anchorX: 0.5,
anchorY: 0.5
});
+ // Set icon color based on type
+ if (iconName === "My Computer") {
+ icon.tint = 0x87CEEB; // Light blue
+ } else if (iconName === "Recycle Bin") {
+ icon.tint = 0x00FF00; // Green
+ } else if (iconName === "Notepad") {
+ icon.tint = 0xFFFFFF; // White
+ } else if (iconName === "Calculator") {
+ icon.tint = 0xDDDDDD; // Light gray
+ } else if (iconName === "Explorer") {
+ icon.tint = 0xFFD700; // Gold
+ }
var label = new Text2(iconName, {
size: 24,
fill: 0xFFFFFF
});
@@ -23,18 +44,60 @@
self.x = x;
self.y = y;
self.name = iconName;
self.interactive = true;
+ self.isSelected = false;
self.down = function () {
+ // Show blue selection background
+ iconBg.alpha = 0.3;
+ iconBg.tint = 0x0000FF;
+ self.isSelected = true;
icon.alpha = 0.7;
LK.getSound('click').play();
};
self.up = function () {
icon.alpha = 1;
- createWindow(iconName);
+ // Double-click effect (simplified)
+ if (self.isSelected) {
+ createWindow(iconName);
+ // Reset selection after opening window
+ LK.setTimeout(function () {
+ iconBg.alpha = 0;
+ self.isSelected = false;
+ }, 300);
+ }
};
return self;
});
+var MouseCursor = Container.expand(function () {
+ var self = Container.call(this);
+ // Create cursor shape
+ var cursorShape = LK.getAsset('desktopIcon', {
+ anchorX: 0,
+ anchorY: 0,
+ width: 32,
+ height: 32
+ });
+ cursorShape.tint = 0xFFFFFF;
+ self.addChild(cursorShape);
+ // Track if the cursor is over a clickable element
+ self.isOverClickable = false;
+ // Update cursor position
+ self.updatePosition = function (x, y) {
+ self.x = x;
+ self.y = y;
+ };
+ // Change cursor when over clickable elements
+ self.setPointer = function (isPointer) {
+ self.isOverClickable = isPointer;
+ if (isPointer) {
+ cursorShape.tint = 0x0000FF;
+ } else {
+ cursorShape.tint = 0xFFFFFF;
+ }
+ };
+ return self;
+});
var StartMenu = Container.expand(function () {
var self = Container.call(this);
var menu = self.attachAsset('startMenu', {
anchorX: 0,
@@ -159,25 +222,51 @@
var ExplorerWindow = Window.expand(function () {
var self = Window.call(this, "File Explorer", 800, 600);
var folderStructure = ["My Documents", "My Computer", "Network Neighborhood", "Recycle Bin"];
for (var i = 0; i < folderStructure.length; i++) {
+ // Create a container for each folder item to handle interactions
+ var folderItem = new Container();
+ folderItem.interactive = true;
+ folderItem.x = 10;
+ folderItem.y = i * 60 + 10;
var folderIcon = LK.getAsset('desktopIcon', {
anchorX: 0,
anchorY: 0,
width: 48,
height: 48
});
folderIcon.tint = 0xFFFF00;
- folderIcon.x = 10;
- folderIcon.y = i * 60 + 10;
+ folderIcon.x = 0;
+ folderIcon.y = 0;
var folderName = new Text2(folderStructure[i], {
size: 20,
fill: 0x000000
});
- folderName.x = 70;
- folderName.y = i * 60 + 24;
- self.contentArea.addChild(folderIcon);
- self.contentArea.addChild(folderName);
+ folderName.x = 60;
+ folderName.y = 14;
+ folderItem.addChild(folderIcon);
+ folderItem.addChild(folderName);
+ // Add click functionality
+ folderItem.name = folderStructure[i];
+ folderItem.lastSelected = false;
+ folderItem.down = function () {
+ this.children[0].tint = 0xCCCC00; // Darker yellow when clicked
+ LK.getSound('click').play();
+ };
+ folderItem.up = function () {
+ this.children[0].tint = 0xFFFF00; // Back to normal yellow
+ // Open a new Explorer window or perform folder-specific action
+ if (this.name === "My Computer") {
+ createWindow("Explorer");
+ } else if (this.name === "Recycle Bin") {
+ var emptyBinWindow = new Window("Empty Recycle Bin?", 400, 200);
+ emptyBinWindow.x = (2048 - 400) / 2;
+ emptyBinWindow.y = (2732 - 200) / 2;
+ game.addChild(emptyBinWindow);
+ activeWindows.push(emptyBinWindow);
+ }
+ };
+ self.contentArea.addChild(folderItem);
}
return self;
});
var CalculatorWindow = Window.expand(function () {
@@ -379,11 +468,22 @@
} else {
newWindow.x = (2048 - newWindow.width) / 2;
newWindow.y = (2732 - 50 - newWindow.height) / 2;
}
- // Add to active windows
+ // Add Windows 98 style opening animation
+ newWindow.scale.x = 0.1;
+ newWindow.scale.y = 0.1;
+ // Add to active windows and game
activeWindows.push(newWindow);
game.addChild(newWindow);
+ // Animate window opening
+ tween(newWindow, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 200,
+ easing: tween.easeOut
+ });
// Set as drag target
dragTarget = newWindow;
// Close start menu if open
if (startMenuOpen) {
@@ -430,8 +530,45 @@
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0' + minutes : minutes;
return hours + ':' + minutes + ' ' + ampm;
}
+// Create mouse cursor
+var mouseCursor = new MouseCursor();
+game.addChild(mouseCursor);
+// Check if cursor is over a clickable element
+function updateCursorStyle() {
+ var isOverClickable = false;
+ // Check if over a desktop icon
+ for (var i = 0; i < game.children.length; i++) {
+ var child = game.children[i];
+ if (child instanceof DesktopIcon && lastMoveX >= child.x - 32 && lastMoveX <= child.x + 32 && lastMoveY >= child.y - 32 && lastMoveY <= child.y + 32) {
+ isOverClickable = true;
+ break;
+ }
+ }
+ // Check if over explorer items in open windows
+ for (var j = 0; j < activeWindows.length; j++) {
+ var window = activeWindows[j];
+ if (window instanceof ExplorerWindow) {
+ for (var k = 0; k < window.contentArea.children.length; k++) {
+ var item = window.contentArea.children[k];
+ if (item.interactive && lastMoveX >= window.x + window.contentArea.x + item.x && lastMoveX <= window.x + window.contentArea.x + item.x + 150 && lastMoveY >= window.y + window.contentArea.y + item.y && lastMoveY <= window.y + window.contentArea.y + item.y + 50) {
+ isOverClickable = true;
+ break;
+ }
+ }
+ }
+ }
+ // Update cursor style
+ mouseCursor.setPointer(isOverClickable);
+}
+// Extend game.move to update mouse cursor
+var originalMove = game.move;
+game.move = function (x, y) {
+ originalMove(x, y);
+ mouseCursor.updatePosition(x, y);
+ updateCursorStyle();
+};
// Play startup sound
LK.setTimeout(function () {
LK.getSound('startup').play();
}, 500);
\ No newline at end of file