User prompt
color theme dark green background
User prompt
it shoots very small red squares
User prompt
pink square drags sideways and shoots red cubes
User prompt
make the pink square shoot green rays and when hitting the balls the score changes numbers
User prompt
make neon green balls descend and each time they are hit they disappear
User prompt
put dots at the top right color numbers white with illuminated blue border
User prompt
remove the green squares that come down
User prompt
remove the light green squares
User prompt
make the pink square big and fire light green squares and when hitting other squares make them disappear
Initial prompt
Yronix
/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 2; self.move = function () { self.y += self.speed; }; }); // EnemyBullet class var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5 }); self.speed = 5; self.move = function () { self.y += self.speed; }; }); // Assets will be automatically generated based on usage in the code. // Hero class var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 }); heroGraphics.tint = 0xFF69B4; self.move = function (x, y) { self.x = x; self.y = y; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Global variables var hero = new Hero(); hero.x = 1024; // Center horizontally hero.y = 2500; // Near the bottom var enemies = []; var enemyBullets = []; // Add hero to the game game.addChild(hero); // Touch event to move hero and shoot game.on('down', function (obj) { var pos = obj.event.getLocalPosition(game); hero.move(pos.x, pos.y); hero.shoot(); }); // Game tick event LK.on('tick', function () { // Move enemies and enemy bullets for (var j = enemies.length - 1; j >= 0; j--) { enemies[j].move(); if (enemies[j].y > 2732) { // Enemy off-screen enemies[j].destroy(); enemies.splice(j, 1); } } for (var k = enemyBullets.length - 1; k >= 0; k--) { enemyBullets[k].move(); if (enemyBullets[k].y > 2732) { // Bullet off-screen enemyBullets[k].destroy(); enemyBullets.splice(k, 1); } // Check collision with hero if (hero.intersects(enemyBullets[k])) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } // Spawn enemies and bullets if (LK.ticks % 120 == 0) { // Every 2 seconds var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = 0; game.addChild(enemy); enemies.push(enemy); var enemyBullet = new EnemyBullet(); enemyBullet.x = enemy.x; enemyBullet.y = enemy.y + 50; game.addChild(enemyBullet); enemyBullets.push(enemyBullet); } });
===================================================================
--- original.js
+++ change.js
@@ -39,29 +39,9 @@
self.move = function (x, y) {
self.x = x;
self.y = y;
};
- self.shoot = function () {
- var bullet = new HeroBullet();
- bullet.x = self.x;
- bullet.y = self.y - 50; // Shoot from above the hero
- game.addChild(bullet);
- heroBullets.push(bullet);
- };
});
-// HeroBullet class
-var HeroBullet = Container.expand(function () {
- var self = Container.call(this);
- var bulletGraphics = self.attachAsset('heroBullet', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- bulletGraphics.tint = 0x90EE90;
- self.speed = -10;
- self.move = function () {
- self.y += self.speed;
- };
-});
/****
* Initialize Game
****/
@@ -75,9 +55,8 @@
// Global variables
var hero = new Hero();
hero.x = 1024; // Center horizontally
hero.y = 2500; // Near the bottom
-var heroBullets = [];
var enemies = [];
var enemyBullets = [];
// Add hero to the game
game.addChild(hero);
@@ -88,17 +67,8 @@
hero.shoot();
});
// Game tick event
LK.on('tick', function () {
- // Move hero bullets
- for (var i = heroBullets.length - 1; i >= 0; i--) {
- heroBullets[i].move();
- if (heroBullets[i].y < 0) {
- // Bullet off-screen
- heroBullets[i].destroy();
- heroBullets.splice(i, 1);
- }
- }
// Move enemies and enemy bullets
for (var j = enemies.length - 1; j >= 0; j--) {
enemies[j].move();
if (enemies[j].y > 2732) {
@@ -118,20 +88,8 @@
if (hero.intersects(enemyBullets[k])) {
LK.effects.flashScreen(0xff0000, 1000);
LK.showGameOver();
}
- // Check collision between hero bullets and enemies
- for (var i = heroBullets.length - 1; i >= 0; i--) {
- for (var j = enemies.length - 1; j >= 0; j--) {
- if (heroBullets[i].intersects(enemies[j])) {
- enemies[j].destroy();
- enemies.splice(j, 1);
- heroBullets[i].destroy();
- heroBullets.splice(i, 1);
- break;
- }
- }
- }
}
// Spawn enemies and bullets
if (LK.ticks % 120 == 0) {
// Every 2 seconds