/**** * Classes ****/ //<Assets used in the game will automatically appear here> // Car class to represent a luxury car var Car = Container.expand(function () { var self = Container.call(this); var carGraphics = self.attachAsset('car', { anchorX: 0.5, anchorY: 0.5 }); self.price = Math.floor(Math.random() * 100000) + 50000; // Random price between 50,000 and 150,000 self.update = function () { // Update logic for car if needed }; }); // Office class to represent the office where transactions occur var Office = Container.expand(function () { var self = Container.call(this); var officeGraphics = self.attachAsset('office', { anchorX: 0.5, anchorY: 0.5 }); self.cars = []; self.addCar = function (car) { self.cars.push(car); self.addChild(car); }; self.removeCar = function (car) { var index = self.cars.indexOf(car); if (index > -1) { self.cars.splice(index, 1); car.destroy(); } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize variables var playerMoney = 500000; // Player starts with $500,000 var offices = []; var selectedCar = null; // Create four offices for (var i = 0; i < 4; i++) { var office = new Office(); office.x = i % 2 * 1024 + 512; // Position offices in a grid office.y = Math.floor(i / 2) * 1366 + 683; offices.push(office); game.addChild(office); } // Populate offices with cars offices.forEach(function (office) { for (var j = 0; j < 5; j++) { var car = new Car(); car.x = Math.random() * 400 - 200; car.y = Math.random() * 400 - 200; office.addCar(car); } }); // Display player's money var moneyText = new Text2('$' + playerMoney, { size: 100, fill: "#ffffff" }); moneyText.anchor.set(0.5, 0); LK.gui.top.addChild(moneyText); // Handle buying and selling cars game.down = function (x, y, obj) { var localPos = game.toLocal(obj.global); offices.forEach(function (office) { office.cars.forEach(function (car) { if (car.intersects({ x: localPos.x, y: localPos.y, width: 1, height: 1 })) { if (selectedCar) { // Sell the selected car playerMoney += selectedCar.price; moneyText.setText('$' + playerMoney); office.removeCar(selectedCar); selectedCar = null; } else if (playerMoney >= car.price) { // Buy the car playerMoney -= car.price; moneyText.setText('$' + playerMoney); selectedCar = car; } } }); }); }; // Update game logic game.update = function () { // Update logic if needed };
===================================================================
--- original.js
+++ change.js
@@ -1,101 +1,106 @@
-/****
+/****
* Classes
-****/
+****/
//<Assets used in the game will automatically appear here>
// Car class to represent a luxury car
var Car = Container.expand(function () {
- var self = Container.call(this);
- var carGraphics = self.attachAsset('car', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.price = Math.floor(Math.random() * 100000) + 50000; // Random price between 50,000 and 150,000
- self.update = function () {
- // Update logic for car if needed
- };
+ var self = Container.call(this);
+ var carGraphics = self.attachAsset('car', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.price = Math.floor(Math.random() * 100000) + 50000; // Random price between 50,000 and 150,000
+ self.update = function () {
+ // Update logic for car if needed
+ };
});
// Office class to represent the office where transactions occur
var Office = Container.expand(function () {
- var self = Container.call(this);
- var officeGraphics = self.attachAsset('office', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.cars = [];
- self.addCar = function (car) {
- self.cars.push(car);
- self.addChild(car);
- };
- self.removeCar = function (car) {
- var index = self.cars.indexOf(car);
- if (index > -1) {
- self.cars.splice(index, 1);
- car.destroy();
- }
- };
+ var self = Container.call(this);
+ var officeGraphics = self.attachAsset('office', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.cars = [];
+ self.addCar = function (car) {
+ self.cars.push(car);
+ self.addChild(car);
+ };
+ self.removeCar = function (car) {
+ var index = self.cars.indexOf(car);
+ if (index > -1) {
+ self.cars.splice(index, 1);
+ car.destroy();
+ }
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* Game Code
-****/
+****/
// Initialize variables
var playerMoney = 500000; // Player starts with $500,000
var offices = [];
var selectedCar = null;
// Create four offices
for (var i = 0; i < 4; i++) {
- var office = new Office();
- office.x = i % 2 * 1024 + 512; // Position offices in a grid
- office.y = Math.floor(i / 2) * 1366 + 683;
- offices.push(office);
- game.addChild(office);
+ var office = new Office();
+ office.x = i % 2 * 1024 + 512; // Position offices in a grid
+ office.y = Math.floor(i / 2) * 1366 + 683;
+ offices.push(office);
+ game.addChild(office);
}
// Populate offices with cars
offices.forEach(function (office) {
- for (var j = 0; j < 5; j++) {
- var car = new Car();
- car.x = Math.random() * 400 - 200;
- car.y = Math.random() * 400 - 200;
- office.addCar(car);
- }
+ for (var j = 0; j < 5; j++) {
+ var car = new Car();
+ car.x = Math.random() * 400 - 200;
+ car.y = Math.random() * 400 - 200;
+ office.addCar(car);
+ }
});
// Display player's money
var moneyText = new Text2('$' + playerMoney, {
- size: 100,
- fill: "#ffffff"
+ size: 100,
+ fill: "#ffffff"
});
moneyText.anchor.set(0.5, 0);
LK.gui.top.addChild(moneyText);
// Handle buying and selling cars
game.down = function (x, y, obj) {
- var localPos = game.toLocal(obj.global);
- offices.forEach(function (office) {
- office.cars.forEach(function (car) {
- if (car.containsPoint(localPos)) {
- if (selectedCar) {
- // Sell the selected car
- playerMoney += selectedCar.price;
- moneyText.setText('$' + playerMoney);
- office.removeCar(selectedCar);
- selectedCar = null;
- } else if (playerMoney >= car.price) {
- // Buy the car
- playerMoney -= car.price;
- moneyText.setText('$' + playerMoney);
- selectedCar = car;
- }
- }
- });
- });
+ var localPos = game.toLocal(obj.global);
+ offices.forEach(function (office) {
+ office.cars.forEach(function (car) {
+ if (car.intersects({
+ x: localPos.x,
+ y: localPos.y,
+ width: 1,
+ height: 1
+ })) {
+ if (selectedCar) {
+ // Sell the selected car
+ playerMoney += selectedCar.price;
+ moneyText.setText('$' + playerMoney);
+ office.removeCar(selectedCar);
+ selectedCar = null;
+ } else if (playerMoney >= car.price) {
+ // Buy the car
+ playerMoney -= car.price;
+ moneyText.setText('$' + playerMoney);
+ selectedCar = car;
+ }
+ }
+ });
+ });
};
// Update game logic
game.update = function () {
- // Update logic if needed
+ // Update logic if needed
};
\ No newline at end of file
A square building having a banner where we can change name of aur office. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cars like Lamborghini, Ferrari, Bugatti. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A garage with employees who can repair the cars. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.