User prompt
There shouldn't be any X-axis boundaries either
User prompt
There shouldn't be any boundaries for the arrow.
User prompt
The game needs to expand as the player goes northeast, so the arrow can continue rising.
Code edit (1 edits merged)
Please save this source code
User prompt
Create a square-shaped spawning zone for bonuses and obstacles with a width of 400 pixels and a lower-left corner origin located at 2048,0.
User prompt
The obstacles and bonuses themselves should not move, it should just be the arrow itself moving towards the obstacles and bonuses and the camera following the arrow.
User prompt
The obstacles and bonuses should randomly spawn relative to the position of the arrow just beyond the edge of the screen near the upper-right corner. Once they spawn, as the arrow moves in their general direction (northeast), the obstacles will be within the camera view where the arrow will need to maneuver around them.
User prompt
The obstacles and bonuses should move southwest (towards the lower-left corner of the screen).
User prompt
Randomly spawn obstacles and bonuses off-screen around the upper-right corner of the screen, so that as the arrow goes in that direction it will need to maneuver around them.
User prompt
Invert movement so that when the player is touching the screen the arrow goes northeast and when the player is not touching the screen the arrow goes southeast.
User prompt
Make the game end if the stonk market cap reaches -10.
User prompt
The score (the stonk market cap) should actually decrease if the player is going southeast.
User prompt
The game should only increase the score (the stonk market cap) when the player is going northeast or when grabbing a bonus, not when the player is going southeast.
User prompt
The game shouldn't begin until the first touch is registered. Before the game begins, a logo should be displayed with the name Stonks Go Up. Once the player touches the screen for the first time, it should immediately go into the game as you have it setup right now.
User prompt
Fix this bug: When I click to start the game, I don't see the arrow and the game doesn't start.
User prompt
Fix this bug: When I click to start the game, I don't see the arrow and the game doesn't start.
User prompt
The game shouldn't begin until the first touch is registered. Before the game begins, a logo should be displayed with the name Stonks Go Up
User prompt
Make the arrow draw a trail behind itself of rectangular dollar bills matching the arrow's orientation (northeast or southeast) every half second. If the arrow is facing northeast when the dollar bill is drawn, the dollar bill should be green. If the arrow is facing southeast when the dollar bill is drawn, the dollar bill should be red.
Code edit (1 edits merged)
Please save this source code
User prompt
Make it so that when the player is pressing on the screen, the arrow goes southeast, but if the player is not pressing on the screen, the arrow goes northeast.
Code edit (1 edits merged)
Please save this source code
User prompt
Add a grid pattern to the background to demonstrate movement
User prompt
Please fix the bug: 'camera is not defined' in or related to this line: 'camera.init(game);' Line Number: 187
User prompt
The screen should keep centered on the arrow in the middle of the screen as the arrow travels.
User prompt
The camera should follow the arrow in the center of the screen.
/****
* 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 = 8; // Movement speed
self.path = []; // Track arrow's path
self.update = function () {
// Move based on current touch state
if (!game.isTouching) {
// Not touching - go northeast
self.direction = "northeast";
self.x += self.speed;
self.y -= self.speed;
arrowGraphics.rotation = -Math.PI / 4; // 45 degrees up
} else {
// Touching - go southeast
self.direction = "southeast";
self.x += self.speed;
self.y += self.speed;
arrowGraphics.rotation = Math.PI / 4; // 45 degrees down
}
// Keep in bounds
if (self.y < 100) {
self.y = 100;
}
if (self.y > 2732 - 100) {
self.y = 2732 - 100;
}
// Record path for replay at game end
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 () {
self.x += self.speed;
// Make bonus rotate
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 (isGreen) {
var self = Container.call(this);
// Create the dollar bill with appropriate color based on direction
var color = isGreen ? 0x00FF00 : 0xFF0000; // Green for northeast, red for southeast
// Create dollar bill shape
var dollarGraphics = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5,
color: color
});
// Set rotation based on direction
dollarGraphics.rotation = isGreen ? -Math.PI / 4 : Math.PI / 4; // Match arrow rotation
// Fade out over time
self.alpha = 0.8;
// Add $ symbol
var dollarSymbol = new Text2("$", {
size: 60,
fill: 0xFFFFFF
});
dollarSymbol.anchor.set(0.5, 0.5);
self.addChild(dollarSymbol);
// Set lifetime and fade out
self.lifeTime = 0;
self.maxLife = 300; // 5 seconds at 60fps
self.update = function () {
self.lifeTime++;
if (self.lifeTime > self.maxLife) {
self.alpha = Math.max(0, 1 - (self.lifeTime - self.maxLife) / 60);
if (self.alpha <= 0) {
self.readyToRemove = true;
}
}
};
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.update = function () {
self.x += self.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: 0x87ceeb
});
/****
* Game Code
****/
// Game variables
// Track if the screen is being touched
game.isTouching = false;
var Camera = function Camera() {
this.target = null;
this.container = null;
this.offsetX = 0;
this.offsetY = 0;
this.init = function (container) {
this.container = container;
};
this.setTarget = function (target) {
this.target = target;
};
this.setOffset = function (x, y) {
this.offsetX = x;
this.offsetY = y;
};
this.update = function () {
if (!this.target || !this.container) {
return;
}
// Move the container in the opposite direction of target
this.container.x = this.offsetX - this.target.x;
this.container.y = this.offsetY - this.target.y;
};
};
var camera = new Camera();
var arrow;
var obstacles = [];
var bonuses = [];
var stonksTexts = [];
var dollarBills = []; // Array to store dollar bills
var lastObstacleTime = 0;
var lastBonusTime = 0;
var lastDollarBillTime = 0; // Track when we last created a dollar bill
var marketCap = 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("Market Cap: 0", {
size: 60,
fill: 0xFFFFFF
});
marketCapText.anchor.set(0.5, 0);
LK.gui.top.addChild(marketCapText);
// Create arrow
arrow = new Arrow();
arrow.x = 300;
arrow.y = 2732 / 2;
game.addChild(arrow);
// Setup camera to follow arrow
camera.init(game);
camera.setTarget(arrow);
camera.setOffset(2048 / 2, 2732 / 2); // Center the camera on the arrow
// Play background music
LK.playMusic('bgMusic');
// Handle touch events
game.down = function (x, y, obj) {
if (gameActive) {
game.isTouching = true;
}
};
game.up = function (x, y, obj) {
if (gameActive) {
game.isTouching = false;
}
};
// Generate obstacles
function createObstacle() {
var obstacle = new Obstacle();
obstacle.x = 2148; // Just off screen to the right
obstacle.y = 200 + Math.random() * (2732 - 400);
obstacles.push(obstacle);
game.addChild(obstacle);
}
// Generate bonuses
function createBonus() {
var bonus = new Bonus();
bonus.x = 2148; // Just off screen to the right
bonus.y = 200 + Math.random() * (2732 - 400);
bonuses.push(bonus);
game.addChild(bonus);
}
// 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 (!gameActive) {
return;
}
// Update the camera to follow the arrow
camera.update();
// Create dollar bill trail every half second (30 ticks at 60fps)
if (game.ticks - lastDollarBillTime > 30) {
// Create a dollar bill at current arrow position
var isGreen = arrow.direction === "northeast";
var dollarBill = new DollarBill(isGreen);
dollarBill.x = arrow.x;
dollarBill.y = arrow.y;
dollarBills.push(dollarBill);
game.addChild(dollarBill);
lastDollarBillTime = game.ticks;
}
// Create obstacles at regular intervals
if (game.ticks - lastObstacleTime > 60) {
createObstacle();
lastObstacleTime = game.ticks;
}
// Create bonuses less frequently
if (game.ticks - lastBonusTime > 180) {
createBonus();
lastBonusTime = game.ticks;
}
// Update marketCap and distance
marketCap += 1;
marketCapText.setText("Stonk Market Cap: " + marketCap);
// Ensure background is large enough
var minBackgroundWidth = Math.max(10000, arrow.x * 2 + 2048);
var minBackgroundHeight = Math.max(10000, arrow.y * 2 + 2732);
if (background.width < minBackgroundWidth || background.height < minBackgroundHeight) {
background.width = minBackgroundWidth;
background.height = minBackgroundHeight;
}
// Check for obstacles that are off-screen
for (var i = obstacles.length - 1; i >= 0; i--) {
if (obstacles[i].x < -150) {
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 < -150 || 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);
}
}
// Remove faded dollar bills
for (var i = dollarBills.length - 1; i >= 0; i--) {
if (dollarBills[i].readyToRemove) {
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() * 500) + 500;
marketCap += bonusValue;
// Show stonks text
createStonksText(true, arrow.x, arrow.y);
// Flash screen green
LK.effects.flashScreen(0x00FF00, 300);
}
}
// Increase difficulty over time
if (game.ticks % 600 === 0) {
for (var i = 0; i < obstacles.length; i++) {
obstacles[i].speed -= 0.5;
}
for (var i = 0; i < bonuses.length; i++) {
bonuses[i].speed -= 0.3;
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -74,8 +74,43 @@
});
};
return self;
});
+var DollarBill = Container.expand(function (isGreen) {
+ var self = Container.call(this);
+ // Create the dollar bill with appropriate color based on direction
+ var color = isGreen ? 0x00FF00 : 0xFF0000; // Green for northeast, red for southeast
+ // Create dollar bill shape
+ var dollarGraphics = self.attachAsset('arrow', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ color: color
+ });
+ // Set rotation based on direction
+ dollarGraphics.rotation = isGreen ? -Math.PI / 4 : Math.PI / 4; // Match arrow rotation
+ // Fade out over time
+ self.alpha = 0.8;
+ // Add $ symbol
+ var dollarSymbol = new Text2("$", {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ dollarSymbol.anchor.set(0.5, 0.5);
+ self.addChild(dollarSymbol);
+ // Set lifetime and fade out
+ self.lifeTime = 0;
+ self.maxLife = 300; // 5 seconds at 60fps
+ self.update = function () {
+ self.lifeTime++;
+ if (self.lifeTime > self.maxLife) {
+ self.alpha = Math.max(0, 1 - (self.lifeTime - self.maxLife) / 60);
+ if (self.alpha <= 0) {
+ self.readyToRemove = true;
+ }
+ }
+ };
+ return self;
+});
var Obstacle = Container.expand(function () {
var self = Container.call(this);
var obstacleGraphics = self.attachAsset('obstacle', {
anchorX: 0.5,
@@ -156,10 +191,12 @@
var arrow;
var obstacles = [];
var bonuses = [];
var stonksTexts = [];
+var dollarBills = []; // Array to store dollar bills
var lastObstacleTime = 0;
var lastBonusTime = 0;
+var lastDollarBillTime = 0; // Track when we last created a dollar bill
var marketCap = 0;
var gameActive = true;
// Create background
var background = LK.getAsset('background', {
@@ -233,8 +270,19 @@
return;
}
// Update the camera to follow the arrow
camera.update();
+ // Create dollar bill trail every half second (30 ticks at 60fps)
+ if (game.ticks - lastDollarBillTime > 30) {
+ // Create a dollar bill at current arrow position
+ var isGreen = arrow.direction === "northeast";
+ var dollarBill = new DollarBill(isGreen);
+ dollarBill.x = arrow.x;
+ dollarBill.y = arrow.y;
+ dollarBills.push(dollarBill);
+ game.addChild(dollarBill);
+ lastDollarBillTime = game.ticks;
+ }
// Create obstacles at regular intervals
if (game.ticks - lastObstacleTime > 60) {
createObstacle();
lastObstacleTime = game.ticks;
@@ -274,8 +322,15 @@
stonksTexts[i].destroy();
stonksTexts.splice(i, 1);
}
}
+ // Remove faded dollar bills
+ for (var i = dollarBills.length - 1; i >= 0; i--) {
+ if (dollarBills[i].readyToRemove) {
+ 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
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