User prompt
Separate the hearts counter and make them heart shaped
User prompt
Add hearts that came and the user couñd grb them and win life also make the life hearts bigger ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Keep shooting when user keep his finger on screen
User prompt
Make a life counter with 3 hearts and just lose 1 heart when hitted
User prompt
Put instructions on screen
User prompt
One tap jump keep the tap and shoot
User prompt
One tap jump two taps shoot
User prompt
Only shoot strs when double tap
User prompt
The shooting starts when double tap
User prompt
Make the character to be able to advance and move with the finger and shoot stars
Remix started
Copy Mario vs Monsters
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * 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 () { self.x -= self.speed; if (self.x < -50) { self.destroy(); } }; }); // Define a class for collectible hearts var Heart = Container.expand(function () { var self = Container.call(this); var heartGraphics = self.attachAsset('heart', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); self.speed = 5; self.lastY = self.y; self.lastX = self.x; // Add some floating animation self.floatOffset = Math.random() * Math.PI * 2; self.floatSpeed = 0.05; self.baseY = 0; self.update = function () { // Store last position for collision detection self.lastY = self.y; self.lastX = self.x; // Move the heart self.x -= self.speed; // Floating animation self.y = self.baseY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 20; // Remove if offscreen if (self.x < -50) { self.destroy(); } }; return self; }); //<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 () { 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; } }; }); // Define a class for star bullets var Star = Container.expand(function () { var self = Container.call(this); // Create a yellow star shape using the built-in shape feature var starGraphics = self.attachAsset('star', { width: 50, height: 50, color: 0xffff00, shape: 'box', anchorX: 0.5, anchorY: 0.5 }); self.speed = 10; // Store the last position for collision detection self.lastY = self.y; self.lastX = self.x; self.update = function () { // Store last position before update self.lastY = self.y; self.lastX = self.x; // Move the star forward self.x += self.speed; // Remove if it goes off-screen if (self.x > 2048 + 50) { self.destroy(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB // Sky blue background }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('background', { anchorX: 0, anchorY: 0 })); background.x = 0; background.y = 0; // Initialize player var player = game.addChild(new Player()); player.x = 2048 / 2; player.y = 2732 / 2; player.lives = 3; player.invulnerable = false; player.invulnerableTime = 0; // Initialize enemies var enemies = []; var enemySpawnInterval = 100; var enemySpawnCounter = 0; // Initialize collectible hearts var collectibleHearts = []; var heartSpawnInterval = 300; // Less frequent than enemies var heartSpawnCounter = 0; // Create life display var hearts = []; var heartsContainer = new Container(); LK.gui.topRight.addChild(heartsContainer); heartsContainer.x = -200; // Offset from right edge heartsContainer.y = 50; // Offset from top edge // Create heart icons for (var i = 0; i < player.lives; i++) { var heart = heartsContainer.addChild(LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 })); heart.x = -i * 100; // Position hearts horizontally with spacing (increased spacing for bigger hearts) hearts.push(heart); } // Create a new Text2 object to display the score var scoreText = new Text2('0', { size: 100, fill: 0xFFFFFF }); // Add the score text to the game GUI at the top center of the screen LK.gui.top.addChild(scoreText); scoreText.x = 2048 / 2; scoreText.y = 0; // Create instruction text var instructionText = new Text2('Tap to JUMP\nHold to SHOOT', { size: 80, fill: 0xFFFFFF, align: 'center' }); instructionText.anchor.set(0.5, 0); LK.gui.center.addChild(instructionText); instructionText.y = 300; // Create a timeout to hide instructions after 5 seconds LK.setTimeout(function () { // Fade out instructions var alpha = 1; var fadeInterval = LK.setInterval(function () { alpha -= 0.1; instructionText.alpha = alpha; if (alpha <= 0) { LK.clearInterval(fadeInterval); instructionText.visible = false; } }, 100); }, 5000); // Handle game updates // Array to store bullets var stars = []; var shootTimer = 0; game.update = function () { player.update(); // Handle player invulnerability if (player.invulnerable) { // Make player flash to indicate invulnerability player.alpha = Math.sin(Date.now() * 0.01) * 0.5 + 0.5; // End invulnerability after 2 seconds if (Date.now() - player.invulnerableTime > 2000) { player.invulnerable = false; player.alpha = 1; } } // Removed auto-shooting to only allow double tap shooting // Update stars for (var i = stars.length - 1; i >= 0; i--) { stars[i].update(); // Remove stars that are destroyed if (!stars[i].parent) { stars.splice(i, 1); continue; } // Check for star-enemy collisions for (var j = enemies.length - 1; j >= 0; j--) { if (stars[i] && enemies[j] && stars[i].intersects(enemies[j])) { // Remove the enemy and the star enemies[j].destroy(); enemies.splice(j, 1); stars[i].destroy(); stars.splice(i, 1); // Update score LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); break; } } } // Update hearts for (var i = hearts.length - 1; i >= 0; i--) { if (hearts[i] && !hearts[i].parent) { hearts.splice(i, 1); } } // Update collectible hearts for (var i = collectibleHearts.length - 1; i >= 0; i--) { collectibleHearts[i].update(); // Remove hearts that are destroyed if (!collectibleHearts[i].parent) { collectibleHearts.splice(i, 1); continue; } // Check for player-heart collisions if (player.intersects(collectibleHearts[i])) { // Player collected a heart collectibleHearts[i].destroy(); collectibleHearts.splice(i, 1); // Add a life if not at maximum if (player.lives < 5) { player.lives++; // Add a heart to the display var heart = heartsContainer.addChild(LK.getAsset('heart', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 })); heart.x = -hearts.length * 100; hearts.push(heart); // Show animation effect tween(heart, { scaleX: 3, scaleY: 3 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(heart, { scaleX: 2.5, scaleY: 2.5 }, { duration: 300, easing: tween.easeIn }); } }); } } } // 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; } // Spawn collectible hearts heartSpawnCounter++; if (heartSpawnCounter >= heartSpawnInterval) { var heart = new Heart(); heart.x = 2048; heart.y = Math.random() * (2732 / 2) + 600; // Random height but not too low heart.baseY = heart.y; collectibleHearts.push(heart); game.addChild(heart); // Randomize the spawn interval for the next heart (less frequent than enemies) heartSpawnInterval = Math.floor(Math.random() * 300) + 300; heartSpawnCounter = 0; } // Update enemies for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].update(); if (player.intersects(enemies[j]) && !player.invulnerable) { // Player was hit, lose a life player.lives--; // Play hit sound LK.getSound('hit').play(); // Flash screen to indicate damage LK.effects.flashScreen(0xff0000, 500); // Make player temporarily invulnerable player.invulnerable = true; player.invulnerableTime = Date.now(); // Update hearts display - remove one heart if (hearts.length > 0) { var heart = hearts.pop(); heart.destroy(); } // Check if player is out of lives if (player.lives <= 0) { LK.showGameOver(); } else { // Destroy the enemy that hit the player enemies[j].destroy(); enemies.splice(j, 1); } } else if (player.x > enemies[j].x && !enemies[j].passed) { enemies[j].passed = true; LK.setScore(LK.getScore() + 1); scoreText.setText(LK.getScore()); } } }; // Handle player interaction var dragNode = null; // Function to handle movement and shooting while holding function handleMove(x, y, obj) { if (dragNode) { dragNode.x = x; // Keep the player at the same vertical position if not jumping if (!player.isJumping) { dragNode.y = 2732 / 2; } // If holding finger on screen, continuously shoot if (shootTimer > 0) { // Only shoot every 10 ticks to control fire rate if (LK.ticks % 10 === 0) { var star = new Star(); star.x = player.x + 100; star.y = player.y; stars.push(star); game.addChild(star); // Play shooting sound LK.getSound('shoot').play(); } } } } // shootTimer already declared earlier in the code // Start tracking player movement on touch down and shoot on hold game.down = function (x, y, obj) { // Always make the player jump on tap player.jump(); // Start shooting timer shootTimer = Date.now(); // Handle regular movement dragNode = player; handleMove(x, y, obj); }; // Update player position during movement game.move = handleMove; // Stop tracking player movement and shooting on touch up game.up = function (x, y, obj) { dragNode = null; shootTimer = 0; // Reset shoot timer };
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Classes
****/
// Define a class for enemies
var Enemy = Container.expand(function () {
@@ -15,8 +20,39 @@
self.destroy();
}
};
});
+// Define a class for collectible hearts
+var Heart = Container.expand(function () {
+ var self = Container.call(this);
+ var heartGraphics = self.attachAsset('heart', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2,
+ scaleY: 2
+ });
+ self.speed = 5;
+ self.lastY = self.y;
+ self.lastX = self.x;
+ // Add some floating animation
+ self.floatOffset = Math.random() * Math.PI * 2;
+ self.floatSpeed = 0.05;
+ self.baseY = 0;
+ self.update = function () {
+ // Store last position for collision detection
+ self.lastY = self.y;
+ self.lastX = self.x;
+ // Move the heart
+ self.x -= self.speed;
+ // Floating animation
+ self.y = self.baseY + Math.sin(LK.ticks * self.floatSpeed + self.floatOffset) * 20;
+ // Remove if offscreen
+ if (self.x < -50) {
+ self.destroy();
+ }
+ };
+ return self;
+});
//<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);
@@ -103,8 +139,12 @@
// Initialize enemies
var enemies = [];
var enemySpawnInterval = 100;
var enemySpawnCounter = 0;
+// Initialize collectible hearts
+var collectibleHearts = [];
+var heartSpawnInterval = 300; // Less frequent than enemies
+var heartSpawnCounter = 0;
// Create life display
var hearts = [];
var heartsContainer = new Container();
LK.gui.topRight.addChild(heartsContainer);
@@ -113,11 +153,13 @@
// Create heart icons
for (var i = 0; i < player.lives; i++) {
var heart = heartsContainer.addChild(LK.getAsset('heart', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 2.5,
+ scaleY: 2.5
}));
- heart.x = -i * 60; // Position hearts horizontally with spacing
+ heart.x = -i * 100; // Position hearts horizontally with spacing (increased spacing for bigger hearts)
hearts.push(heart);
}
// Create a new Text2 object to display the score
var scoreText = new Text2('0', {
@@ -189,8 +231,59 @@
break;
}
}
}
+ // Update hearts
+ for (var i = hearts.length - 1; i >= 0; i--) {
+ if (hearts[i] && !hearts[i].parent) {
+ hearts.splice(i, 1);
+ }
+ }
+ // Update collectible hearts
+ for (var i = collectibleHearts.length - 1; i >= 0; i--) {
+ collectibleHearts[i].update();
+ // Remove hearts that are destroyed
+ if (!collectibleHearts[i].parent) {
+ collectibleHearts.splice(i, 1);
+ continue;
+ }
+ // Check for player-heart collisions
+ if (player.intersects(collectibleHearts[i])) {
+ // Player collected a heart
+ collectibleHearts[i].destroy();
+ collectibleHearts.splice(i, 1);
+ // Add a life if not at maximum
+ if (player.lives < 5) {
+ player.lives++;
+ // Add a heart to the display
+ var heart = heartsContainer.addChild(LK.getAsset('heart', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 2.5,
+ scaleY: 2.5
+ }));
+ heart.x = -hearts.length * 100;
+ hearts.push(heart);
+ // Show animation effect
+ tween(heart, {
+ scaleX: 3,
+ scaleY: 3
+ }, {
+ duration: 300,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(heart, {
+ scaleX: 2.5,
+ scaleY: 2.5
+ }, {
+ duration: 300,
+ easing: tween.easeIn
+ });
+ }
+ });
+ }
+ }
+ }
// Spawn enemies
enemySpawnCounter++;
if (enemySpawnCounter >= enemySpawnInterval) {
var enemy = new Enemy();
@@ -201,8 +294,21 @@
// Randomize the spawn interval for the next enemy
enemySpawnInterval = Math.floor(Math.random() * 150) + 50;
enemySpawnCounter = 0;
}
+ // Spawn collectible hearts
+ heartSpawnCounter++;
+ if (heartSpawnCounter >= heartSpawnInterval) {
+ var heart = new Heart();
+ heart.x = 2048;
+ heart.y = Math.random() * (2732 / 2) + 600; // Random height but not too low
+ heart.baseY = heart.y;
+ collectibleHearts.push(heart);
+ game.addChild(heart);
+ // Randomize the spawn interval for the next heart (less frequent than enemies)
+ heartSpawnInterval = Math.floor(Math.random() * 300) + 300;
+ heartSpawnCounter = 0;
+ }
// Update enemies
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j].update();
if (player.intersects(enemies[j]) && !player.invulnerable) {
I need an octopus that looks like bowser. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows
Heart illustration red shinny. Single Game Texture. 2d. Blank background. High contrast. No shadows
Star illustration shinny. Single Game Texture. Blank background. High contrast. No shadows
Make it more detailed and add flying dinosaurs
Re imagine