Code edit (3 edits merged)
Please save this source code
User prompt
I don't see stonksguy
User prompt
Add the stonksguy asset to display in the lower-left of the screen at all times
User prompt
Instead of the single background, make a grid of dark blue squares (outlined in lighter shade of blue) which covers the entire background but repeats like tiles behind everything else, and moves like everything else ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (2 edits merged)
Please save this source code
User prompt
Make the background repeat
User prompt
Make the background slide southwest when the arrow is facing northeast, and make the background slide northwest when the arrow is facing southeast. It should slide at the same speed as the rest of the objects.
User prompt
Make the arrow's hitbox smaller
User prompt
Make the obstacle hitbox even smaller
User prompt
Make the hitbox smaller for the obstacles and bonuses
Code edit (1 edits merged)
Please save this source code
User prompt
Make the hitbox even smaller for obstacles
User prompt
Make the hitboxes smaller for the obstacles
User prompt
Alongside the gradual speed increase, Increase the rate at which dollars, obstacles, and bonuses spawn.
User prompt
Randomly spawn an obstacle directly in the path of the arrow
User prompt
Start the arrow two thirds down on the screen and two thirds left on the screen
Code edit (2 edits merged)
Please save this source code
User prompt
Gradually increase movement speed as the stonk market cap increases
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Make the camera and game stand still and have the dollars, obstacles, and bonuses move instead of the arrow
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'game.container.x = this.container.x;' Line Number: 170
Code edit (11 edits merged)
Please save this source code
User prompt
When I click on the Tap to Start screen, nothing is happening
User prompt
Please fix the bug: 'window.addEventListener is not a function' in or related to this line: 'window.addEventListener('mousedown', function () {' Line Number: 242
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1"); /**** * Classes ****/ var Arrow = Container.expand(function () { var self = Container.call(this); var arrowGraphics = self.attachAsset('arrow', { anchorX: 0.5, anchorY: 0.5 }); self.direction = "northeast"; // Starting direction self.speed = 10; // Movement speed will be used for object movement self.x = 2048 * (1 / 3); // Fixed position at 1/3 from left (2/3 left on screen) self.y = 2732 * (2 / 3); // Fixed position at 2/3 down on screen self.path = []; // Track arrow's path self.update = function () { // Direction changes based on touch state, but arrow doesn't move if (!game.isTouching) { // Not touching - arrow faces northeast self.direction = "northeast"; arrowGraphics.rotation = -Math.PI / 4; // 45 degrees up } else { // Touching - arrow faces southeast self.direction = "southeast"; arrowGraphics.rotation = Math.PI / 4; // 45 degrees down } // Adjust speed based on market cap // Base speed of 10, then increase by 0.5 for each 100 in market cap // Clamp between 10 and 30 to avoid extreme speeds var speedMultiplier = Math.max(0, marketCap) / 100 * 0.5; self.speed = Math.max(10, Math.min(30, 10 + speedMultiplier)); // Record fixed path for consistency if (game.ticks % 5 === 0) { self.path.push({ x: self.x, y: self.y }); } }; // Direction is now controlled by touch state in update method return self; }); var Bonus = Container.expand(function () { var self = Container.call(this); var bonusGraphics = self.attachAsset('bonus', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -8; self.collected = false; self.update = function () { // Bonuses now move towards the arrow (opposite direction) if (game.isTouching) { // Move opposite to southeast direction self.x -= arrow.speed; self.y -= arrow.speed; } else { // Move opposite to northeast direction self.x -= arrow.speed; self.y += arrow.speed; } // Spin the bonus bonusGraphics.rotation += 0.05; }; self.collect = function () { self.collected = true; tween(bonusGraphics, { alpha: 0, scaleX: 2, scaleY: 2 }, { duration: 300, easing: tween.easeOut }); }; return self; }); var DollarBill = Container.expand(function (direction) { var self = Container.call(this); var color = direction === "northeast" ? 0x00FF00 : 0xFF0000; var dollarGraphics = self.attachAsset('dollar', { anchorX: 0.5, anchorY: 0.5, tint: color }); //dollarGraphics.rotation = Math.random() * Math.PI * 2; // Random rotation dollarGraphics.scale.set(0.8, 0.5); // Make it more bill-shaped // No need for self.speed as we'll use arrow.speed directly self.direction = direction; // Store direction for movement self.update = function () { // Move in the opposite direction of what the arrow would move // Use arrow's current speed for consistent movement if (self.direction === "northeast") { self.x -= arrow.speed; self.y += arrow.speed; } else { self.x -= arrow.speed; self.y -= arrow.speed; } }; return self; }); var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); self.speed = -10; self.hitboxScale = 0.7; // Make hitbox 70% of the actual size // Override the intersects method to use a smaller hitbox self.originalIntersects = self.intersects; self.intersects = function (otherObject) { // Store original width and height var originalWidth = obstacleGraphics.width; var originalHeight = obstacleGraphics.height; // Temporarily scale down the width and height for collision detection obstacleGraphics.width *= self.hitboxScale; obstacleGraphics.height *= self.hitboxScale; // Check collision with smaller hitbox var result = self.originalIntersects.call(self, otherObject); // Restore original width and height obstacleGraphics.width = originalWidth; obstacleGraphics.height = originalHeight; return result; }; self.update = function () { // Obstacles now move towards the arrow (opposite direction) // Always use arrow's current speed for consistent movement if (game.isTouching) { // Move opposite to southeast direction self.x -= arrow.speed; self.y -= arrow.speed; } else { // Move opposite to northeast direction self.x -= arrow.speed; self.y += arrow.speed; } }; return self; }); var StonksText = Container.expand(function (message, color) { var self = Container.call(this); var text = new Text2(message || "STONKS!", { size: 100, fill: color || "#00FF00" }); text.anchor.set(0.5, 0.5); self.addChild(text); self.animate = function () { self.alpha = 1; tween(self, { alpha: 0, y: self.y - 200 }, { duration: 1500, easing: tween.easeOut }); tween(self.scale, { x: 2, y: 2 }, { duration: 1500, easing: tween.easeOut }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0066ff }); /**** * Game Code ****/ // Track if the screen is being touched // Game variables game.isTouching = false; var gameStarted = false; // Track if the game has been started by the first touch // Camera functionality removed as the arrow now stays stationary // and other objects move around it var camera = { update: function update() {} // Empty function to prevent errors }; var arrow; var obstacles = []; var bonuses = []; var stonksTexts = []; var dollarBills = []; var lastObstacleTime = 0; var lastBonusTime = 0; var lastDollarTime = 0; var marketCap = 0; var marketCapFactor = 0; var gameActive = true; // Create background var background = LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, width: 10000, height: 10000 }); game.addChild(background); // Create GUI elements var marketCapText = new Text2("Stonk Market Cap: $0.00", { size: 60, fill: 0xFFFFFF }); marketCapText.anchor.set(0.5, 0); LK.gui.top.addChild(marketCapText); marketCapText.visible = false; // Hide initially // Create startup logo var logoText = new Text2("Stonks Go Up", { size: 150, fill: 0x00FF00 }); logoText.anchor.set(0.5, 1.2); logoText.x = 2048 / 2; logoText.y = 2732 / 2; game.addChild(logoText); // Add tap to start instruction var startInstructionText = new Text2("Tap to Start", { size: 80, fill: 0xFFFFFF }); startInstructionText.anchor.set(0.5, 0.5); startInstructionText.x = 2048 / 2; startInstructionText.y = 2732 / 2 + 200; game.addChild(startInstructionText); // Make the text pulse tween(startInstructionText.scale, { x: 1.1, y: 1.1 }, { duration: 800, easing: tween.easeInOut, loop: -1, yoyo: true }); // Create arrow in the center of the screen arrow = new Arrow(); // Arrow position is set in the class constructor game.addChild(arrow); // No camera setup needed since we have a fixed view // Play background music LK.playMusic('bgMusic'); // Handle touch events game.down = function (x, y, obj) { if (!gameStarted) { // First touch - start the game gameStarted = true; // Hide the logo and instruction tween(logoText, { alpha: 0 }, { duration: 500, easing: tween.easeOut, onComplete: function onComplete() { logoText.destroy(); } }); tween(startInstructionText, { alpha: 0 }, { duration: 500, easing: tween.easeOut, onComplete: function onComplete() { startInstructionText.destroy(); } }); // Show the market cap text marketCapText.visible = true; // Set touch state game.isTouching = true; } else if (gameActive) { game.isTouching = true; } }; game.up = function (x, y, obj) { if (gameActive) { game.isTouching = false; } }; // Generate obstacles function createObstacle() { var obstacle = new Obstacle(); // Since arrow is fixed in center, use fixed screen coordinates var screenWidth = 2048; var screenHeight = 2732; // Randomly decide if this obstacle should be directly in the arrow's path var inPath = Math.random() < 0.4; // 40% chance to spawn in path var spawnRegion = Math.random(); if (inPath) { // Spawn directly in the path of the arrow based on current direction var distanceAhead = 1000 + Math.random() * 500; // Spawn far enough to give player time to react if (arrow.direction === "northeast") { // Position in the northeast path of the arrow obstacle.x = arrow.x + distanceAhead; obstacle.y = arrow.y - distanceAhead; } else { // Position in the southeast path of the arrow obstacle.x = arrow.x + distanceAhead; obstacle.y = arrow.y + distanceAhead; } } else if (spawnRegion < 0.7) { // Spawn to the right obstacle.x = screenWidth + Math.random() * 200; // Just off-screen to the right obstacle.y = screenHeight / 2 - Math.random() * 500; // Spread around middle height } else { // Spawn above obstacle.x = screenWidth / 2 + Math.random() * 500; // Spread to the right of center obstacle.y = -200 - Math.random() * 200; // Just above the visible screen } obstacles.push(obstacle); game.addChild(obstacle); } // Generate bonuses function createBonus() { var bonus = new Bonus(); // Since arrow is fixed in center, use fixed screen coordinates var screenWidth = 2048; var screenHeight = 2732; // Spawn bonuses at the upper-right corner of visible screen var spawnRegion = Math.random(); if (spawnRegion < 0.6) { // Spawn to the right bonus.x = screenWidth + Math.random() * 300; // Just off-screen to the right bonus.y = screenHeight / 2 - Math.random() * 600; // Spread around middle height } else { // Spawn above bonus.x = screenWidth / 2 + Math.random() * 600; // Spread to the right of center bonus.y = -200 - Math.random() * 300; // Just above the visible screen } bonuses.push(bonus); game.addChild(bonus); } // Create dollar bill in appropriate direction function createDollarBill() { if (!arrow || !gameActive) { return; } var dollarBill = new DollarBill(arrow.direction); // Position the dollar bill in front of the arrow based on direction // Since the arrow is stationary, we position relative to the center var offsetDistance = 100; if (arrow.direction === "northeast") { dollarBill.x = arrow.x + offsetDistance; dollarBill.y = arrow.y - offsetDistance; dollarBill.rotation = -Math.PI / 4; // 45 degrees up } else { dollarBill.x = arrow.x + offsetDistance; dollarBill.y = arrow.y + offsetDistance; dollarBill.rotation = Math.PI / 4; // 45 degrees down } dollarBills.push(dollarBill); game.addChild(dollarBill); } // Create stonks text popup function createStonksText(isPositive, x, y) { var message = isPositive ? "STONKS!" : "NOT STONKS!"; var color = isPositive ? "#00FF00" : "#FF0000"; var stonksText = new StonksText(message, color); stonksText.x = x; stonksText.y = y; stonksText.animate(); stonksTexts.push(stonksText); game.addChild(stonksText); } // Game update loop game.update = function () { if (!gameStarted || !gameActive) { return; } // No camera update needed with stationary arrow // Calculate spawn rate multipliers based on market cap var marketCapFactor = Math.max(0, marketCap) / 100; var obstacleRate = Math.max(20, 60 - marketCapFactor * 10); // Decrease from 60 down to 20 as cap increases var bonusRate = Math.max(80, 180 - marketCapFactor * 20); // Decrease from 180 down to 80 as cap increases var dollarRate = Math.max(10, 30 - marketCapFactor * 5); // Decrease from 30 down to 10 as cap increases // Create obstacles at dynamic intervals lastObstacleTime = lastObstacleTime + 1; if (lastObstacleTime > obstacleRate) { createObstacle(); lastObstacleTime = 0; } // Create bonuses at dynamic intervals lastBonusTime = lastBonusTime + 1; if (lastBonusTime > bonusRate) { createBonus(); lastBonusTime = 0; } // Create dollar bills at dynamic intervals lastDollarTime = lastDollarTime + 1; if (lastDollarTime > dollarRate) { createDollarBill(); lastDollarTime = 0; } // Update marketCap - increase when going northeast, decrease when going southeast var oldSpeed = arrow.speed; if (arrow.direction === "northeast") { marketCap += 1; } else if (arrow.direction === "southeast") { marketCap -= 1; } // Calculate current and previous spawn rates var prevMarketCapFactor = Math.max(0, marketCap - 1) / 100; var prevDollarRate = Math.max(10, 30 - prevMarketCapFactor * 5); var currentDollarRate = Math.max(10, 30 - marketCapFactor * 5); // Show visual feedback when speed increases significantly if (arrow.speed - oldSpeed > 0.5) { var speedText = new StonksText("SPEED UP!", "#FFFF00"); speedText.x = arrow.x; speedText.y = arrow.y - 100; speedText.animate(); stonksTexts.push(speedText); game.addChild(speedText); } // Show visual feedback when spawn rate increases significantly if (prevDollarRate - currentDollarRate > 0.5 && arrow.direction === "northeast") { var spawnText = new StonksText("SPAWN RATE UP!", "#00FFFF"); spawnText.x = arrow.x + 100; spawnText.y = arrow.y; spawnText.animate(); stonksTexts.push(spawnText); game.addChild(spawnText); } // Check if market cap has reached game-ending threshold of -10 if (marketCap <= -10 && gameActive) { // Game over gameActive = false; createStonksText(false, arrow.x, arrow.y); LK.getSound('crash').play(); // Flash screen red LK.effects.flashScreen(0xFF0000, 1000); // Show game over LK.setTimeout(function () { LK.setScore(marketCap); LK.showGameOver(); }, 1500); } // Calculate rate percentages relative to initial rates for display var speedPercentage = Math.round(arrow.speed / 10 * 100); var spawnRatePercentage = Math.round(30 / dollarRate * 100); marketCapText.setText("Stonk Market Cap: $" + marketCap + ".00 | Speed: " + speedPercentage + "% | Spawn: " + spawnRatePercentage + "%"); // Check if obstacles are completely off-screen for (var i = obstacles.length - 1; i >= 0; i--) { // Remove obstacles that have moved off the left side of the screen if (obstacles[i].x < -200) { obstacles[i].destroy(); obstacles.splice(i, 1); } } // Check for bonuses that are off-screen for (var i = bonuses.length - 1; i >= 0; i--) { if (bonuses[i].x < -200 || bonuses[i].collected) { bonuses[i].destroy(); bonuses.splice(i, 1); } } // Remove faded stonks texts for (var i = stonksTexts.length - 1; i >= 0; i--) { if (stonksTexts[i].alpha <= 0) { stonksTexts[i].destroy(); stonksTexts.splice(i, 1); } } // Clean up dollar bills that are off-screen for (var i = dollarBills.length - 1; i >= 0; i--) { if (dollarBills[i].x < -200) { dollarBills[i].destroy(); dollarBills.splice(i, 1); } } // Check for collisions with obstacles for (var i = 0; i < obstacles.length; i++) { if (arrow.intersects(obstacles[i])) { // Game over gameActive = false; createStonksText(false, arrow.x, arrow.y); LK.getSound('crash').play(); // Flash screen red LK.effects.flashScreen(0xFF0000, 1000); // Show game over LK.setTimeout(function () { LK.setScore(marketCap); LK.showGameOver(); }, 1500); break; } } // Check for collisions with bonuses for (var i = bonuses.length - 1; i >= 0; i--) { if (!bonuses[i].collected && arrow.intersects(bonuses[i])) { // Collect bonus bonuses[i].collect(); LK.getSound('collect').play(); // Add bonus score var bonusValue = Math.floor(Math.random() * 1000) + 500; marketCap += bonusValue; // Show stonks text createStonksText(true, arrow.x, arrow.y); // Flash screen green LK.effects.flashScreen(0x00FF00, 300); } } // Objects don't move, so no need to increase difficulty by changing their speed };
===================================================================
--- original.js
+++ change.js
@@ -111,8 +111,25 @@
anchorX: 0.5,
anchorY: 0.5
});
self.speed = -10;
+ self.hitboxScale = 0.7; // Make hitbox 70% of the actual size
+ // Override the intersects method to use a smaller hitbox
+ self.originalIntersects = self.intersects;
+ self.intersects = function (otherObject) {
+ // Store original width and height
+ var originalWidth = obstacleGraphics.width;
+ var originalHeight = obstacleGraphics.height;
+ // Temporarily scale down the width and height for collision detection
+ obstacleGraphics.width *= self.hitboxScale;
+ obstacleGraphics.height *= self.hitboxScale;
+ // Check collision with smaller hitbox
+ var result = self.originalIntersects.call(self, otherObject);
+ // Restore original width and height
+ obstacleGraphics.width = originalWidth;
+ obstacleGraphics.height = originalHeight;
+ return result;
+ };
self.update = function () {
// Obstacles now move towards the arrow (opposite direction)
// Always use arrow's current speed for consistent movement
if (game.isTouching) {
arrow pointing to the right like on a stock market ticker. No shadows
cartoonish dollar bill. In-Game asset. 2d. High contrast. No shadows
green stock market chart candle. In-Game asset. 2d. High contrast. No shadows
red stock market chart candle. In-Game asset. 2d. High contrast. No shadows
screen-wrappable repeating blue grid on dark background. In-Game asset. 2d. High contrast. No shadows
white full moon. In-Game asset. 2d. High contrast. No shadows