Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
Add a full width full height background on the back of everything
User prompt
Remove the Player: ... AI: ... score text elements. Instead, use the PLAYER and AI which are at -160 to also show the score like PLAYER(10) AI(2)
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
No sorry, I want two background assets - one for the AI background and one for the player background
Code edit (7 edits merged)
Please save this source code
User prompt
Add a background asset that is full screen covering the back of my screen
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix: gray lines disappear. They should never nor for the player nor for the ai
User prompt
No, remove the controls of the pieces for the player (rotation, moving down, moving left, moving right). Instead, on the bottom of the game screen, place 4 widgets, 1 per rotate clockwise, one to move left, one to move right, one to move down. Full width, like on the bottom on the screen after the AI and PLayer screens.
User prompt
Change a little the controls for the player: - You rotate a piece if you click on it. - You move left a piece if you click on the left of a piece or left above the piece, but never left below. - You move right a piece if you click on the right of a piece or right above the piece, but never right below.
User prompt
There is a bug: if I have lines that I got from my competitor, when a new piece lands they are translated to my competitor screen. That is not right. Lines that appeared in my screen from my competitor stay forever in my screen.
User prompt
Only move pieces right or left on down, if the y position of the tap is more or less the same as the y of the currently moving piece. Don't move left or right a piece if it's above or below the piece.
User prompt
Can you make it so that every line achieved by the player appears on the bottom of the AI pushing all pieces up, and the same from the player if the AI achieves a line? Kind of a "competitive" mode.
User prompt
For the fast drop mode - can It be only while I'm holding the mouse button / tapping the screen? If I release it it goes out from the fast mode. Thank you.
User prompt
For the player: if I click below the piece, the piece goes quicker down.
User prompt
For the player, If I click on the right of the current moving piece, the piece moves right. If I click on the left, the piece moves left. If I click exactly on the piece, the piece rotates.
Code edit (1 edits merged)
Please save this source code
User prompt
Blank Canvas
Initial prompt
An empty game
/**** * Classes ****/ var TouchIndicator = Container.expand(function () { var self = Container.call(this); var indicatorGraphics = self.attachAsset('touchIndicator', { anchorX: 0.5, anchorY: 0.5 }); self.fadeOut = function () { indicatorGraphics.alpha = 0.8; // Simple fade out over time self.fadeTimer = 30; // 30 frames to fade out }; self.update = function () { if (self.fadeTimer && self.fadeTimer > 0) { self.fadeTimer--; indicatorGraphics.alpha = self.fadeTimer / 30 * 0.8; if (self.fadeTimer <= 0) { self.destroy(); } } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xFFFFFF }); /**** * Game Code ****/ // Create background canvas area var canvasArea = game.addChild(LK.getAsset('canvasBackground', { anchorX: 0, anchorY: 0, x: 0, y: 0, alpha: 0.1 })); // Touch indicators array var touchIndicators = []; // Coordinate display var coordinateText = new Text2('Touch the canvas to begin', { size: 48, fill: 0x333333 }); coordinateText.anchor.set(0.5, 0.5); coordinateText.x = 1024; coordinateText.y = 1366; game.addChild(coordinateText); // Title text var titleText = new Text2('Blank Canvas', { size: 72, fill: 0x2196F3 }); titleText.anchor.set(0.5, 0); titleText.x = 1024; titleText.y = 200; game.addChild(titleText); // Subtitle text var subtitleText = new Text2('Interactive Foundation for Game Development', { size: 36, fill: 0x666666 }); subtitleText.anchor.set(0.5, 0); subtitleText.x = 1024; subtitleText.y = 300; game.addChild(subtitleText); // Instructions text var instructionText = new Text2('Touch anywhere on the screen\nto see coordinate feedback', { size: 42, fill: 0x888888 }); instructionText.anchor.set(0.5, 0.5); instructionText.x = 1024; instructionText.y = 1500; game.addChild(instructionText); // Touch counter var touchCount = 0; var touchCountText = new Text2('Touches: 0', { size: 54, fill: 0xFF5722 }); touchCountText.anchor.set(0.5, 0); LK.gui.top.addChild(touchCountText); // Active touch indicator var activeTouchIndicator = null; // Handle touch/mouse down game.down = function (x, y, obj) { // Update touch count touchCount++; touchCountText.setText('Touches: ' + touchCount); // Update coordinate display coordinateText.setText('X: ' + Math.round(x) + ', Y: ' + Math.round(y)); // Create touch indicator at touch position var indicator = new TouchIndicator(); indicator.x = x; indicator.y = y; touchIndicators.push(indicator); game.addChild(indicator); indicator.fadeOut(); // Store reference to active touch activeTouchIndicator = indicator; }; // Handle touch/mouse move game.move = function (x, y, obj) { // Update coordinate display during drag coordinateText.setText('X: ' + Math.round(x) + ', Y: ' + Math.round(y) + ' (dragging)'); // Move active touch indicator if exists if (activeTouchIndicator && activeTouchIndicator.fadeTimer > 20) { activeTouchIndicator.x = x; activeTouchIndicator.y = y; } }; // Handle touch/mouse up game.up = function (x, y, obj) { // Clear active touch reference activeTouchIndicator = null; // Update coordinate display coordinateText.setText('Released at X: ' + Math.round(x) + ', Y: ' + Math.round(y)); }; // Main game update loop game.update = function () { // Clean up destroyed touch indicators for (var i = touchIndicators.length - 1; i >= 0; i--) { var indicator = touchIndicators[i]; if (indicator.fadeTimer !== undefined && indicator.fadeTimer <= 0) { touchIndicators.splice(i, 1); } } // Simple animation for title text if (LK.ticks % 120 === 0) { titleText.alpha = titleText.alpha === 1 ? 0.7 : 1; } };
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,140 @@
-/****
+/****
+* Classes
+****/
+var TouchIndicator = Container.expand(function () {
+ var self = Container.call(this);
+ var indicatorGraphics = self.attachAsset('touchIndicator', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.fadeOut = function () {
+ indicatorGraphics.alpha = 0.8;
+ // Simple fade out over time
+ self.fadeTimer = 30; // 30 frames to fade out
+ };
+ self.update = function () {
+ if (self.fadeTimer && self.fadeTimer > 0) {
+ self.fadeTimer--;
+ indicatorGraphics.alpha = self.fadeTimer / 30 * 0.8;
+ if (self.fadeTimer <= 0) {
+ self.destroy();
+ }
+ }
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xFFFFFF
+});
+
+/****
+* Game Code
+****/
+// Create background canvas area
+var canvasArea = game.addChild(LK.getAsset('canvasBackground', {
+ anchorX: 0,
+ anchorY: 0,
+ x: 0,
+ y: 0,
+ alpha: 0.1
+}));
+// Touch indicators array
+var touchIndicators = [];
+// Coordinate display
+var coordinateText = new Text2('Touch the canvas to begin', {
+ size: 48,
+ fill: 0x333333
+});
+coordinateText.anchor.set(0.5, 0.5);
+coordinateText.x = 1024;
+coordinateText.y = 1366;
+game.addChild(coordinateText);
+// Title text
+var titleText = new Text2('Blank Canvas', {
+ size: 72,
+ fill: 0x2196F3
+});
+titleText.anchor.set(0.5, 0);
+titleText.x = 1024;
+titleText.y = 200;
+game.addChild(titleText);
+// Subtitle text
+var subtitleText = new Text2('Interactive Foundation for Game Development', {
+ size: 36,
+ fill: 0x666666
+});
+subtitleText.anchor.set(0.5, 0);
+subtitleText.x = 1024;
+subtitleText.y = 300;
+game.addChild(subtitleText);
+// Instructions text
+var instructionText = new Text2('Touch anywhere on the screen\nto see coordinate feedback', {
+ size: 42,
+ fill: 0x888888
+});
+instructionText.anchor.set(0.5, 0.5);
+instructionText.x = 1024;
+instructionText.y = 1500;
+game.addChild(instructionText);
+// Touch counter
+var touchCount = 0;
+var touchCountText = new Text2('Touches: 0', {
+ size: 54,
+ fill: 0xFF5722
+});
+touchCountText.anchor.set(0.5, 0);
+LK.gui.top.addChild(touchCountText);
+// Active touch indicator
+var activeTouchIndicator = null;
+// Handle touch/mouse down
+game.down = function (x, y, obj) {
+ // Update touch count
+ touchCount++;
+ touchCountText.setText('Touches: ' + touchCount);
+ // Update coordinate display
+ coordinateText.setText('X: ' + Math.round(x) + ', Y: ' + Math.round(y));
+ // Create touch indicator at touch position
+ var indicator = new TouchIndicator();
+ indicator.x = x;
+ indicator.y = y;
+ touchIndicators.push(indicator);
+ game.addChild(indicator);
+ indicator.fadeOut();
+ // Store reference to active touch
+ activeTouchIndicator = indicator;
+};
+// Handle touch/mouse move
+game.move = function (x, y, obj) {
+ // Update coordinate display during drag
+ coordinateText.setText('X: ' + Math.round(x) + ', Y: ' + Math.round(y) + ' (dragging)');
+ // Move active touch indicator if exists
+ if (activeTouchIndicator && activeTouchIndicator.fadeTimer > 20) {
+ activeTouchIndicator.x = x;
+ activeTouchIndicator.y = y;
+ }
+};
+// Handle touch/mouse up
+game.up = function (x, y, obj) {
+ // Clear active touch reference
+ activeTouchIndicator = null;
+ // Update coordinate display
+ coordinateText.setText('Released at X: ' + Math.round(x) + ', Y: ' + Math.round(y));
+};
+// Main game update loop
+game.update = function () {
+ // Clean up destroyed touch indicators
+ for (var i = touchIndicators.length - 1; i >= 0; i--) {
+ var indicator = touchIndicators[i];
+ if (indicator.fadeTimer !== undefined && indicator.fadeTimer <= 0) {
+ touchIndicators.splice(i, 1);
+ }
+ }
+ // Simple animation for title text
+ if (LK.ticks % 120 === 0) {
+ titleText.alpha = titleText.alpha === 1 ? 0.7 : 1;
+ }
+};
\ No newline at end of file