User prompt
Make a “just a game about cutting a slice of meat” at the top of the screen
User prompt
Don’t make the meat multiply just make the meat be able to cut wherever the knife swipes on the meat ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the meat be able to be cut as many times as you want not like resetting but you can split the meat more than once ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the meat not reset once it’s split apart
User prompt
Please fix the bug: 'TypeError: easing is not a function. (In 'easing(t)', 'easing' is "easeOutQuad")' in or related to this line: 'if (isDragging) {' Line Number: 301 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make the meat actually split apart when you cut it
User prompt
Make the controls a bit easier
User prompt
Remove the timer and make the cutting object a butcher knife with a brown rectangle for the handle and make the meat a red meat shaped object made out of ovals
Code edit (1 edits merged)
Please save this source code
User prompt
Slice Master: Precision Butcher
Initial prompt
A game about cutting a slice of meat
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/****
* Classes
****/
var CutLine = Container.expand(function () {
var self = Container.call(this);
var lineGraphics = self.attachAsset('cutLine', {
anchorX: 0.5,
anchorY: 0.5
});
lineGraphics.alpha = 0;
self.show = function () {
tween(lineGraphics, {
alpha: 1
}, {
duration: 200
});
};
return self;
});
var Knife = Container.expand(function () {
var self = Container.call(this);
var knifeHandle = self.attachAsset('knifeHandle', {
anchorX: 0.5,
anchorY: 1.0,
y: 0
});
var knifeBlade = self.attachAsset('knifeBlade', {
anchorX: 0.5,
anchorY: 1.0,
y: -60
});
self.isActive = false;
return self;
});
var Meat = Container.expand(function () {
var self = Container.call(this);
var meatOval1 = self.attachAsset('meatOval1', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var meatOval2 = self.attachAsset('meatOval2', {
anchorX: 0.5,
anchorY: 0.5,
x: -30,
y: -20
});
var meatOval3 = self.attachAsset('meatOval3', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 30
});
self.width = 350;
self.height = 250;
self.targetWeight = 100;
self.currentWeight = 100;
self.isCut = false;
self.cutPosition = 0;
self.getCutAccuracy = function () {
var accuracy = Math.abs(self.cutPosition - 0.5) * 1.5;
return Math.max(0, 1 - accuracy);
};
return self;
});
var MeatPiece = Container.expand(function (isTopPart, cutPosition) {
var self = Container.call(this);
var meatOval1 = self.attachAsset('meatOval1', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var meatOval2 = self.attachAsset('meatOval2', {
anchorX: 0.5,
anchorY: 0.5,
x: -30,
y: -20
});
var meatOval3 = self.attachAsset('meatOval3', {
anchorX: 0.5,
anchorY: 0.5,
x: 40,
y: 30
});
// Create mask based on cut position
if (isTopPart) {
// Top piece - mask bottom portion
meatOval1.height = meatOval1.height * cutPosition;
meatOval2.height = meatOval2.height * cutPosition;
meatOval3.height = meatOval3.height * cutPosition;
} else {
// Bottom piece - mask top portion and adjust position
var remainingHeight = 1 - cutPosition;
meatOval1.height = meatOval1.height * remainingHeight;
meatOval2.height = meatOval2.height * remainingHeight;
meatOval3.height = meatOval3.height * remainingHeight;
meatOval1.y = 250 * cutPosition / 2;
meatOval2.y = -20 + 200 * cutPosition / 2;
meatOval3.y = 30 + 150 * cutPosition / 2;
}
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xF5F5DC
});
/****
* Game Code
****/
var cuttingBoard = game.addChild(LK.getAsset('cuttingBoard', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var guideline = game.addChild(LK.getAsset('guideline', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 1366
}));
var meat = game.addChild(new Meat());
meat.x = 1024;
meat.y = 1366;
var knife = game.addChild(new Knife());
knife.x = 1024;
knife.y = 1200;
var cutLines = [];
var meatPieces = [];
var isDragging = false;
var dragStartY = 0;
var currentLevel = 1;
var perfectCuts = 0;
var gameActive = true;
var scoreText = new Text2('Score: 0', {
size: 80,
fill: 0x000000
});
scoreText.anchor.set(0, 0);
LK.gui.topRight.addChild(scoreText);
var levelText = new Text2('Level: 1', {
size: 80,
fill: 0x000000
});
levelText.anchor.set(0, 0);
LK.gui.topLeft.addChild(levelText);
var instructionText = new Text2('Drag to cut along the red line!', {
size: 60,
fill: 0x333333
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 0;
instructionText.y = 200;
LK.gui.bottom.addChild(instructionText);
function resetMeat() {
meat.isCut = false;
meat.cutPosition = 0;
meat.targetWeight = 80 + Math.random() * 40;
meat.alpha = 1;
meat.visible = true;
tween(meat, {
scaleX: 1,
scaleY: 1,
alpha: 1
}, {
duration: 300
});
for (var i = cutLines.length - 1; i >= 0; i--) {
cutLines[i].destroy();
cutLines.splice(i, 1);
}
for (var i = meatPieces.length - 1; i >= 0; i--) {
meatPieces[i].destroy();
meatPieces.splice(i, 1);
}
var randomOffset = (Math.random() - 0.5) * 100;
guideline.x = 1024 + randomOffset;
}
function makeCut(cutY) {
if (meat.isCut || !gameActive) return;
meat.isCut = true;
var cutPosition = (cutY - (meat.y - meat.height / 2)) / meat.height;
cutPosition = Math.max(0, Math.min(1, cutPosition));
meat.cutPosition = cutPosition;
var cutLine = game.addChild(new CutLine());
cutLine.x = meat.x;
cutLine.y = cutY;
cutLine.show();
cutLines.push(cutLine);
// Hide original meat and create split pieces
meat.visible = false;
// Create top piece
var topPiece = game.addChild(new MeatPiece(true, cutPosition));
topPiece.x = meat.x;
topPiece.y = meat.y;
meatPieces.push(topPiece);
// Create bottom piece
var bottomPiece = game.addChild(new MeatPiece(false, cutPosition));
bottomPiece.x = meat.x;
bottomPiece.y = meat.y;
meatPieces.push(bottomPiece);
// Animate pieces splitting apart
tween(topPiece, {
x: meat.x - 100,
y: meat.y - 50,
rotation: -0.3
}, {
duration: 800,
easing: tween.easeOutQuad
});
tween(bottomPiece, {
x: meat.x + 100,
y: meat.y + 50,
rotation: 0.3
}, {
duration: 800,
easing: tween.easeOutQuad
});
LK.getSound('slice').play();
var accuracy = meat.getCutAccuracy();
var points = Math.floor(accuracy * 100 * currentLevel);
if (accuracy > 0.6) {
perfectCuts++;
points *= 2;
LK.getSound('success').play();
LK.effects.flashObject(topPiece, 0x00FF00, 500);
LK.effects.flashObject(bottomPiece, 0x00FF00, 500);
instructionText.setText('Perfect Cut! +' + points);
} else if (accuracy > 0.3) {
instructionText.setText('Good Cut! +' + points);
LK.effects.flashObject(topPiece, 0xFFFF00, 500);
LK.effects.flashObject(bottomPiece, 0xFFFF00, 500);
} else {
instructionText.setText('Poor Cut! +' + points);
LK.effects.flashObject(topPiece, 0xFF0000, 500);
LK.effects.flashObject(bottomPiece, 0xFF0000, 500);
}
LK.setScore(LK.getScore() + points);
scoreText.setText('Score: ' + LK.getScore());
LK.setTimeout(function () {
if (perfectCuts >= 5) {
currentLevel++;
perfectCuts = 0;
levelText.setText('Level: ' + currentLevel);
instructionText.setText('Level Up!');
}
LK.setTimeout(function () {
instructionText.setText('Drag to cut along the red line!');
}, 1000);
}, 1500);
}
game.down = function (x, y, obj) {
if (!gameActive) return;
var localPos = meat.toLocal(game.toGlobal({
x: x,
y: y
}));
if (Math.abs(localPos.x) < meat.width * 0.8 && Math.abs(localPos.y) < meat.height * 0.8) {
isDragging = true;
dragStartY = y;
knife.isActive = true;
knife.x = x;
knife.y = y;
}
};
game.move = function (x, y, obj) {
if (!gameActive) return;
if (isDragging) {
knife.x = x;
knife.y = y;
if (Math.abs(y - dragStartY) > 20) {
makeCut(y);
isDragging = false;
knife.isActive = false;
}
}
};
game.up = function (x, y, obj) {
if (isDragging) {
isDragging = false;
knife.isActive = false;
}
};
game.update = function () {
if (knife.isActive) {
knife.rotation = Math.sin(LK.ticks * 0.3) * 0.1;
} else {
knife.rotation = 0;
}
guideline.alpha = 0.3 + Math.sin(LK.ticks * 0.1) * 0.2;
if (isDragging) {
var trailEffect = Math.sin(LK.ticks * 0.5) * 0.1;
knife.scaleX = 1 + trailEffect;
} else {
knife.scaleX = 1;
}
};
resetMeat(); ===================================================================
--- original.js
+++ change.js
@@ -256,9 +256,8 @@
levelText.setText('Level: ' + currentLevel);
instructionText.setText('Level Up!');
}
LK.setTimeout(function () {
- resetMeat();
instructionText.setText('Drag to cut along the red line!');
}, 1000);
}, 1500);
}