User prompt
also make it if it crouching monstores wint spawn and make it go back up when stop crouching
User prompt
when it crouches dont let it go up just down
User prompt
when u crouch jumps and glitches fix it
User prompt
add chrouching aniamation ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Please fix the bug: 'window.addEventListener is not a function' in or related to this line: 'window.addEventListener('keydown', function (e) {' Line Number: 383
User prompt
with the joystick make crouching work with it or when u press s
User prompt
add joystick for movement
User prompt
there is no mobile button
User prompt
Please fix the bug: 'storage.has is not a function' in or related to this line: 'if (storage && storage.has('touchControlsEnabled')) {' Line Number: 114 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
Please fix the bug: 'storage is not defined' in or related to this line: 'if (storage && storage.has('touchControlsEnabled')) {' Line Number: 109 ↪💡 Consider importing and using the following plugins: @upit/storage.v1
User prompt
make it so u can enable touch controls from pause button even on pc
User prompt
make it mobile firendly
Remix started
Copy Mario vs Monsters
/**** * Classes ****/ // Define a class for enemies var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.update = function () { // Track last position for collision detection self.lastX = self.x; self.lastY = self.y; self.lastWasIntersecting = false; self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); //<Assets used in the game will automatically appear here> // Define a class for the player character var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.jumpHeight = 40; self.isJumping = false; self.velocityY = 0; self.update = function () { // Track last position for collision detection self.lastX = self.x; self.lastY = self.y; if (self.isJumping) { self.y += self.velocityY; self.velocityY += 0.7; // Decreased gravity effect by 30% if (self.y >= 2732 / 2) { // Ground level self.y = 2732 / 2; self.isJumping = false; self.velocityY = 0; } } }; self.jump = function () { if (!self.isJumping) { self.isJumping = true; self.velocityY = -self.jumpHeight; } }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ // Make background fit the screen properly var background = game.addChild(LK.getAsset('background', { anchorX: 0.5, anchorY: 0.5 })); background.x = 2048 / 2; background.y = 2732 / 2; // Initialize player var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; // Initialize enemies var enemies = []; var enemySpawnInterval = 100; var enemySpawnCounter = 0; // Create a new Text2 object to display the score with better mobile visibility var scoreText = new Text2('Score: 0', { size: 120, fill: 0xFFFFFF, stroke: 0x000000, strokeThickness: 5 }); // Add the score text to the game GUI at the top center of the screen // Anchoring properly for responsive display scoreText.anchor.set(0.5, 0); LK.gui.top.addChild(scoreText); // Handle game updates game.update = function () { player.update(); // Spawn enemies enemySpawnCounter++; if (enemySpawnCounter >= enemySpawnInterval) { var enemy = new Enemy(); enemy.x = 2048; enemy.y = 2732 / 2; enemies.push(enemy); game.addChild(enemy); // Randomize the spawn interval for the next enemy enemySpawnInterval = Math.floor(Math.random() * 150) + 50; enemySpawnCounter = 0; } // Update enemies with better collision detection for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); // More precise collision detection if (player.intersects(enemies[j])) { if (!enemies[j].lastWasIntersecting) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } enemies[j].lastWasIntersecting = true; } else { enemies[j].lastWasIntersecting = false; // Check if player passed the enemy if (player.x > enemies[j].x && !enemies[j].passed) { enemies[j].passed = true; LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); // Visual feedback when scoring var pointText = new Text2('+1', { size: 60, fill: 0xFFFFFF }); pointText.x = enemies[j].x; pointText.y = enemies[j].y - 100; game.addChild(pointText); // Animate and remove the +1 text LK.setTimeout(function () { pointText.destroy(); }, 1000); } } } }; // Handle player jump with improved controls for mobile game.down = function (x, y, obj) { // Jump when tapping anywhere on screen player.jump(); }; // Add move handler for potential drag controls game.move = function (x, y, obj) { // Can be expanded for more mobile controls if needed }; // Initialize the score to zero scoreText.setText('0'); // Make score text more visible on mobile screens scoreText.size = 120;
===================================================================
--- original.js
+++ change.js
@@ -9,8 +9,12 @@
anchorY: 0.5
});
self.speed = 5;
self.update = function () {
+ // Track last position for collision detection
+ self.lastX = self.x;
+ self.lastY = self.y;
+ self.lastWasIntersecting = false;
self.x -= self.speed;
if (self.x < -50) {
self.destroy();
}
@@ -28,8 +32,11 @@
self.jumpHeight = 40;
self.isJumping = false;
self.velocityY = 0;
self.update = function () {
+ // Track last position for collision detection
+ self.lastX = self.x;
+ self.lastY = self.y;
if (self.isJumping) {
self.y += self.velocityY;
self.velocityY += 0.7; // Decreased gravity effect by 30%
if (self.y >= 2732 / 2) {
@@ -57,31 +64,34 @@
/****
* Game Code
****/
+// Make background fit the screen properly
var background = game.addChild(LK.getAsset('background', {
- anchorX: 0,
- anchorY: 0
+ anchorX: 0.5,
+ anchorY: 0.5
}));
-background.x = 0;
-background.y = 0;
+background.x = 2048 / 2;
+background.y = 2732 / 2;
// Initialize player
var player = game.addChild(new Player());
player.x = 2048 / 2;
player.y = 2732 / 2;
// Initialize enemies
var enemies = [];
var enemySpawnInterval = 100;
var enemySpawnCounter = 0;
-// Create a new Text2 object to display the score
-var scoreText = new Text2('0', {
- size: 100,
- fill: "#ffffff"
+// Create a new Text2 object to display the score with better mobile visibility
+var scoreText = new Text2('Score: 0', {
+ size: 120,
+ fill: 0xFFFFFF,
+ stroke: 0x000000,
+ strokeThickness: 5
});
// Add the score text to the game GUI at the top center of the screen
+// Anchoring properly for responsive display
+scoreText.anchor.set(0.5, 0);
LK.gui.top.addChild(scoreText);
-scoreText.x = 2048 / 2;
-scoreText.y = 0;
// Handle game updates
game.update = function () {
player.update();
// Spawn enemies
@@ -95,21 +105,50 @@
// Randomize the spawn interval for the next enemy
enemySpawnInterval = Math.floor(Math.random() * 150) + 50;
enemySpawnCounter = 0;
}
- // Update enemies
+ // Update enemies with better collision detection
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j].update();
+ // More precise collision detection
if (player.intersects(enemies[j])) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
- } else if (player.x > enemies[j].x && !enemies[j].passed) {
- enemies[j].passed = true;
- LK.setScore(LK.getScore() + 1);
- scoreText.setText(LK.getScore());
+ if (!enemies[j].lastWasIntersecting) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ enemies[j].lastWasIntersecting = true;
+ } else {
+ enemies[j].lastWasIntersecting = false;
+ // Check if player passed the enemy
+ if (player.x > enemies[j].x && !enemies[j].passed) {
+ enemies[j].passed = true;
+ LK.setScore(LK.getScore() + 1);
+ scoreText.setText(LK.getScore());
+ // Visual feedback when scoring
+ var pointText = new Text2('+1', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ pointText.x = enemies[j].x;
+ pointText.y = enemies[j].y - 100;
+ game.addChild(pointText);
+ // Animate and remove the +1 text
+ LK.setTimeout(function () {
+ pointText.destroy();
+ }, 1000);
+ }
}
}
};
-// Handle player jump
+// Handle player jump with improved controls for mobile
game.down = function (x, y, obj) {
+ // Jump when tapping anywhere on screen
player.jump();
-};
\ No newline at end of file
+};
+// Add move handler for potential drag controls
+game.move = function (x, y, obj) {
+ // Can be expanded for more mobile controls if needed
+};
+// Initialize the score to zero
+scoreText.setText('0');
+// Make score text more visible on mobile screens
+scoreText.size = 120;
\ No newline at end of file