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
===================================================================
--- original.js
+++ change.js
@@ -27,9 +27,28 @@
self.move = function (x, y) {
self.x = x;
self.y = y;
};
+ self.shoot = function () {
+ var newRay = new HeroRay();
+ newRay.x = self.x;
+ newRay.y = self.y;
+ heroRays.push(newRay);
+ game.addChild(newRay);
+ };
});
+// HeroRay class
+var HeroRay = Container.expand(function () {
+ var self = Container.call(this);
+ var rayGraphics = self.attachAsset('heroRay', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = -5;
+ self.move = function () {
+ self.y += self.speed;
+ };
+});
// NeonGreenBall class
var NeonGreenBall = Container.expand(function () {
var self = Container.call(this);
var ballGraphics = self.attachAsset('neonGreenBall', {
@@ -70,8 +89,9 @@
// Touch event to move hero and destroy neon green balls
game.on('down', function (obj) {
var pos = obj.event.getLocalPosition(game);
hero.move(pos.x, pos.y);
+ hero.shoot();
for (var i = neonGreenBalls.length - 1; i >= 0; i--) {
if (hero.intersects(neonGreenBalls[i])) {
neonGreenBalls[i].destroy();
neonGreenBalls.splice(i, 1);
@@ -79,18 +99,36 @@
}
});
// Global variables
var neonGreenBalls = [];
+var heroRays = [];
// Game tick event
LK.on('tick', function () {
- // Move neon green balls
+ // Move neon green balls and hero rays
for (var i = neonGreenBalls.length - 1; i >= 0; i--) {
neonGreenBalls[i].move();
if (neonGreenBalls[i].y > 2732) {
neonGreenBalls[i].destroy();
neonGreenBalls.splice(i, 1);
}
}
+ for (var i = heroRays.length - 1; i >= 0; i--) {
+ heroRays[i].move();
+ if (heroRays[i].y < 0) {
+ heroRays[i].destroy();
+ heroRays.splice(i, 1);
+ }
+ for (var j = neonGreenBalls.length - 1; j >= 0; j--) {
+ if (heroRays[i] && heroRays[i].intersects(neonGreenBalls[j])) {
+ neonGreenBalls[j].destroy();
+ neonGreenBalls.splice(j, 1);
+ heroRays[i].destroy();
+ heroRays.splice(i, 1);
+ LK.setScore(LK.getScore() + 1);
+ scoreTxt.setText(LK.getScore());
+ }
+ }
+ }
// Spawn neon green balls
if (LK.ticks % 60 == 0) {
var newBall = new NeonGreenBall();
newBall.x = Math.random() * 2048;