User prompt
You can add score system right corner
User prompt
Add score system add menü
User prompt
Add score
User prompt
Point system
User prompt
Target move up and right and left and down
User prompt
Target move up and down
User prompt
Target move right and left
User prompt
Background black
Code edit (1 edits merged)
Please save this source code
User prompt
Hı
Initial prompt
Hı
/**** * Classes ****/ // No plugins needed for MVP // HiCharacter: draggable by the player var HiCharacter = Container.expand(function () { var self = Container.call(this); var charAsset = self.attachAsset('hiCharacter', { anchorX: 0.5, anchorY: 0.5 }); // For possible future use: down/up events self.down = function (x, y, obj) {}; self.up = function (x, y, obj) {}; return self; }); // HiDot: collectible, spawns at random positions var HiDot = Container.expand(function () { var self = Container.call(this); var dotAsset = self.attachAsset('hiDot', { anchorX: 0.5, anchorY: 0.5 }); return self; }); // HiTarget: the goal area var HiTarget = Container.expand(function () { var self = Container.call(this); var targetAsset = self.attachAsset('hiTarget', { anchorX: 0.5, anchorY: 0.5 }); return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xf7f7f7 }); /**** * Game Code ****/ // Character: red box, Target: green ellipse, Dot: yellow ellipse. // "Hi" themed assets: a character, a target, and a collectible "dot". // Center positions var centerX = 2048 / 2; var centerY = 2732 / 2; // Score display var scoreTxt = new Text2('0', { size: 140, fill: 0x222222 }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // "Hı!" greeting text at the top center, below the score var hiTxt = new Text2('Hı!', { size: 120, fill: 0xD83318 }); hiTxt.anchor.set(0.5, 0); hiTxt.y = 160; LK.gui.top.addChild(hiTxt); // Create and position the target near the bottom center var hiTarget = new HiTarget(); hiTarget.x = centerX; hiTarget.y = 2732 - 350; game.addChild(hiTarget); // Create and position the character near the top center var hiCharacter = new HiCharacter(); hiCharacter.x = centerX; hiCharacter.y = 500; game.addChild(hiCharacter); // Dots array var hiDots = []; // Dragging logic var dragNode = null; // For intersection state tracking var lastTargetIntersecting = false; // Helper: spawn a dot at a random position (not overlapping with target or character) function spawnDot() { var dot = new HiDot(); // Avoid top 200px and bottom 400px, and avoid left/right 100px var minX = 100 + dot.width / 2; var maxX = 2048 - 100 - dot.width / 2; var minY = 300 + dot.height / 2; var maxY = 2732 - 400 - dot.height / 2; // Try up to 10 times to avoid spawning on character or target for (var i = 0; i < 10; i++) { dot.x = minX + Math.random() * (maxX - minX); dot.y = minY + Math.random() * (maxY - minY); // Check overlap with character or target if (!dot.intersects(hiCharacter) && !dot.intersects(hiTarget)) break; } hiDots.push(dot); game.addChild(dot); } // Initial dot spawnDot(); // Move handler: drag character, check for dot/target intersections function handleMove(x, y, obj) { if (dragNode) { // Clamp to game area (avoid top left 100x100) var newX = Math.max(hiCharacter.width / 2 + 20, Math.min(2048 - hiCharacter.width / 2 - 20, x)); var newY = Math.max(hiCharacter.height / 2 + 120, Math.min(2732 - hiCharacter.height / 2 - 20, y)); dragNode.x = newX; dragNode.y = newY; } // Check for dot collection for (var i = hiDots.length - 1; i >= 0; i--) { var dot = hiDots[i]; if (hiCharacter.intersects(dot)) { // Collect dot dot.destroy(); hiDots.splice(i, 1); LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); // Spawn a new dot spawnDot(); } } // Check for reaching the target (win condition: must have at least 5 points) var nowIntersecting = hiCharacter.intersects(hiTarget); if (!lastTargetIntersecting && nowIntersecting && LK.getScore() >= 5) { LK.effects.flashScreen(0x83de44, 800); LK.showYouWin(); } lastTargetIntersecting = nowIntersecting; } // Touch/mouse events game.down = function (x, y, obj) { // Only start drag if touch is on character var local = hiCharacter.toLocal(game.toGlobal({ x: x, y: y })); if (local.x >= -hiCharacter.width / 2 && local.x <= hiCharacter.width / 2 && local.y >= -hiCharacter.height / 2 && local.y <= hiCharacter.height / 2) { dragNode = hiCharacter; handleMove(x, y, obj); } }; game.move = handleMove; game.up = function (x, y, obj) { dragNode = null; }; // Game update: not needed for MVP, but required for intersection state tracking game.update = function () { // No per-frame logic needed except for intersection state tracking var nowIntersecting = hiCharacter.intersects(hiTarget); lastTargetIntersecting = nowIntersecting; };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,153 @@
-/****
+/****
+* Classes
+****/
+// No plugins needed for MVP
+// HiCharacter: draggable by the player
+var HiCharacter = Container.expand(function () {
+ var self = Container.call(this);
+ var charAsset = self.attachAsset('hiCharacter', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // For possible future use: down/up events
+ self.down = function (x, y, obj) {};
+ self.up = function (x, y, obj) {};
+ return self;
+});
+// HiDot: collectible, spawns at random positions
+var HiDot = Container.expand(function () {
+ var self = Container.call(this);
+ var dotAsset = self.attachAsset('hiDot', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+// HiTarget: the goal area
+var HiTarget = Container.expand(function () {
+ var self = Container.call(this);
+ var targetAsset = self.attachAsset('hiTarget', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xf7f7f7
+});
+
+/****
+* Game Code
+****/
+// Character: red box, Target: green ellipse, Dot: yellow ellipse.
+// "Hi" themed assets: a character, a target, and a collectible "dot".
+// Center positions
+var centerX = 2048 / 2;
+var centerY = 2732 / 2;
+// Score display
+var scoreTxt = new Text2('0', {
+ size: 140,
+ fill: 0x222222
+});
+scoreTxt.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreTxt);
+// "Hı!" greeting text at the top center, below the score
+var hiTxt = new Text2('Hı!', {
+ size: 120,
+ fill: 0xD83318
+});
+hiTxt.anchor.set(0.5, 0);
+hiTxt.y = 160;
+LK.gui.top.addChild(hiTxt);
+// Create and position the target near the bottom center
+var hiTarget = new HiTarget();
+hiTarget.x = centerX;
+hiTarget.y = 2732 - 350;
+game.addChild(hiTarget);
+// Create and position the character near the top center
+var hiCharacter = new HiCharacter();
+hiCharacter.x = centerX;
+hiCharacter.y = 500;
+game.addChild(hiCharacter);
+// Dots array
+var hiDots = [];
+// Dragging logic
+var dragNode = null;
+// For intersection state tracking
+var lastTargetIntersecting = false;
+// Helper: spawn a dot at a random position (not overlapping with target or character)
+function spawnDot() {
+ var dot = new HiDot();
+ // Avoid top 200px and bottom 400px, and avoid left/right 100px
+ var minX = 100 + dot.width / 2;
+ var maxX = 2048 - 100 - dot.width / 2;
+ var minY = 300 + dot.height / 2;
+ var maxY = 2732 - 400 - dot.height / 2;
+ // Try up to 10 times to avoid spawning on character or target
+ for (var i = 0; i < 10; i++) {
+ dot.x = minX + Math.random() * (maxX - minX);
+ dot.y = minY + Math.random() * (maxY - minY);
+ // Check overlap with character or target
+ if (!dot.intersects(hiCharacter) && !dot.intersects(hiTarget)) break;
+ }
+ hiDots.push(dot);
+ game.addChild(dot);
+}
+// Initial dot
+spawnDot();
+// Move handler: drag character, check for dot/target intersections
+function handleMove(x, y, obj) {
+ if (dragNode) {
+ // Clamp to game area (avoid top left 100x100)
+ var newX = Math.max(hiCharacter.width / 2 + 20, Math.min(2048 - hiCharacter.width / 2 - 20, x));
+ var newY = Math.max(hiCharacter.height / 2 + 120, Math.min(2732 - hiCharacter.height / 2 - 20, y));
+ dragNode.x = newX;
+ dragNode.y = newY;
+ }
+ // Check for dot collection
+ for (var i = hiDots.length - 1; i >= 0; i--) {
+ var dot = hiDots[i];
+ if (hiCharacter.intersects(dot)) {
+ // Collect dot
+ dot.destroy();
+ hiDots.splice(i, 1);
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ // Spawn a new dot
+ spawnDot();
+ }
+ }
+ // Check for reaching the target (win condition: must have at least 5 points)
+ var nowIntersecting = hiCharacter.intersects(hiTarget);
+ if (!lastTargetIntersecting && nowIntersecting && LK.getScore() >= 5) {
+ LK.effects.flashScreen(0x83de44, 800);
+ LK.showYouWin();
+ }
+ lastTargetIntersecting = nowIntersecting;
+}
+// Touch/mouse events
+game.down = function (x, y, obj) {
+ // Only start drag if touch is on character
+ var local = hiCharacter.toLocal(game.toGlobal({
+ x: x,
+ y: y
+ }));
+ if (local.x >= -hiCharacter.width / 2 && local.x <= hiCharacter.width / 2 && local.y >= -hiCharacter.height / 2 && local.y <= hiCharacter.height / 2) {
+ dragNode = hiCharacter;
+ handleMove(x, y, obj);
+ }
+};
+game.move = handleMove;
+game.up = function (x, y, obj) {
+ dragNode = null;
+};
+// Game update: not needed for MVP, but required for intersection state tracking
+game.update = function () {
+ // No per-frame logic needed except for intersection state tracking
+ var nowIntersecting = hiCharacter.intersects(hiTarget);
+ lastTargetIntersecting = nowIntersecting;
+};
\ No newline at end of file
Man. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Witch. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat
Beatuful yellow Hair woman. No background. Transparent background. Blank background. No shadows. 2d. In-Game asset. flat