Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot use 'in' operator to search for 'scaleX' in undefined' in or related to this line: 'tween(self.currentGraphic, {' Line Number: 61 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (9 edits merged)
Please save this source code
User prompt
Please fix the bug: 'currentGraphic is not defined' in or related to this line: 'var baseWidth = currentGraphic.width;' Line Number: 48
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(self.currentGraphic, {' Line Number: 55 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(self.currentGraphic, {' Line Number: 62
User prompt
Please fix the bug: 'Uncaught TypeError: tween.to is not a function' in or related to this line: 'tween.to(self.currentGraphic, {' Line Number: 55
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'tween(self.currentGraphic, {' Line Number: 55
Code edit (1 edits merged)
Please save this source code
User prompt
revert index order in frames spawn loop
User prompt
Please fix the bug: 'heart_0_frame_0 is not defined' in or related to this line: 'self.currentGraphic = heart_0_frame_0;' Line Number: 44
User prompt
you didn't take into account the previous spawn order of heat frames. fix it
User prompt
Please fix the bug: 'heart_0_frame_0 is not defined' in or related to this line: 'self.currentGraphic = heart_0_frame_0;' Line Number: 44
User prompt
As you can see, heart frame assets are named 'heart_X_frame_Y'. adapt the current code and make it more generic by leveraging this naming convention
Code edit (5 edits merged)
Please save this source code
User prompt
switch self.currentGraphic and self.nextGraphic to next frames when self.tapCount reaches 10 then 20 then 30 then 40
Code edit (1 edits merged)
Please save this source code
User prompt
apply this heart_0_frame_0.alpha = Math.max(0, Math.min(1, heart_0_frame_0.alpha - 0.1)); to all frames
Code edit (1 edits merged)
Please save this source code
User prompt
Add a counter for taps in the BigHeart
User prompt
Please fix the bug: 'Uncaught ReferenceError: heart_0_frame_1 is not defined' in or related to this line: 'tween(heart_0_frame_1, {' Line Number: 142
User prompt
Please fix the bug: 'Uncaught ReferenceError: heart_0_frame_1 is not defined' in or related to this line: 'tween(heart_0_frame_1, {' Line Number: 141
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
// Create a class for bigHeart
var BigHeart = Container.expand(function () {
var self = Container.call(this);
// Attach the bigHeart asset to the class
var bigHeartGraphics = self.attachAsset('bigHeart', {
anchorX: 0.5,
anchorY: 0.5
});
var heart_0_frame_1 = self.attachAsset('heart_0_frame_1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
self.addChild(heart_0_frame_1);
var heart_0_frame_0 = self.attachAsset('heart_0_frame_4', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
var heart_0_frame_2 = self.attachAsset('heart_0_frame_3', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
var heart_0_frame_3 = self.attachAsset('heart_0_frame_2', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
var heart_0_frame_4 = self.attachAsset('heart_0_frame_1', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
var heart_0_frame_5 = self.attachAsset('heart_0_frame_0', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.1,
scaleY: 1.1
});
// Position the bigHeart at the center of the screen
self.x = 2048 / 2;
self.y = 2732 / 2;
// Define baseWidth and baseHeight
var baseWidth = bigHeartGraphics.width;
var baseHeight = bigHeartGraphics.height;
// Event handler called when a press happens on element. This is automatically called on press if bigHeart is attached.
self.down = function (x, y, obj) {
// Play beat sound
LK.getSound('bump').play();
// Animate the size of the bigHeart to 1.5 times its original size over 0.5 seconds
tween(heart_0_frame_1, {
width: baseWidth * 1.1,
height: baseHeight * 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(heart_0_frame_1, {
width: baseWidth,
height: baseHeight
}, {
duration: 100
});
}
});
tween(heart_0_frame_0, {
width: baseWidth * 1.1,
height: baseHeight * 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(heart_0_frame_0, {
width: baseWidth,
height: baseHeight
}, {
duration: 100
});
}
});
if (heart_0_frame_0.alpha > 0) {
heart_0_frame_0.alpha -= 0.1;
}
// Log the down event
log("Down event triggered on BigHeart");
};
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xa16e9f //Init game with black background
});
/****
* Game Code
****/
var isDebug = true;
function log() {
if (isDebug) {
console.log.apply(console, arguments);
}
}
// Add a counter for taps
var tapCounter = 0;
// Add a big heart at the center of the screen
var bigHeart = new BigHeart();
game.addChild(bigHeart);
// Update the tap counter when the BigHeart is pressed
bigHeart.down = function (x, y, obj) {
tapCounter++;
console.log("Tap count: ", tapCounter);
// Play beat sound
LK.getSound('bump').play();
// Animate the size of the bigHeart to 1.5 times its original size over 0.5 seconds
tween(heart_0_frame_1, {
width: baseWidth * 1.1,
height: baseHeight * 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(heart_0_frame_1, {
width: baseWidth,
height: baseHeight
}, {
duration: 100
});
}
});
tween(heart_0_frame_0, {
width: baseWidth * 1.1,
height: baseHeight * 1.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(heart_0_frame_0, {
width: baseWidth,
height: baseHeight
}, {
duration: 100
});
}
});
if (heart_0_frame_0.alpha > 0) {
heart_0_frame_0.alpha -= 0.1;
}
// Log the down event
log("Down event triggered on BigHeart");
};
// Global ProgressManager
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function _classCallCheck(a, n) {
if (!(a instanceof n)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(e, r) {
for (var t = 0; t < r.length; t++) {
var o = r[t];
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
}
}
function _createClass(e, r, t) {
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
writable: !1
}), e;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
function _toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) {
return t;
}
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) {
return i;
}
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var progressManager;
// Constants for Generators and Upgrades
var GENERATORS = {
ME: {
id: 1,
name: "Me",
description: "It's you! The player whose heart beats love",
autoClick: false,
clickRate: 0,
cost: 0,
upgradeLevel: 0
},
FAIRY: {
id: 2,
name: "Fairy",
description: "A magical fairy that generates love beats",
autoClick: true,
clickRate: 0.1,
// 1 click per 10 seconds
cost: 100,
upgradeLevel: 0
}
};
var UPGRADES = {
ROSE: {
id: 1,
name: "Rose",
description: "A rose that enhances love generation",
targetGenerator: 1,
// Targets Generator #1 (Me)
multipliers: [2, 4, 8],
// Levels of multiplier
cost: 10
}
};
// Progress Management
function ProgressManager() {
var self = this;
self.money = 0;
self.generators = {};
self.upgrades = {};
self.currentTime = Date.now();
self.lastUpdateTime = self.currentTime;
self.updateGame = function () {
var now = Date.now();
var deltaTime = now - self.lastUpdateTime;
// Update generators
Object.values(self.generators).forEach(function (generator) {
var generated = generator.generate(deltaTime);
self.money += generated;
});
self.lastUpdateTime = now;
};
self.buyGenerator = function (generatorId) {
var generatorConfig = Object.values(GENERATORS).find(function (g) {
return g.id === generatorId;
});
if (!generatorConfig) {
throw new Error("Generator with id ".concat(generatorId, " not found"));
}
if (self.money < generatorConfig.cost) {
return false;
}
self.money -= generatorConfig.cost;
self.generators[generatorId] = new Generator(generatorConfig);
return true;
};
self.buyUpgrade = function (upgradeId, generatorId) {
var upgradeConfig = Object.values(UPGRADES).find(function (u) {
return u.id === upgradeId;
});
var targetGenerator = self.generators[generatorId];
if (!upgradeConfig || !targetGenerator) {
throw new Error("Upgrade or Generator not found");
}
if (self.money < upgradeConfig.cost) {
return false;
}
self.money -= upgradeConfig.cost;
var upgrade = new Upgrade(upgradeConfig);
upgrade.apply(targetGenerator);
self.upgrades[upgradeId] = upgrade;
return true;
};
}
function Generator(config) {
var self = this;
self.id = config.id;
self.name = config.name;
self.description = config.description;
self.autoClick = config.autoClick;
self.clickRate = config.clickRate;
self.cost = config.cost;
self.upgradeLevel = config.upgradeLevel;
self.generate = function (deltaTime) {
if (!self.autoClick) {
return 0;
}
var clickAmount = self.clickRate * deltaTime / 1000;
return clickAmount * Math.pow(2, self.upgradeLevel);
};
self.currentMultiplier = Math.pow(2, self.upgradeLevel);
self.manualGenerate = function () {
return 1 * self.currentMultiplier;
};
self.upgrade = function (upgradeMultiplier) {
self.upgradeLevel++;
};
}
function Upgrade(config) {
var self = this;
self.id = config.id;
self.name = config.name;
self.description = config.description;
self.targetGenerator = config.targetGenerator;
self.multipliers = config.multipliers;
self.cost = config.cost;
self.currentLevel = 0;
self.apply = function (generator) {
if (self.currentLevel < self.multipliers.length) {
generator.upgrade(self.multipliers[self.currentLevel]);
self.currentLevel++;
}
};
}
function initializeGame() {
progressManager = new ProgressManager();
// Initialize starting generator (Me)
progressManager.generators[GENERATORS.ME.id] = new Generator(GENERATORS.ME);
}
initializeGame();
a big lovely heart
a big stone heart
a big used copper heart
face view of a big bronze heart
face view of a big silver heart
Big shining gold heart verly slightly ornate. face view.
Big precious shiny porcelain heart slightly ornate. face view.
Large precious heart in mother-of-pearl, lightly ornate. Front view.
Large heart in precious ruby, very lightly decorated. Front view.
The most precious large heart in diamond, Front view.
clean pink enamel board witha very thin border