User prompt
que la banera se mas grand ey gorda
User prompt
que mejor el personaje slata cundo le de click ala pantalla ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
osea mas grandes los enemigos
User prompt
que el player tenga animacion para moverse ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
que sea ams grand eel player
User prompt
que las plataformas esten mas bajas
User prompt
que alla mas lento
User prompt
pero mejor queno salga eso de de nuevo que salga el game over normal
User prompt
pero que no siga la partida
User prompt
que el game over tenga diseño como de una moneda y que tenga un texto que ponga:de nuevo? y cuando el des se reinicie la partida
User prompt
mejor sin flecha sy que sea un runner
User prompt
que en la pantalla aya dos flechas una para moverse a la izquierda y otra a la derecha
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addEventListener')' in or related to this line: 'leftControl.down = function (x, y, obj) {' Line Number: 369
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'addEventListener')' in or related to this line: 'document.addEventListener('keydown', function (e) {' Line Number: 368
User prompt
y que con als flechas se mueva el personaje
User prompt
que el enemigo este ams lejos
User prompt
de plataformas
Code edit (1 edits merged)
Please save this source code
User prompt
Script Master - Text Adventure Creator
User prompt
scriipt
Initial prompt
un juego tipo mario bros 1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Coin = Container.expand(function (startX, startY) { var self = Container.call(this); var coinGraphics = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.collected = false; self.x = startX || 400; self.y = startY || 2300; self.update = function () { if (!self.collected) { self.rotation += 0.1; } }; self.collect = function () { if (!self.collected) { self.collected = true; self.alpha = 0; LK.setScore(LK.getScore() + 10); LK.getSound('coin_collect').play(); } }; return self; }); var Enemy = Container.expand(function (startX, startY) { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 1 }); self.velocityX = -2; self.velocityY = 0; self.gravity = 0.8; self.alive = true; self.x = startX || 800; self.y = startY || 2400; self.update = function () { if (!self.alive) return; // Apply gravity self.velocityY += self.gravity; // Update position self.x += self.velocityX; self.y += self.velocityY; // Ground collision if (self.y >= 2400) { self.y = 2400; self.velocityY = 0; } // Platform collision for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; if (self.intersects(platform) && self.velocityY > 0) { if (self.y - 25 <= platform.y - 20) { self.y = platform.y - 20; self.velocityY = 0; break; } } } // Reverse direction at edges if (self.x < 50 || self.x > levelWidth - 50) { self.velocityX = -self.velocityX; } }; self.defeat = function () { self.alive = false; self.alpha = 0.5; LK.getSound('enemy_hit').play(); LK.setTimeout(function () { self.destroy(); }, 500); }; return self; }); var Platform = Container.expand(function (startX, startY, width) { var self = Container.call(this); self.platformWidth = width || 200; var platformGraphics = self.attachAsset('platform', { anchorX: 0.5, anchorY: 0.5, width: self.platformWidth }); self.x = startX || 400; self.y = startY || 2000; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 1 }); self.velocityX = 0; self.velocityY = 0; self.gravity = 0.8; self.jumpPower = -18; self.speed = 8; self.onGround = false; self.lastOnGround = false; self.x = 200; self.y = 2400; self.update = function () { // Apply gravity self.velocityY += self.gravity; // Update position self.x += self.velocityX; self.y += self.velocityY; // Ground collision if (self.y >= 2400) { self.y = 2400; self.velocityY = 0; self.onGround = true; } else { self.onGround = false; } // Platform collision for (var i = 0; i < platforms.length; i++) { var platform = platforms[i]; if (self.intersects(platform) && self.velocityY > 0) { if (self.y - 40 <= platform.y - 20) { self.y = platform.y - 20; self.velocityY = 0; self.onGround = true; break; } } } // Keep player on screen if (self.x < 30) self.x = 30; if (self.x > 2018) self.x = 2018; // Update camera cameraX = self.x - 1024; if (cameraX < 0) cameraX = 0; if (cameraX > levelWidth - 2048) cameraX = levelWidth - 2048; self.lastOnGround = self.onGround; }; self.jump = function () { if (self.onGround) { self.velocityY = self.jumpPower; self.onGround = false; LK.getSound('jump').play(); } }; self.moveLeft = function () { self.velocityX = -self.speed; }; self.moveRight = function () { self.velocityX = self.speed; }; self.stop = function () { self.velocityX = 0; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb }); /**** * Game Code ****/ // Game variables var levelWidth = 4000; var cameraX = 0; var platforms = []; var enemies = []; var coins = []; var player = new Player(); var gameContainer = new Container(); var leftPressed = false; var rightPressed = false; // Add game container to game game.addChild(gameContainer); gameContainer.addChild(player); // Create ground var ground = gameContainer.attachAsset('ground', { x: 0, y: 2460, width: levelWidth, anchorX: 0, anchorY: 0 }); // Create platforms var platformData = [{ x: 600, y: 2200, width: 200 }, { x: 1000, y: 2000, width: 200 }, { x: 1400, y: 1800, width: 200 }, { x: 1800, y: 2100, width: 200 }, { x: 2200, y: 1900, width: 200 }, { x: 2600, y: 1700, width: 200 }, { x: 3000, y: 1500, width: 200 }, { x: 3400, y: 1800, width: 200 }]; for (var i = 0; i < platformData.length; i++) { var platData = platformData[i]; var platform = new Platform(platData.x, platData.y, platData.width); platforms.push(platform); gameContainer.addChild(platform); } // Create enemies var enemyData = [{ x: 800, y: 2400 }, { x: 1200, y: 2400 }, { x: 2000, y: 2400 }, { x: 2800, y: 2400 }]; for (var i = 0; i < enemyData.length; i++) { var enemyPos = enemyData[i]; var enemy = new Enemy(enemyPos.x, enemyPos.y); enemies.push(enemy); gameContainer.addChild(enemy); } // Create coins var coinData = [{ x: 400, y: 2300 }, { x: 700, y: 2100 }, { x: 1100, y: 1900 }, { x: 1500, y: 1700 }, { x: 1900, y: 2000 }, { x: 2300, y: 1800 }, { x: 2700, y: 1600 }, { x: 3100, y: 1400 }, { x: 3500, y: 1700 }]; for (var i = 0; i < coinData.length; i++) { var coinPos = coinData[i]; var coin = new Coin(coinPos.x, coinPos.y); coins.push(coin); gameContainer.addChild(coin); } // Create finish flag var flag = gameContainer.attachAsset('flag', { x: 3800, y: 2340, anchorX: 0.5, anchorY: 1 }); // Create UI var scoreText = new Text2('Score: 0', { size: 48, fill: '#ffffff' }); scoreText.anchor.set(0, 0); scoreText.x = 50; scoreText.y = 50; LK.gui.topLeft.addChild(scoreText); var instructionText = new Text2('Touch left/right to move, tap to jump!', { size: 32, fill: '#ffffff' }); instructionText.anchor.set(0.5, 0); instructionText.x = 1024; instructionText.y = 100; LK.gui.top.addChild(instructionText); // Control areas for mobile var leftControl = game.attachAsset('platform', { x: 0, y: 2200, width: 512, height: 532, alpha: 0.1, anchorX: 0, anchorY: 0 }); var rightControl = game.attachAsset('platform', { x: 512, y: 2200, width: 512, height: 532, alpha: 0.1, anchorX: 0, anchorY: 0 }); var jumpControl = game.attachAsset('platform', { x: 1024, y: 2200, width: 1024, height: 532, alpha: 0.1, anchorX: 0, anchorY: 0 }); // Touch controls leftControl.down = function (x, y, obj) { leftPressed = true; }; leftControl.up = function (x, y, obj) { leftPressed = false; }; rightControl.down = function (x, y, obj) { rightPressed = true; }; rightControl.up = function (x, y, obj) { rightPressed = false; }; jumpControl.down = function (x, y, obj) { player.jump(); }; game.update = function () { // Handle movement if (leftPressed) { player.moveLeft(); } else if (rightPressed) { player.moveRight(); } else { player.stop(); } // Update player player.update(); // Update enemies for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; enemy.update(); } // Update coins for (var i = 0; i < coins.length; i++) { var coin = coins[i]; coin.update(); } // Check collisions with enemies for (var i = enemies.length - 1; i >= 0; i--) { var enemy = enemies[i]; if (enemy.alive && player.intersects(enemy)) { if (player.velocityY > 0 && player.y < enemy.y - 20) { // Player jumped on enemy enemy.defeat(); enemies.splice(i, 1); player.velocityY = -10; // Bounce LK.setScore(LK.getScore() + 50); } else { // Player hit enemy LK.getSound('game_over').play(); LK.showGameOver(); return; } } } // Check collisions with coins for (var i = coins.length - 1; i >= 0; i--) { var coin = coins[i]; if (!coin.collected && player.intersects(coin)) { coin.collect(); coins.splice(i, 1); } } // Check if player reached flag if (player.intersects(flag)) { LK.showYouWin(); return; } // Check if player fell off screen if (player.y > 2800) { LK.getSound('game_over').play(); LK.showGameOver(); return; } // Update camera gameContainer.x = -cameraX; // Update score display scoreText.setText('Score: ' + LK.getScore()); };
===================================================================
--- original.js
+++ change.js
@@ -5,295 +5,416 @@
/****
* Classes
****/
-var ScriptCharacter = Container.expand(function (name, x, y, color) {
+var Coin = Container.expand(function (startX, startY) {
var self = Container.call(this);
- self.characterName = name || 'Character';
- self.characterColor = color || 0x4a90e2;
- var characterGraphics = self.attachAsset('character', {
+ var coinGraphics = self.attachAsset('coin', {
anchorX: 0.5,
- anchorY: 1,
- tint: self.characterColor
+ anchorY: 0.5
});
- var nameText = new Text2(self.characterName, {
- size: 24,
- fill: '#ffffff'
+ self.collected = false;
+ self.x = startX || 400;
+ self.y = startY || 2300;
+ self.update = function () {
+ if (!self.collected) {
+ self.rotation += 0.1;
+ }
+ };
+ self.collect = function () {
+ if (!self.collected) {
+ self.collected = true;
+ self.alpha = 0;
+ LK.setScore(LK.getScore() + 10);
+ LK.getSound('coin_collect').play();
+ }
+ };
+ return self;
+});
+var Enemy = Container.expand(function (startX, startY) {
+ var self = Container.call(this);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 1
});
- nameText.anchor.set(0.5, 1);
- nameText.y = -130;
- self.addChild(nameText);
- self.x = x || 100;
- self.y = y || 500;
- self.speak = function (text) {
- var speechBubble = new Text2(text, {
- size: 20,
- fill: '#000000'
- });
- speechBubble.anchor.set(0.5, 1);
- speechBubble.y = -150;
- self.addChild(speechBubble);
- tween(speechBubble, {
- alpha: 0
- }, {
- duration: 3000,
- onFinish: function onFinish() {
- speechBubble.destroy();
+ self.velocityX = -2;
+ self.velocityY = 0;
+ self.gravity = 0.8;
+ self.alive = true;
+ self.x = startX || 800;
+ self.y = startY || 2400;
+ self.update = function () {
+ if (!self.alive) return;
+ // Apply gravity
+ self.velocityY += self.gravity;
+ // Update position
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ // Ground collision
+ if (self.y >= 2400) {
+ self.y = 2400;
+ self.velocityY = 0;
+ }
+ // Platform collision
+ for (var i = 0; i < platforms.length; i++) {
+ var platform = platforms[i];
+ if (self.intersects(platform) && self.velocityY > 0) {
+ if (self.y - 25 <= platform.y - 20) {
+ self.y = platform.y - 20;
+ self.velocityY = 0;
+ break;
+ }
}
- });
+ }
+ // Reverse direction at edges
+ if (self.x < 50 || self.x > levelWidth - 50) {
+ self.velocityX = -self.velocityX;
+ }
};
- self.moveTo = function (newX, newY) {
- tween(self, {
- x: newX,
- y: newY
- }, {
- duration: 1000,
- easing: tween.easeInOut
- });
+ self.defeat = function () {
+ self.alive = false;
+ self.alpha = 0.5;
+ LK.getSound('enemy_hit').play();
+ LK.setTimeout(function () {
+ self.destroy();
+ }, 500);
};
return self;
});
-var ScriptExecutor = Container.expand(function () {
+var Platform = Container.expand(function (startX, startY, width) {
var self = Container.call(this);
- self.characters = {};
- self.currentScene = null;
- self.executeCommand = function (command) {
- var parts = command.trim().split(' ');
- var action = parts[0].toLowerCase();
- try {
- switch (action) {
- case 'create':
- if (parts[1] === 'character') {
- var name = parts[2] || 'Character';
- var x = parseInt(parts[3]) || 100;
- var y = parseInt(parts[4]) || 500;
- var color = parseInt(parts[5]) || 0x4a90e2;
- var character = new ScriptCharacter(name, x, y, color);
- self.characters[name] = character;
- visualOutput.addChild(character);
- LK.getSound('success').play();
- }
+ self.platformWidth = width || 200;
+ var platformGraphics = self.attachAsset('platform', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: self.platformWidth
+ });
+ self.x = startX || 400;
+ self.y = startY || 2000;
+ return self;
+});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 1
+ });
+ self.velocityX = 0;
+ self.velocityY = 0;
+ self.gravity = 0.8;
+ self.jumpPower = -18;
+ self.speed = 8;
+ self.onGround = false;
+ self.lastOnGround = false;
+ self.x = 200;
+ self.y = 2400;
+ self.update = function () {
+ // Apply gravity
+ self.velocityY += self.gravity;
+ // Update position
+ self.x += self.velocityX;
+ self.y += self.velocityY;
+ // Ground collision
+ if (self.y >= 2400) {
+ self.y = 2400;
+ self.velocityY = 0;
+ self.onGround = true;
+ } else {
+ self.onGround = false;
+ }
+ // Platform collision
+ for (var i = 0; i < platforms.length; i++) {
+ var platform = platforms[i];
+ if (self.intersects(platform) && self.velocityY > 0) {
+ if (self.y - 40 <= platform.y - 20) {
+ self.y = platform.y - 20;
+ self.velocityY = 0;
+ self.onGround = true;
break;
- case 'move':
- var charName = parts[1];
- var newX = parseInt(parts[2]) || 100;
- var newY = parseInt(parts[3]) || 500;
- if (self.characters[charName]) {
- self.characters[charName].moveTo(newX, newY);
- LK.getSound('success').play();
- }
- break;
- case 'say':
- var charName = parts[1];
- var text = parts.slice(2).join(' ');
- if (self.characters[charName]) {
- self.characters[charName].speak(text);
- LK.getSound('success').play();
- }
- break;
- case 'scene':
- var sceneColor = parseInt(parts[1]) || 0x87ceeb;
- if (self.currentScene) {
- self.currentScene.tint = sceneColor;
- }
- LK.getSound('success').play();
- break;
- case 'clear':
- for (var charName in self.characters) {
- self.characters[charName].destroy();
- }
- self.characters = {};
- LK.getSound('success').play();
- break;
- default:
- LK.getSound('error').play();
- break;
+ }
}
- } catch (e) {
- LK.getSound('error').play();
}
+ // Keep player on screen
+ if (self.x < 30) self.x = 30;
+ if (self.x > 2018) self.x = 2018;
+ // Update camera
+ cameraX = self.x - 1024;
+ if (cameraX < 0) cameraX = 0;
+ if (cameraX > levelWidth - 2048) cameraX = levelWidth - 2048;
+ self.lastOnGround = self.onGround;
};
+ self.jump = function () {
+ if (self.onGround) {
+ self.velocityY = self.jumpPower;
+ self.onGround = false;
+ LK.getSound('jump').play();
+ }
+ };
+ self.moveLeft = function () {
+ self.velocityX = -self.speed;
+ };
+ self.moveRight = function () {
+ self.velocityX = self.speed;
+ };
+ self.stop = function () {
+ self.velocityX = 0;
+ };
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x0f0f0f
+ backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
-// Create split-screen interface
-var textEditor = game.attachAsset('textEditor', {
- x: 24,
- y: 66
-});
-var visualOutput = game.attachAsset('visualOutput', {
- x: 1024,
- y: 66
-});
-// Create scene background
-var sceneBackground = visualOutput.attachAsset('background', {
+// Game variables
+var levelWidth = 4000;
+var cameraX = 0;
+var platforms = [];
+var enemies = [];
+var coins = [];
+var player = new Player();
+var gameContainer = new Container();
+var leftPressed = false;
+var rightPressed = false;
+// Add game container to game
+game.addChild(gameContainer);
+gameContainer.addChild(player);
+// Create ground
+var ground = gameContainer.attachAsset('ground', {
x: 0,
- y: 0
+ y: 2460,
+ width: levelWidth,
+ anchorX: 0,
+ anchorY: 0
});
-// Create script executor
-var scriptExecutor = new ScriptExecutor();
-scriptExecutor.currentScene = sceneBackground;
-// Create UI elements
-var titleText = new Text2('Script Master', {
+// Create platforms
+var platformData = [{
+ x: 600,
+ y: 2200,
+ width: 200
+}, {
+ x: 1000,
+ y: 2000,
+ width: 200
+}, {
+ x: 1400,
+ y: 1800,
+ width: 200
+}, {
+ x: 1800,
+ y: 2100,
+ width: 200
+}, {
+ x: 2200,
+ y: 1900,
+ width: 200
+}, {
+ x: 2600,
+ y: 1700,
+ width: 200
+}, {
+ x: 3000,
+ y: 1500,
+ width: 200
+}, {
+ x: 3400,
+ y: 1800,
+ width: 200
+}];
+for (var i = 0; i < platformData.length; i++) {
+ var platData = platformData[i];
+ var platform = new Platform(platData.x, platData.y, platData.width);
+ platforms.push(platform);
+ gameContainer.addChild(platform);
+}
+// Create enemies
+var enemyData = [{
+ x: 800,
+ y: 2400
+}, {
+ x: 1200,
+ y: 2400
+}, {
+ x: 2000,
+ y: 2400
+}, {
+ x: 2800,
+ y: 2400
+}];
+for (var i = 0; i < enemyData.length; i++) {
+ var enemyPos = enemyData[i];
+ var enemy = new Enemy(enemyPos.x, enemyPos.y);
+ enemies.push(enemy);
+ gameContainer.addChild(enemy);
+}
+// Create coins
+var coinData = [{
+ x: 400,
+ y: 2300
+}, {
+ x: 700,
+ y: 2100
+}, {
+ x: 1100,
+ y: 1900
+}, {
+ x: 1500,
+ y: 1700
+}, {
+ x: 1900,
+ y: 2000
+}, {
+ x: 2300,
+ y: 1800
+}, {
+ x: 2700,
+ y: 1600
+}, {
+ x: 3100,
+ y: 1400
+}, {
+ x: 3500,
+ y: 1700
+}];
+for (var i = 0; i < coinData.length; i++) {
+ var coinPos = coinData[i];
+ var coin = new Coin(coinPos.x, coinPos.y);
+ coins.push(coin);
+ gameContainer.addChild(coin);
+}
+// Create finish flag
+var flag = gameContainer.attachAsset('flag', {
+ x: 3800,
+ y: 2340,
+ anchorX: 0.5,
+ anchorY: 1
+});
+// Create UI
+var scoreText = new Text2('Score: 0', {
size: 48,
fill: '#ffffff'
});
-titleText.anchor.set(0.5, 0);
-titleText.x = 1024;
-titleText.y = 10;
-game.addChild(titleText);
-var editorLabel = new Text2('Script Editor', {
+scoreText.anchor.set(0, 0);
+scoreText.x = 50;
+scoreText.y = 50;
+LK.gui.topLeft.addChild(scoreText);
+var instructionText = new Text2('Touch left/right to move, tap to jump!', {
size: 32,
fill: '#ffffff'
});
-editorLabel.anchor.set(0, 0);
-editorLabel.x = 24;
-editorLabel.y = 20;
-game.addChild(editorLabel);
-var outputLabel = new Text2('Visual Output', {
- size: 32,
- fill: '#ffffff'
+instructionText.anchor.set(0.5, 0);
+instructionText.x = 1024;
+instructionText.y = 100;
+LK.gui.top.addChild(instructionText);
+// Control areas for mobile
+var leftControl = game.attachAsset('platform', {
+ x: 0,
+ y: 2200,
+ width: 512,
+ height: 532,
+ alpha: 0.1,
+ anchorX: 0,
+ anchorY: 0
});
-outputLabel.anchor.set(0, 0);
-outputLabel.x = 1024;
-outputLabel.y = 20;
-game.addChild(outputLabel);
-// Create execute button
-var executeButton = game.attachAsset('executeButton', {
- x: 124,
- y: 2300,
- anchorX: 0.5,
- anchorY: 0.5
+var rightControl = game.attachAsset('platform', {
+ x: 512,
+ y: 2200,
+ width: 512,
+ height: 532,
+ alpha: 0.1,
+ anchorX: 0,
+ anchorY: 0
});
-var executeText = new Text2('Execute', {
- size: 24,
- fill: '#ffffff'
-});
-executeText.anchor.set(0.5, 0.5);
-executeText.x = 124;
-executeText.y = 2300;
-game.addChild(executeText);
-// Create clear button
-var clearButton = game.attachAsset('clearButton', {
- x: 374,
- y: 2300,
- anchorX: 0.5,
- anchorY: 0.5
-});
-var clearText = new Text2('Clear', {
- size: 24,
- fill: '#ffffff'
-});
-clearText.anchor.set(0.5, 0.5);
-clearText.x = 374;
-clearText.y = 2300;
-game.addChild(clearText);
-// Create help text
-var helpText = new Text2('Commands:\ncreate character [name] [x] [y] [color]\nmove [character] [x] [y]\nsay [character] [text]\nscene [color]\nclear', {
- size: 20,
- fill: '#888888'
-});
-helpText.anchor.set(0, 0);
-helpText.x = 50;
-helpText.y = 100;
-game.addChild(helpText);
-// Text input simulation
-var currentText = '';
-var textLines = [];
-var cursorVisible = true;
-var cursorTimer = 0;
-var maxLines = 45;
-var textDisplay = new Text2('', {
- size: 20,
- fill: '#00ff00'
-});
-textDisplay.anchor.set(0, 0);
-textDisplay.x = 50;
-textDisplay.y = 300;
-game.addChild(textDisplay);
-var cursor = game.attachAsset('cursor', {
- x: 50,
- y: 300,
+var jumpControl = game.attachAsset('platform', {
+ x: 1024,
+ y: 2200,
+ width: 1024,
+ height: 532,
+ alpha: 0.1,
anchorX: 0,
anchorY: 0
});
-// Sample commands for demonstration
-var sampleCommands = ['create character Hero 200 500 0x4a90e2', 'create character Villain 800 500 0xe24a4a', 'say Hero Hello world!', 'move Hero 400 500', 'say Villain I am the villain!', 'scene 0x8b4513'];
-var commandIndex = 0;
-var autoExecuteTimer = 0;
-// Button interactions
-executeButton.down = function (x, y, obj) {
- if (currentText.trim()) {
- scriptExecutor.executeCommand(currentText.trim());
- textLines.push('> ' + currentText.trim());
- currentText = '';
- updateTextDisplay();
- }
+// Touch controls
+leftControl.down = function (x, y, obj) {
+ leftPressed = true;
};
-clearButton.down = function (x, y, obj) {
- currentText = '';
- textLines = [];
- scriptExecutor.executeCommand('clear');
- updateTextDisplay();
+leftControl.up = function (x, y, obj) {
+ leftPressed = false;
};
-function updateTextDisplay() {
- var displayText = textLines.slice(-maxLines).join('\n');
- if (currentText) {
- displayText += '\n> ' + currentText;
- }
- textDisplay.setText(displayText);
- // Update cursor position
- var lines = displayText.split('\n');
- var lastLine = lines[lines.length - 1] || '';
- cursor.y = 300 + (lines.length - 1) * 25;
- cursor.x = 50 + lastLine.length * 12;
-}
-// Simulate typing for demo
+rightControl.down = function (x, y, obj) {
+ rightPressed = true;
+};
+rightControl.up = function (x, y, obj) {
+ rightPressed = false;
+};
+jumpControl.down = function (x, y, obj) {
+ player.jump();
+};
game.update = function () {
- // Cursor blinking
- cursorTimer++;
- if (cursorTimer >= 30) {
- cursorVisible = !cursorVisible;
- cursor.alpha = cursorVisible ? 1 : 0;
- cursorTimer = 0;
+ // Handle movement
+ if (leftPressed) {
+ player.moveLeft();
+ } else if (rightPressed) {
+ player.moveRight();
+ } else {
+ player.stop();
}
- // Auto-execute sample commands for demonstration
- autoExecuteTimer++;
- if (autoExecuteTimer >= 180 && commandIndex < sampleCommands.length) {
- var command = sampleCommands[commandIndex];
- currentText = command;
- updateTextDisplay();
- // Auto-execute after a short delay
- LK.setTimeout(function () {
- scriptExecutor.executeCommand(command);
- textLines.push('> ' + command);
- currentText = '';
- updateTextDisplay();
- commandIndex++;
- }, 1000);
- autoExecuteTimer = 0;
+ // Update player
+ player.update();
+ // Update enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ enemy.update();
}
- updateTextDisplay();
-};
-// Touch input for mobile typing simulation
-game.down = function (x, y, obj) {
- if (x < 1024) {
- // Clicked in editor area
- LK.getSound('keypress').play();
- // Simple character addition simulation
- var chars = 'abcdefghijklmnopqrstuvwxyz0123456789 ';
- var randomChar = chars[Math.floor(Math.random() * chars.length)];
- if (currentText.length < 50) {
- currentText += randomChar;
+ // Update coins
+ for (var i = 0; i < coins.length; i++) {
+ var coin = coins[i];
+ coin.update();
+ }
+ // Check collisions with enemies
+ for (var i = enemies.length - 1; i >= 0; i--) {
+ var enemy = enemies[i];
+ if (enemy.alive && player.intersects(enemy)) {
+ if (player.velocityY > 0 && player.y < enemy.y - 20) {
+ // Player jumped on enemy
+ enemy.defeat();
+ enemies.splice(i, 1);
+ player.velocityY = -10; // Bounce
+ LK.setScore(LK.getScore() + 50);
+ } else {
+ // Player hit enemy
+ LK.getSound('game_over').play();
+ LK.showGameOver();
+ return;
+ }
}
}
+ // Check collisions with coins
+ for (var i = coins.length - 1; i >= 0; i--) {
+ var coin = coins[i];
+ if (!coin.collected && player.intersects(coin)) {
+ coin.collect();
+ coins.splice(i, 1);
+ }
+ }
+ // Check if player reached flag
+ if (player.intersects(flag)) {
+ LK.showYouWin();
+ return;
+ }
+ // Check if player fell off screen
+ if (player.y > 2800) {
+ LK.getSound('game_over').play();
+ LK.showGameOver();
+ return;
+ }
+ // Update camera
+ gameContainer.x = -cameraX;
+ // Update score display
+ scoreText.setText('Score: ' + LK.getScore());
};
\ No newline at end of file