Code edit (1 edits merged)
Please save this source code
User prompt
change paper color to green when player accept it
Code edit (1 edits merged)
Please save this source code
User prompt
change paper color when it accept
Code edit (4 edits merged)
Please save this source code
User prompt
stop game when player click on bad paper
Code edit (3 edits merged)
Please save this source code
User prompt
papers must be delete, when player click on paper
Code edit (4 edits merged)
Please save this source code
User prompt
delete complected papers
User prompt
paper color must change
User prompt
intstead reject papers change color to green
User prompt
complected papers have green color
User prompt
papers reject being replaced by the completed papers
Code edit (1 edits merged)
Please save this source code
User prompt
guard to the foreground
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
bad papers doesn't less score when go out from screen
User prompt
bad papers must less score
User prompt
fix it
User prompt
papers must be bigger
User prompt
when player click on paper paper must accept
User prompt
papers must increase score
User prompt
guard move follow cursor
/**** * Classes ****/ // Define the BadPaper class var BadPaper = Container.expand(function () { var self = Container.call(this); var paperGraphics = self.attachAsset('badPaper', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.update = function () { // BadPaper specific update logic }; self.containsPoint = function (point) { return point.x >= self.x && point.x <= self.x + self.width && point.y >= self.y && point.y <= self.y + self.height; }; }); // Define the Guard class var Guard = Container.expand(function () { var self = Container.call(this); var guardGraphics = self.attachAsset('guard', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { // Guard specific update logic }; }); //<Assets used in the game will automatically appear here> // Define the Paper class var Paper = Container.expand(function () { var self = Container.call(this); var paperGraphics = self.attachAsset('paper', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.update = function () { // Paper specific update logic }; self.containsPoint = function (point) { return point.x >= self.x && point.x <= self.x + self.width && point.y >= self.y && point.y <= self.y + self.height; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ // Initialize arrays and variables var papers = []; var score = 0; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Create the guard and position it var guard = new Guard(); guard.x = 2048 / 2; guard.y = 2732 - 200; game.addChild(guard); // Function to handle paper acceptance function acceptPaper(paper) { //paper.destroy(); paperGraphics.color = 0x00ff00; papers.splice(papers.indexOf(paper), 1); //paper.color = 0xff0000; if (paper instanceof BadPaper) { score -= 1; scoreTxt.setText(score); LK.setScore(LK.getScore() - 1); } else { score += 1; scoreTxt.setText(score); LK.setScore(LK.getScore() + 1); LK.setColot(paper, 'green'); } } // Function to handle paper rejection function rejectPaper(paper) { paper.destroy(); papers.splice(papers.indexOf(paper), 1); if (paper instanceof BadPaper == true) { score += 1; } score -= 1; scoreTxt.setText(score); } // Function to create a new paper function createPaper() { var newPaper; if (Math.random() < 0.3) { // 10% chance to create a bad paper newPaper = new BadPaper(); } else { newPaper = new Paper(); } newPaper.x = Math.random() * 2048; newPaper.y = 0; papers.push(newPaper); game.addChildAt(newPaper, 0); } // Event listener for moving the guard game.move = function (x, y, obj) { guard.x = x; guard.y = y; }; // Event listener for rejecting papers game.down = function (x, y, obj) { var localPos = game.toLocal(obj.global); papers.forEach(function (paper) { if (paper.containsPoint({ x: localPos.x, y: localPos.y })) { if (paper instanceof BadPaper) { LK.showGameOver(); } else { acceptPaper(paper); paperGraphics.color = 0x00ff00; // Change paper color to green } } }); }; // Update function to handle game logic game.update = function () { // Create a new paper every 60 ticks if (LK.ticks % 60 == 0) { createPaper(); } // Update all papers papers.forEach(function (paper) { paper.y += 5; // Move paper downwards if (paper.y > 2732) { rejectPaper(paper); // Reject paper if it goes off screen } }); // Stop the game if the score is less than 0 if (score < 0) { LK.showGameOver(); } };
===================================================================
--- original.js
+++ change.js
@@ -71,9 +71,10 @@
guard.y = 2732 - 200;
game.addChild(guard);
// Function to handle paper acceptance
function acceptPaper(paper) {
- paper.destroy();
+ //paper.destroy();
+ paperGraphics.color = 0x00ff00;
papers.splice(papers.indexOf(paper), 1);
//paper.color = 0xff0000;
if (paper instanceof BadPaper) {
score -= 1;