User prompt
It seems very artificial that customers do not arrive at a constant speed.
User prompt
You can only hold 1 customer in each room. When a new customer arrives, an angry word bubble will appear above them and they will leave. They will give a low score when they leave. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Match the room location used by incoming customers.
User prompt
Create two images: a full room and an empty room.
User prompt
show rooms as empty and occupied
User prompt
creating space between rooms to the right and left.
User prompt
creating space between rooms to the right and left.
User prompt
Give each incoming customer a scoring task ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Create a hotel rating system so that guests can give a score out of 5. ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
move add room button below hotel
User prompt
center hotel room and directional keys vertically on the screen
User prompt
make the room price 10 dollars
User prompt
The arrangement of the rooms is arranged in a 3x6 pattern
User prompt
Open the rooms in every direction
User prompt
Fitting the room layout in 3x3x3 format equal to the hotel's dimensions
User prompt
Increase the number of rooms from 10 to 12
User prompt
prevent rooms from overlapping
User prompt
Let the customer come from outside the screen ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
When you add a room, it will be deducted from the budget.
User prompt
Let's add $200 for each room
User prompt
Write the hotel budget on the top left, let's start with 1000 dollars
User prompt
Customers coming to the hotel can go to the grocery store. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
add grocery store to bottom of screen
User prompt
A maximum of 10 rooms can be added to each hotel.
User prompt
bringing the total number of rooms to 50.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AddRoomButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('add_room_button', { anchorX: 0.5, anchorY: 0.5 }); self.buttonText = self.addChild(new Text2('Add Room', { size: 50, fill: 0xFFFFFF })); self.buttonText.anchor.set(0.5, 0.5); self.down = function (x, y, obj) { if (totalRooms < 50 && hotelCounts[currentHotelIndex] < 12 && budget >= 200) { if (hotels[currentHotelIndex].addRoom()) { totalRooms++; hotelCounts[currentHotelIndex]++; budget -= 200; // Deduct $200 for each room updateUI(); } } }; self.updateButton = function () { if (totalRooms >= 50 || hotelCounts[currentHotelIndex] >= 12 || budget < 200) { buttonBg.tint = 0x666666; if (hotelCounts[currentHotelIndex] >= 12) { self.buttonText.setText('Hotel Full'); } else if (budget < 200) { self.buttonText.setText('Need $200'); } else { self.buttonText.setText('Limit Reached'); } } else { buttonBg.tint = 0xffffff; self.buttonText.setText('Add Room'); } }; return self; }); var Customer = Container.expand(function () { var self = Container.call(this); var customerGraphics = self.attachAsset('customer', { anchorX: 0.5, anchorY: 1.0 }); self.isAtHotel = true; self.isMoving = false; self.moveToGroceryStore = function () { if (self.isMoving || !self.isAtHotel) return; self.isMoving = true; tween(self, { y: 2400 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { self.isAtHotel = false; self.isMoving = false; // Stay at grocery store for a moment, then return LK.setTimeout(function () { self.returnToHotel(); }, 1500); } }); }; self.returnToHotel = function () { if (self.isMoving || self.isAtHotel) return; self.isMoving = true; tween(self, { y: 800 }, { duration: 2000, easing: tween.easeInOut, onFinish: function onFinish() { self.isAtHotel = true; self.isMoving = false; } }); }; return self; }); var GroceryStore = Container.expand(function () { var self = Container.call(this); var storeBg = self.attachAsset('grocery_store', { anchorX: 0.5, anchorY: 0.5 }); self.storeText = self.addChild(new Text2('Grocery Store', { size: 40, fill: 0xFFFFFF })); self.storeText.anchor.set(0.5, 0.5); return self; }); var Hotel = Container.expand(function () { var self = Container.call(this); // Hotel background var hotelBg = self.attachAsset('hotel_bg', { anchorX: 0.5, anchorY: 0.5 }); // Properties self.hotelId = 1; self.roomCount = 0; self.rooms = []; self.setHotel = function (id) { self.hotelId = id; self.updateDisplay(); }; self.addRoom = function () { if (self.roomCount < 12) { // Max 12 rooms per hotel var room = self.addChild(LK.getAsset('room', { anchorX: 0.5, anchorY: 0.5 })); // Position rooms in a grid (3 columns, 4 rows) var col = self.roomCount % 3; var row = Math.floor(self.roomCount / 3); var targetX = (col - 2) * 90; var targetY = (row - 0.5) * 70; // Check for overlapping with existing rooms var isOverlapping = false; for (var i = 0; i < self.rooms.length; i++) { var existingRoom = self.rooms[i]; var distanceX = Math.abs(existingRoom.x - targetX); var distanceY = Math.abs(existingRoom.y - targetY); // Check if rooms would overlap (room width is 100, height is 75) if (distanceX < 100 && distanceY < 75) { isOverlapping = true; break; } } // If overlapping, try to find an alternative position if (isOverlapping) { var foundPosition = false; // Try different positions around the grid for (var tryRow = 0; tryRow < 4 && !foundPosition; tryRow++) { for (var tryCol = 0; tryCol < 3 && !foundPosition; tryCol++) { targetX = (tryCol - 1) * 90; targetY = (tryRow - 1.5) * 70; isOverlapping = false; // Check this position against all existing rooms for (var i = 0; i < self.rooms.length; i++) { var existingRoom = self.rooms[i]; var distanceX = Math.abs(existingRoom.x - targetX); var distanceY = Math.abs(existingRoom.y - targetY); if (distanceX < 100 && distanceY < 75) { isOverlapping = true; break; } } if (!isOverlapping) { foundPosition = true; } } } // If no position found, don't add the room if (!foundPosition) { room.destroy(); return false; } } room.x = targetX; room.y = targetY; self.rooms.push(room); self.roomCount++; return true; } return false; }; self.updateDisplay = function () { // Clear existing rooms for (var i = 0; i < self.rooms.length; i++) { self.rooms[i].destroy(); } self.rooms = []; // Add rooms based on current count for (var i = 0; i < self.roomCount; i++) { var room = self.addChild(LK.getAsset('room', { anchorX: 0.5, anchorY: 0.5 })); var col = i % 3; var row = Math.floor(i / 3); room.x = (col - 1) * 90; room.y = (row - 1.5) * 70; self.rooms.push(room); } }; return self; }); var NavigationButton = Container.expand(function () { var self = Container.call(this); var buttonBg = self.attachAsset('nav_button', { anchorX: 0.5, anchorY: 0.5 }); self.isLeft = true; self.buttonText = null; self.setText = function (text) { if (self.buttonText) { self.buttonText.destroy(); } self.buttonText = self.addChild(new Text2(text, { size: 40, fill: 0xFFFFFF })); self.buttonText.anchor.set(0.5, 0.5); }; self.down = function (x, y, obj) { if (self.isLeft) { currentHotelIndex = (currentHotelIndex - 1 + 5) % 5; } else { currentHotelIndex = (currentHotelIndex + 1) % 5; } updateHotelDisplay(); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x2c3e50 }); /**** * Game Code ****/ // Game state variables var hotels = []; var currentHotelIndex = 0; var totalRooms = 0; var hotelCounts = [0, 0, 0, 0, 0]; var budget = 1000; // UI elements var hotelNameText; var currentRoomsText; var totalRoomsText; var budgetText; var leftButton; var rightButton; var addRoomButton; var currentHotel; // Initialize hotels for (var i = 0; i < 5; i++) { hotels.push(new Hotel()); } // Initialize hotel counts to match hotel room counts for (var i = 0; i < 5; i++) { hotelCounts[i] = hotels[i].roomCount; } // Position current hotel in center currentHotel = game.addChild(hotels[0]); currentHotel.x = 1024; currentHotel.y = 900; // Create navigation buttons leftButton = game.addChild(new NavigationButton()); leftButton.isLeft = true; leftButton.setText('<'); leftButton.x = 400; leftButton.y = 900; rightButton = game.addChild(new NavigationButton()); rightButton.isLeft = false; rightButton.setText('>'); rightButton.x = 1648; rightButton.y = 900; // Create add room button addRoomButton = game.addChild(new AddRoomButton()); addRoomButton.x = 1024; addRoomButton.y = 1400; // Create UI text elements hotelNameText = new Text2('Hotel 1', { size: 80, fill: 0xFFFFFF }); hotelNameText.anchor.set(0.5, 0); LK.gui.top.addChild(hotelNameText); hotelNameText.y = 150; currentRoomsText = new Text2('Rooms in this hotel: 0', { size: 50, fill: 0xFFFFFF }); currentRoomsText.anchor.set(0.5, 0); LK.gui.top.addChild(currentRoomsText); currentRoomsText.y = 250; totalRoomsText = new Text2('Total rooms: 0/50', { size: 50, fill: 0xFFFFFF }); totalRoomsText.anchor.set(0.5, 0); LK.gui.top.addChild(totalRoomsText); totalRoomsText.y = 320; budgetText = new Text2('Budget: $1000', { size: 50, fill: 0xFFFFFF }); budgetText.anchor.set(0, 0); LK.gui.topLeft.addChild(budgetText); budgetText.x = 120; budgetText.y = 50; function updateHotelDisplay() { // Remove current hotel game.removeChild(currentHotel); // Add new hotel currentHotel = game.addChild(hotels[currentHotelIndex]); currentHotel.x = 1024; currentHotel.y = 900; currentHotel.setHotel(currentHotelIndex + 1); updateUI(); } function updateUI() { hotelNameText.setText('Hotel ' + (currentHotelIndex + 1)); currentRoomsText.setText('Rooms in this hotel: ' + hotelCounts[currentHotelIndex]); totalRoomsText.setText('Total rooms: ' + totalRooms + '/50'); budgetText.setText('Budget: $' + budget); addRoomButton.updateButton(); } // Update hotel counts when rooms are added function updateHotelCounts() { totalRooms = 0; for (var i = 0; i < 5; i++) { hotelCounts[i] = hotels[i].roomCount; totalRooms += hotelCounts[i]; } } game.update = function () { updateHotelCounts(); // Spawn customers periodically if there are rooms in the current hotel customerSpawnTimer++; if (customerSpawnTimer >= 180 && hotelCounts[currentHotelIndex] > 0 && customers.length < 5) { // Every 3 seconds, max 5 customers customerSpawnTimer = 0; spawnCustomer(); } // Clean up customers that have been around too long for (var i = customers.length - 1; i >= 0; i--) { // Remove customers after they've made several trips (optional cleanup) if (Math.random() < 0.001) { // Very small chance to remove each frame customers[i].destroy(); customers.splice(i, 1); } } }; // Create grocery store at bottom of screen var groceryStore = game.addChild(new GroceryStore()); groceryStore.x = 1024; groceryStore.y = 2500; // Customer management var customers = []; var customerSpawnTimer = 0; function spawnCustomer() { var customer = game.addChild(new Customer()); customer.x = 900 + Math.random() * 248; // Random position near hotel customer.y = -100; // Start off-screen at the top customers.push(customer); // Move customer to hotel first tween(customer, { y: 800 }, { duration: 1500, easing: tween.easeInOut, onFinish: function onFinish() { // Customer goes to grocery store after arriving at hotel and a random delay LK.setTimeout(function () { customer.moveToGroceryStore(); }, Math.random() * 3000 + 1000); } }); } // Initialize UI updateUI();
===================================================================
--- original.js
+++ change.js
@@ -17,9 +17,9 @@
fill: 0xFFFFFF
}));
self.buttonText.anchor.set(0.5, 0.5);
self.down = function (x, y, obj) {
- if (totalRooms < 50 && hotelCounts[currentHotelIndex] < 10 && budget >= 200) {
+ if (totalRooms < 50 && hotelCounts[currentHotelIndex] < 12 && budget >= 200) {
if (hotels[currentHotelIndex].addRoom()) {
totalRooms++;
hotelCounts[currentHotelIndex]++;
budget -= 200; // Deduct $200 for each room
@@ -27,11 +27,11 @@
}
}
};
self.updateButton = function () {
- if (totalRooms >= 50 || hotelCounts[currentHotelIndex] >= 10 || budget < 200) {
+ if (totalRooms >= 50 || hotelCounts[currentHotelIndex] >= 12 || budget < 200) {
buttonBg.tint = 0x666666;
- if (hotelCounts[currentHotelIndex] >= 10) {
+ if (hotelCounts[currentHotelIndex] >= 12) {
self.buttonText.setText('Hotel Full');
} else if (budget < 200) {
self.buttonText.setText('Need $200');
} else {
@@ -114,17 +114,17 @@
self.hotelId = id;
self.updateDisplay();
};
self.addRoom = function () {
- if (self.roomCount < 10) {
- // Max 10 rooms per hotel
+ if (self.roomCount < 12) {
+ // Max 12 rooms per hotel
var room = self.addChild(LK.getAsset('room', {
anchorX: 0.5,
anchorY: 0.5
}));
- // Position rooms in a grid (5 columns, 2 rows)
- var col = self.roomCount % 5;
- var row = Math.floor(self.roomCount / 5);
+ // Position rooms in a grid (3 columns, 4 rows)
+ var col = self.roomCount % 3;
+ var row = Math.floor(self.roomCount / 3);
var targetX = (col - 2) * 90;
var targetY = (row - 0.5) * 70;
// Check for overlapping with existing rooms
var isOverlapping = false;
@@ -141,12 +141,12 @@
// If overlapping, try to find an alternative position
if (isOverlapping) {
var foundPosition = false;
// Try different positions around the grid
- for (var tryRow = 0; tryRow < 2 && !foundPosition; tryRow++) {
- for (var tryCol = 0; tryCol < 5 && !foundPosition; tryCol++) {
- targetX = (tryCol - 2) * 90;
- targetY = (tryRow - 0.5) * 70;
+ for (var tryRow = 0; tryRow < 4 && !foundPosition; tryRow++) {
+ for (var tryCol = 0; tryCol < 3 && !foundPosition; tryCol++) {
+ targetX = (tryCol - 1) * 90;
+ targetY = (tryRow - 1.5) * 70;
isOverlapping = false;
// Check this position against all existing rooms
for (var i = 0; i < self.rooms.length; i++) {
var existingRoom = self.rooms[i];
@@ -187,12 +187,12 @@
var room = self.addChild(LK.getAsset('room', {
anchorX: 0.5,
anchorY: 0.5
}));
- var col = i % 5;
- var row = Math.floor(i / 5);
- room.x = (col - 2) * 90;
- room.y = (row - 0.5) * 70;
+ var col = i % 3;
+ var row = Math.floor(i / 3);
+ room.x = (col - 1) * 90;
+ room.y = (row - 1.5) * 70;
self.rooms.push(room);
}
};
return self;
stickman top view. In-Game asset
empty room top view. In-Game asset. 2d. High contrast. No shadows
full room top view. In-Game asset. 2d. High contrast. No shadows
left arrow. In-Game asset
destroyed and damaged red flag cross the stripe
Hotel wall view from the front with flowers and mosses. In-Game asset
16:9
Building silhouettes. In-Game asset
hotel bar top view. In-Game asset