User prompt
decrease the acceleration increase after player moving to the down state from 1 to 0.1
User prompt
after each time the player moves to the down state, permanently increase the acceleration of all 3 food items by 1 for all future spawned food items
Code edit (10 edits merged)
Please save this source code
User prompt
after each time the player moves to the down state, increase the acceleration of all 3 food items by 0.1
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'foodAsset')' in or related to this line: 'return false;' Line Number: 221
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'foodAsset')' in or related to this line: 'return false;' Line Number: 221
User prompt
after each time the player moves to the down state, increase the acceleration of all 3 food items by 0.1
Code edit (1 edits merged)
Please save this source code
User prompt
instead of displaying the value under the poop units, move it so it overlaps the poop units in their center
User prompt
when the player prematurely goes to the up state and the units are reset, instantly remove all the values under them, instead of waiting for the next food to be collected before doing so
User prompt
there's a bug where only food_2 correctly updates previous points, ensure all 3 foods correctly update these values
User prompt
you also need to update the values displayed under previous units. so if the 2nd unit has been filled, which is worth 2 points, the value under the first unit also has to be updated from 1 to 2, since all units are valued to the latest value. so if unit 7 for example has been filled, update all previous values to 7 since each unit is now worth 7 points
User prompt
the values udner the units works correctly expect when food 2 is collected which doesn't show anything under
User prompt
the value under each unit doesn't update correctly. there should be no value when the digestive system is empty. as soon as the first unit has been filled, display 1 single value under the first unit. display the second value under the second unit as soon as the 2nd unit has been filled and update the first value under the first unit.
User prompt
now let's display a value under each unit, that shows the current points each unit has. only display this value for the filled units. so when the first unit has been filled, that would be worth 1 point, sodisplay 1 under the unit. when the second unit has been filled, display 2 under the second unit and update the value under the first unit to 2, since that is now also worth 2 points. keep doing this until the last 10th unit,
User prompt
if the score reaches 0 or bellow from the score penalty of the player moving back up by the decrease in score from the remaining units, go to game over
User prompt
actually, when the digestive system is reset by the player prematurely moved back up, decrease the score for each of those remaining units, based on the given formula.
User prompt
if the players goes to the up state and still has units that are filled up, reset the digestive system back to zero and don't award any points for the remaining units that have been removed
User prompt
When transitioning to the down state, calculate the number of filled units. - Store this value as a fixed point value for the current down state. - Each time a unit is depleted, add this fixed point value to the score. - Ensure that the score calculation does not incrementally increase for each unit but remains constant based on the initial calculation.
User prompt
depleted units dont add points to the score
User prompt
the score shows NaN when points are added from the depleted units
User prompt
the score disappears when points are being added from the depleted units
User prompt
When transitioning to the down state, calculate the number of filled units. - Store this value as a fixed point value for the current down state. - Each time a unit is depleted, add this fixed point value to the score. - Ensure that the score calculation does not incrementally increase for each unit but remains constant based on the initial calculation.
User prompt
When transitioning to the down state, calculate the number of filled units. - Store this value as a fixed point value for the current down state. - Each time a unit is depleted, add this fixed point value to the score. - Ensure that the score calculation does not incrementally increase for each unit but remains constant based on the initial calculation.
User prompt
the calculation formula is wrong. when having collected 10 units, each depleted unit should only award 10 points, right now it add much more than that
/**** * Classes ****/ // Create BackgroundContainer class var BackgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create DigestionSystem class var DigestionSystem = Container.expand(function () { var self = Container.call(this); self.units = []; self.maxUnits = 10; self.unitWidth = 100; self.unitHeight = 100; self.unitSpacing = 100; self.unitFullAlpha = 1; self.unitEmptyAlpha = 0.5; // Initialize with 10 empty units for (var i = 0; i < self.maxUnits; i++) { var unit = self.attachAsset('Unit', { anchorX: 0.5, anchorY: 0.5, x: i * (self.unitWidth + self.unitSpacing), alpha: self.unitEmptyAlpha }); self.units.push(unit); } return self; }); // Create Food class var Food = Container.expand(function () { var self = Container.call(this); // Attach Food asset to the food self.foodAsset = self.attachAsset('Food', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create Food_2 class var Food_2 = Container.expand(function () { var self = Container.call(this); // Attach Food_2 asset to the food self.foodAsset = self.attachAsset('Food_2', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create Food_3 class var Food_3 = Container.expand(function () { var self = Container.call(this); // Attach Food_3 asset to the food self.foodAsset = self.attachAsset('Food_3', { anchorX: 0.5, anchorY: 0.5 }); // Set food speed self.speed = -5; // This is automatically called every game tick, if the food is attached! self.update = function () { self.speed -= 0.3; // acceleration self.x += self.speed; }; return self; }); // Create ForegroundContainer class var ForegroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create MidgroundContainer class var MidgroundContainer = Container.expand(function () { var self = Container.call(this); return self; }); // Create Player class var Player = Container.expand(function () { var self = Container.call(this); // Attach Player_Up asset to the player self.playerUp = self.attachAsset('Player_Up', { anchorX: 0.5, anchorY: 1.0, scaleX: 1.5, scaleY: 1.5 }); // Attach Player_Down asset to the player self.playerDown = self.attachAsset('Player_Down', { anchorX: 0.5, anchorY: 1.0, x: -120, scaleX: 1.5, scaleY: 1.5 }); // Initially, Player_Down is not visible self.playerDown.visible = false; // Method to switch between Player_Up and Player_Down self.switchFrame = function () { self.playerUp.visible = !self.playerUp.visible; self.playerDown.visible = !self.playerDown.visible; if (self.playerDown.visible) { LK.getSound('Pooping').play(); } else { LK.getSound('Pooping').stop(); // Calculate score based on the number of filled units var filledUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }).length; var pointsPerUnit = filledUnits > 0 ? filledUnits : 0; digestionSystem.pointsPerUnit = pointsPerUnit; // Store points per unit in digestionSystem } }; // Method to check if the player collides with a food object self.checkCollision = function (food) { // Only player_up can collect food if (self.playerUp.visible) { var playerBounds = self.playerUp.getBounds(); if (food) { var foodBounds = food.getBounds(); var foodCenter = { x: foodBounds.x + foodBounds.width / 2, y: foodBounds.y + foodBounds.height / 2 }; } var playerCenter = { x: playerBounds.x + playerBounds.width / 2, y: playerBounds.y + playerBounds.height / 2 }; // Check if the center of the food is within the bounds of the player if (foodCenter && playerBounds.contains(foodCenter.x, foodCenter.y)) { // Do not add a unit to the Digestion System here return true; } if (food) { var foodBounds = food.getBounds(); var foodCenter = { x: foodBounds.x + foodBounds.width / 2, y: foodBounds.y + foodBounds.height / 2 }; if (playerBounds.contains(foodCenter.x, foodCenter.y)) { return true; } if (food.foodAsset) { var foodAssetBounds = food.foodAsset.getBounds(); var foodAssetCenter = { x: foodAssetBounds.x + foodAssetBounds.width / 2, y: foodAssetBounds.y + foodAssetBounds.height / 2 }; if (playerBounds.contains(foodAssetCenter.x, foodAssetCenter.y)) { return true; } } } return false; } return false; }; return self; }); /**** * Initialize Game ****/ //<Assets used in the game will automatically appear here> var game = new LK.Game({ backgroundColor: 0xfdfff4 // Init game with white background }); /**** * Game Code ****/ var backgroundContainer = game.addChild(new BackgroundContainer()); var background = backgroundContainer.attachAsset('background', { anchorX: 0.5, anchorY: 1.0, x: 2048 / 2, y: 2732 }); var midgroundContainer = game.addChild(new MidgroundContainer()); var foregroundContainer = game.addChild(new ForegroundContainer()); // Add the Digestion System to the game var digestionSystem = game.addChild(new DigestionSystem()); digestionSystem.x = 2048 / 2 - 400 - digestionSystem.unitWidth * digestionSystem.maxUnits / 2; digestionSystem.y = 100; var score = 0; digestionSystem.pointsPerUnit = 0; // Initialize pointsPerUnit to avoid NaN issues var filledUnits = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", stroke: "#000000", strokeThickness: 15 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); scoreTxt.y += 920; // Add the Player in the center of the screen var player = midgroundContainer.addChild(new Player()); player.x = 2048 / 2 - 500; player.y = 2732 + 30; // Switch the player's frame on tap game.down = function (x, y, obj) { player.switchFrame(); }; // Spawn food from the right edge of the screen at y position of 500 game.update = function () { if (LK.ticks == 0) { score = 0; scoreTxt.setText(score); // Reset the Digestion System digestionSystem.units.forEach(function (unit) { unit.alpha = digestionSystem.unitEmptyAlpha; }); } if (LK.ticks % 60 == 0) { // every second var foodBucket = []; for (var i = 0; i < 90; i++) { foodBucket.push(new Food()); } for (var i = 0; i < 60; i++) { foodBucket.push(new Food_2()); } for (var i = 0; i < 30; i++) { foodBucket.push(new Food_3()); } var newFood = foodBucket[Math.floor(Math.random() * foodBucket.length)]; newFood.x = 2048; // right edge of the screen newFood.y = 1900; foregroundContainer.addChild(newFood); } // Check for collision between the player and the food // Remove a unit from the Digestion System when the player is in the Down state if (!player.playerUp.visible) { if (LK.ticks % 30 == 0) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length > 0) { fullUnits[fullUnits.length - 1].alpha = digestionSystem.unitEmptyAlpha; score += digestionSystem.pointsPerUnit; // Add points based on the stored points per unit scoreTxt.setText(score.toString()); // Ensure score is updated as a string } else { LK.getSound('Pooping').stop(); } } } else { LK.getSound('Pooping').stop(); } for (var i = foregroundContainer.children.length - 1; i >= 0; i--) { var food = foregroundContainer.children[i]; if (player.checkCollision(food) || player.checkCollision(food.foodAsset)) { // Increment the score if (food instanceof Food_2) { score += 2; // Add two units to the Digestion System for (var i = 0; i < 2; i++) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; } else { LK.showGameOver(); return; } } } else if (food instanceof Food_3) { score += 3; // Add three units to the Digestion System for (var i = 0; i < 3; i++) { var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; } else { LK.showGameOver(); return; } } } else { score++; // Add a unit to the Digestion System var fullUnits = digestionSystem.units.filter(function (unit) { return unit.alpha === digestionSystem.unitFullAlpha; }); if (fullUnits.length < digestionSystem.maxUnits) { digestionSystem.units[fullUnits.length].alpha = digestionSystem.unitFullAlpha; filledUnits = fullUnits.length + 1; // Update filledUnits } else { LK.showGameOver(); return; } } scoreTxt.setText(score.toString()); // Ensure score is updated as a string // Play the Eat sound LK.getSound('Eat').play(); // Remove the food from the game food.destroy(); } } };
===================================================================
--- original.js
+++ change.js
@@ -120,14 +120,10 @@
// Calculate score based on the number of filled units
var filledUnits = digestionSystem.units.filter(function (unit) {
return unit.alpha === digestionSystem.unitFullAlpha;
}).length;
- if (filledUnits > 0) {
- var pointsPerUnit = filledUnits;
- digestionSystem.pointsPerUnit = pointsPerUnit; // Store points per unit in digestionSystem
- } else {
- digestionSystem.pointsPerUnit = 0; // Ensure pointsPerUnit is a number
- }
+ var pointsPerUnit = filledUnits > 0 ? filledUnits : 0;
+ digestionSystem.pointsPerUnit = pointsPerUnit; // Store points per unit in digestionSystem
}
};
// Method to check if the player collides with a food object
self.checkCollision = function (food) {
@@ -201,8 +197,9 @@
var digestionSystem = game.addChild(new DigestionSystem());
digestionSystem.x = 2048 / 2 - 400 - digestionSystem.unitWidth * digestionSystem.maxUnits / 2;
digestionSystem.y = 100;
var score = 0;
+digestionSystem.pointsPerUnit = 0; // Initialize pointsPerUnit to avoid NaN issues
var filledUnits = 0;
var scoreTxt = new Text2('0', {
size: 150,
fill: "#ffffff",
@@ -255,12 +252,10 @@
return unit.alpha === digestionSystem.unitFullAlpha;
});
if (fullUnits.length > 0) {
fullUnits[fullUnits.length - 1].alpha = digestionSystem.unitEmptyAlpha;
- if (!isNaN(digestionSystem.pointsPerUnit)) {
- score += digestionSystem.pointsPerUnit; // Add points based on the stored points per unit
- scoreTxt.setText(score.toString()); // Ensure score is updated as a string
- }
+ score += digestionSystem.pointsPerUnit; // Add points based on the stored points per unit
+ scoreTxt.setText(score.toString()); // Ensure score is updated as a string
} else {
LK.getSound('Pooping').stop();
}
}
hamburger. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
poop UI element . pixelated. 8 bit.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "Constipated" against a poop banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "You’re on a roll!" against a toilet paper banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
text saying "Holy Crap!" against a divine angelic poop banner. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelated text saying "Shit Yeah!" as a shitty newspaper headline. pixelated. 8-bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
macdonalds fries but with the M letter rotated so it looks like a 3. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
large KFC bucket with the digit 5 on it. pixelated. 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit pixelated image of a video game character sitting with hands on a large belly, wearing a white shirt and brown pants. The setting is a simple bathroom, with the character as the main focus. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.