User prompt
imrpove trail to look more like and engine particle
User prompt
engime particle should eemit particles
User prompt
attache trail to player and make sure it moves when player rotates.
User prompt
attach trail to the player
User prompt
do not auto rotate the player
User prompt
when player rotates, trail should keep his same shape and size, but rotate behind the player. so it should always keep the same distance and position from the player
User prompt
trail should rotate attached to the player hwne its rotating
User prompt
trail should roatate when player rotates
User prompt
player final position should be 200 pixels higher
User prompt
make trail wider
User prompt
Use this code for player trail: var Trail = Container.expand(function () { var self = Container.call(this); var trailGraphics = self.attachAsset('trail', { anchorX: 0.5, anchorY: 0.5, alpha: 0.5 }); self.speed = 5; self.update = function () { self.y += self.speed; self.alpha -= 0.02; // Fade out the trail faster self.scale.x -= 0.02; // Shrink the trail faster self.scale.y -= 0.02; // Shrink the trail faster if (self.y > 2732 || self.alpha <= 0 || self.scale.x <= 0 || self.scale.y <= 0) { self.destroy(); } }; });
User prompt
particle emitter should alwasy move downwrdas
User prompt
create a particle trail below the player. it should be from more to less and also dissapearing in time
User prompt
remove engine particle
User prompt
add a trail behind the player
User prompt
add explosion effect when an enemy is destroyed
User prompt
Migrate to the latest version of LK
Code edit (5 edits merged)
Please save this source code
User prompt
make herobullet while charging flicker faster
Code edit (1 edits merged)
Please save this source code
Code edit (5 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
whos trace of the same color of the bullet behind it after shot
User prompt
Fix Bug: 'TypeError: heroBullets[i].move is not a function' in this line: 'if (heroBullets[i]) heroBullets[i].move();' Line Number: 324
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,15 +1,85 @@
+/****
+* Classes
+****/
+var Background = Container.expand(function () {
+ var self = Container.call(this);
+ var bg1 = self.attachAsset('background', {});
+ var bg2 = self.attachAsset('background', {});
+ bg1.width = bg2.width = 2048;
+ bg1.height = bg2.height = 2732;
+ bg2.y = -2732;
+ self.addChild(bg1);
+ self.addChild(bg2);
+ self._move_migrated = function () {
+ bg1.y += 1;
+ bg2.y += 1;
+ if (bg1.y >= 2732) {
+ bg1.y = -2732;
+ }
+ if (bg2.y >= 2732) {
+ bg2.y = -2732;
+ }
+ };
+});
+var Cloud = Container.expand(function () {
+ var self = Container.call(this);
+ var trail = LK.getAsset('trail', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var cloudGraphics = self.attachAsset('cloud', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedY = 1;
+ self._move_migrated = function () {
+ var cloudSpeed = 3.5;
+ self.y += cloudSpeed;
+ if (self.y > 2732) {
+ self.y = -cloudGraphics.height;
+ }
+ };
+});
+var Enemy = Container.expand(function (hero) {
+ var self = Container.call(this);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speedY = 2;
+ self.hero = hero;
+ self.lifebar = self.attachAsset('lifebar', {
+ anchorX: 0.5
+ });
+ self.lifebar.y = -self.lifebar.height - 100;
+ self.life = 100;
+ self._move_migrated = function () {
+ var dx = this.hero.x - this.x;
+ var dy = this.hero.y - this.y;
+ var angle = Math.atan2(dy, dx);
+ var speedMultiplier = 1 + Math.floor(LK.ticks / 7200);
+ self.x += (Math.cos(angle) * self.speedY + Math.sin(LK.ticks / 60) * 5) * speedMultiplier;
+ self.y += Math.sin(angle) * self.speedY * speedMultiplier;
+ self.lifebar.scale.x = self.life / 100;
+ };
+});
var EnemyBoss = Container.expand(function (hero) {
var self = Container.call(this);
- var bossGraphics = self.createAsset('enemyBoss', 'Enemy Boss Graphics', .5, .5);
+ var bossGraphics = self.attachAsset('enemyBoss', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
bossGraphics.tint = 0xFFFFFF * (0.5 + Math.random() * 0.5);
self.speedY = 3;
self.hero = hero;
- self.lifebar = self.createAsset('lifebar', 'Boss Lifebar', .5, 0);
+ self.lifebar = self.attachAsset('lifebar', {
+ anchorX: 0.5
+ });
self.lifebar.y = -self.lifebar.height - 170;
self.lifebar.x -= 10;
self.life = 500;
- self.move = function () {
+ self._move_migrated = function () {
var dx = this.hero.x - this.x + (Math.random() - 0.5) * 100;
var dy = this.hero.y - this.y + (Math.random() - 0.5) * 100;
var angle = Math.atan2(dy, dx);
var newX = self.x + Math.cos(angle) * self.speedY + Math.sin(LK.ticks / 60) * 5;
@@ -24,69 +94,33 @@
}
};
self.shoot = function () {};
self.on('tick', function () {
- self.move();
+ self._move_migrated();
self.shoot();
});
});
-var Cloud = Container.expand(function () {
- var self = Container.call(this);
- var trail = LK.getAsset('trail', 'Trail Graphics', 0.5, 0.5);
- var cloudGraphics = self.createAsset('cloud', 'Cloud Graphics', 0.5, 0.5);
- self.speedY = 1;
- self.move = function () {
- var cloudSpeed = 3.5;
- self.y += cloudSpeed;
- if (self.y > 2732) {
- self.y = -cloudGraphics.height;
- }
- };
-});
-var HeroBullet = Container.expand(function (hero) {
- var self = Container.call(this);
- self.bulletGraphics = self.createAsset('heroBullet', 'Hero Bullet Graphics', .5, .5);
- self.creationTick = LK.ticks;
- self.bulletGraphics.tint = 0x6EC1E4;
- self.speed = -1.5;
- self.damage = 1;
- self.isShot = false;
- self.flickerSpeed = 10;
- self.flickerMinAlpha = 0.5;
- self.flickerMaxAlpha = 1;
- self.move = function () {
- self.x += self.speedX * self.scale.x * self.scale.x;
- self.y += self.speedY * self.scale.y * self.scale.y;
- self.rotation += LK.ticks * 0.01;
- self.damage = self.scale.x * self.scale.y;
- var holdDuration = (LK.ticks - self.creationTick) % 240;
- if (holdDuration < 120) {
- var sizeMultiplier = 1 + holdDuration / 40;
- } else {
- var sizeMultiplier = 4 - (holdDuration - 120) / 40;
- }
- self.scale.x = self.scale.y = Math.max(1, sizeMultiplier);
- if (self.flicker) {
- self.alpha += self.flickerSpeed;
- if (self.alpha <= self.flickerMinAlpha || self.alpha >= self.flickerMaxAlpha) {
- self.flickerSpeed *= -1;
- }
- self.alpha = Math.max(self.flickerMinAlpha, Math.min(self.alpha, self.flickerMaxAlpha));
- }
- };
-});
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
- var bulletGraphics = self.createAsset('enemyBullet', 'Enemy Bullet Graphics', .5, .5);
+ var bulletGraphics = self.attachAsset('enemyBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
self.speed = 3;
- self.move = function () {
+ self._move_migrated = function () {
self.y += self.speed;
};
});
var Hero = Container.expand(function () {
var self = Container.call(this);
- var heroGraphics = self.createAsset('hero', 'Hero character', .5, .5);
- var trail = self.createAsset('trail', 'Trail Graphics', 1, 0.5);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ var trail = self.attachAsset('trail', {
+ anchorX: 1,
+ anchorY: 0.5
+ });
trail.rotation = Math.PI / 4;
trail.y = heroGraphics.height / 2 - 80;
trail.x = -heroGraphics.width / 2 + 30;
trail.flicker = true;
@@ -113,285 +147,296 @@
self.movementDirection *= -1;
}
};
});
-var Enemy = Container.expand(function (hero) {
+var HeroBullet = Container.expand(function (hero) {
var self = Container.call(this);
- var enemyGraphics = self.createAsset('enemy', 'Enemy character', .5, .5);
- self.speedY = 2;
- self.hero = hero;
- self.lifebar = self.createAsset('lifebar', 'Enemy Lifebar', .5, 0);
- self.lifebar.y = -self.lifebar.height - 100;
- self.life = 100;
- self.move = function () {
- var dx = this.hero.x - this.x;
- var dy = this.hero.y - this.y;
- var angle = Math.atan2(dy, dx);
- var speedMultiplier = 1 + Math.floor(LK.ticks / 7200);
- self.x += (Math.cos(angle) * self.speedY + Math.sin(LK.ticks / 60) * 5) * speedMultiplier;
- self.y += Math.sin(angle) * self.speedY * speedMultiplier;
- self.lifebar.scale.x = self.life / 100;
- };
-});
-var Background = Container.expand(function () {
- var self = Container.call(this);
- var bg1 = self.createAsset('background', 'Game Background 1', 0, 0);
- var bg2 = self.createAsset('background', 'Game Background 2', 0, 0);
- bg1.width = bg2.width = 2048;
- bg1.height = bg2.height = 2732;
- bg2.y = -2732;
- self.addChild(bg1);
- self.addChild(bg2);
- self.move = function () {
- bg1.y += 1;
- bg2.y += 1;
- if (bg1.y >= 2732) bg1.y = -2732;
- if (bg2.y >= 2732) bg2.y = -2732;
- };
-});
-var Game = Container.expand(function () {
- var self = Container.call(this);
- var getReadyMessage = new Text2('Get Ready!', {
- size: 200,
- fill: '#ffffff',
- align: 'center'
+ self.bulletGraphics = self.attachAsset('heroBullet', {
+ anchorX: 0.5,
+ anchorY: 0.5
});
- getReadyMessage.anchor.set(0.8, 0.8);
- getReadyMessage.x = 2048 / 2;
- getReadyMessage.y = 2732 / 3 - 100;
- getReadyMessage.alpha = 0;
- LK.gui.addChild(getReadyMessage);
- var fadeInInterval = LK.setInterval(function () {
- getReadyMessage.alpha += 0.05;
- if (getReadyMessage.alpha >= 1) {
- LK.clearInterval(fadeInInterval);
+ self.creationTick = LK.ticks;
+ self.bulletGraphics.tint = 0x6EC1E4;
+ self.speed = -1.5;
+ self.damage = 1;
+ self.isShot = false;
+ self.flickerSpeed = 0.7;
+ self.flickerMinAlpha = 0.5;
+ self.flickerMaxAlpha = 1;
+ self._move_migrated = function () {
+ self.x += self.speedX * self.scale.x * self.scale.x;
+ self.y += self.speedY * self.scale.y * self.scale.y;
+ self.rotation += LK.ticks * 0.01;
+ self.damage = self.scale.x * self.scale.y;
+ var holdDuration = (LK.ticks - self.creationTick) % 240;
+ if (holdDuration < 120) {
+ var sizeMultiplier = 1 + holdDuration / 40;
+ } else {
+ var sizeMultiplier = 4 - (holdDuration - 120) / 40;
}
- }, 1000 / 60);
- var getSetMessage = new Text2('(tap or hold for super shot!)', {
- size: 50,
- fill: '#ffffff',
- align: 'center'
- });
- getSetMessage.anchor.set(0.8, 0.8);
- getSetMessage.x = 2048 / 2 - 90;
- getSetMessage.y = getReadyMessage.y + 100;
- LK.gui.addChild(getSetMessage);
- LK.setTimeout(function () {
- var fadeOutInterval = LK.setInterval(function () {
- getReadyMessage.alpha -= 0.05;
- if (getReadyMessage.alpha <= 0) {
- LK.clearInterval(fadeOutInterval);
- getReadyMessage.destroy();
+ self.scale.x = self.scale.y = Math.max(1, sizeMultiplier);
+ if (self.flicker) {
+ self.alpha += self.flickerSpeed;
+ if (self.alpha <= self.flickerMinAlpha || self.alpha >= self.flickerMaxAlpha) {
+ self.flickerSpeed *= -1;
}
- }, 1000 / 60);
- getSetMessage.destroy();
- }, 3000);
- var enemies = [];
- var enemiesSpawnedCount = 0;
- var background = self.addChild(new Background());
- background.alpha = 0.3;
- self.spawnEnemy = function () {
- var enemy;
- if (enemiesSpawnedCount % 10 === 0 && enemiesSpawnedCount !== 0) {
- enemy = new EnemyBoss(hero);
- enemy.scale.x *= 1 * (1 + enemiesSpawnedCount / 100);
- enemy.scale.y *= 1 * (1 + enemiesSpawnedCount / 100);
- enemy.speedY *= 1 * (1 + enemiesSpawnedCount / 100);
- enemy.life *= 1 * (0.5 + enemiesSpawnedCount / 100);
- } else {
- enemy = new Enemy(hero);
+ self.alpha = Math.max(self.flickerMinAlpha, Math.min(self.alpha, self.flickerMaxAlpha));
}
- enemy.x = Math.random() * 2048;
- enemy.y = -enemy.height;
- enemies.push(enemy);
- self.addChild(enemy);
- enemiesSpawnedCount++;
};
- var enemySpawnTicker = 0;
- LK.on('tick', function () {
- var spawnRate = Math.max(30, 120 - Math.floor(LK.ticks / 3600));
- if (enemySpawnTicker++ % spawnRate === 0) {
- self.spawnEnemy();
+});
+
+/****
+* Initialize Game
+****/
+var game = new LK.Game({
+ backgroundColor: 0x000000
+});
+
+/****
+* Game Code
+****/
+var getReadyMessage = new Text2('Get Ready!', {
+ size: 200,
+ fill: '#ffffff',
+ align: 'center'
+});
+getReadyMessage.anchor.set(0.8, 0.8);
+getReadyMessage.x = 2048 / 2;
+getReadyMessage.y = 2732 / 3 - 100;
+getReadyMessage.alpha = 0;
+LK.gui.addChild(getReadyMessage);
+var fadeInInterval = LK.setInterval(function () {
+ getReadyMessage.alpha += 0.05;
+ if (getReadyMessage.alpha >= 1) {
+ LK.clearInterval(fadeInInterval);
+ }
+}, 1000 / 60);
+var getSetMessage = new Text2('(tap or hold for super shot!)', {
+ size: 50,
+ fill: '#ffffff',
+ align: 'center'
+});
+getSetMessage.anchor.set(0.8, 0.8);
+getSetMessage.x = 2048 / 2 - 90;
+getSetMessage.y = getReadyMessage.y + 100;
+LK.gui.addChild(getSetMessage);
+LK.setTimeout(function () {
+ var fadeOutInterval = LK.setInterval(function () {
+ getReadyMessage.alpha -= 0.05;
+ if (getReadyMessage.alpha <= 0) {
+ LK.clearInterval(fadeOutInterval);
+ getReadyMessage.destroy();
}
- });
- stage.on('up', function (obj) {
- if (currentBullet) {
- var pos = obj.event.getLocalPosition(self);
- var dx = pos.x - hero.x;
- var dy = pos.y - hero.y;
- var angle = Math.atan2(dy, dx);
- currentBullet.isShot = true;
- currentBullet.speedX = Math.cos(angle) * 15;
- currentBullet.speedY = Math.sin(angle) * 15;
- hero.rotation = angle;
- heroBullets.push(currentBullet);
- currentBullet = null;
- }
- });
- LK.on('tick', function () {
- hero.updateMovement();
- background.move();
- if (currentBullet) {
- var holdDuration = LK.ticks - holdTime;
- var sizeMultiplier = Math.max(1, 1 + Math.abs(Math.sin(holdDuration / 60)) * 3);
- if (currentBullet.scale.x < sizeMultiplier) {
- currentBullet.scale.x = sizeMultiplier;
- currentBullet.scale.y = sizeMultiplier;
- if (currentBullet.bulletGraphics.width * currentBullet.scale.x > 150) {
- currentBullet.bulletGraphics.tint = 0xFFA500;
- }
+ }, 1000 / 60);
+ getSetMessage.destroy();
+}, 3000);
+var enemies = [];
+var enemiesSpawnedCount = 0;
+var background = game.addChild(new Background());
+background.alpha = 0.3;
+game.spawnEnemy = function () {
+ var enemy;
+ if (enemiesSpawnedCount % 10 === 0 && enemiesSpawnedCount !== 0) {
+ enemy = new EnemyBoss(hero);
+ enemy.scale.x *= 1 * (1 + enemiesSpawnedCount / 100);
+ enemy.scale.y *= 1 * (1 + enemiesSpawnedCount / 100);
+ enemy.speedY *= 1 * (1 + enemiesSpawnedCount / 100);
+ enemy.life *= 1 * (0.5 + enemiesSpawnedCount / 100);
+ } else {
+ enemy = new Enemy(hero);
+ }
+ enemy.x = Math.random() * 2048;
+ enemy.y = -enemy.height;
+ enemies.push(enemy);
+ game.addChild(enemy);
+ enemiesSpawnedCount++;
+};
+var enemySpawnTicker = 0;
+LK.on('tick', function () {
+ var spawnRate = Math.max(30, 120 - Math.floor(LK.ticks / 3600));
+ if (enemySpawnTicker++ % spawnRate === 0) {
+ game.spawnEnemy();
+ }
+});
+game.on('up', function (x, y, obj) {
+ if (currentBullet) {
+ var pos = game.toLocal(obj.global);
+ var dx = pos.x - hero.x;
+ var dy = pos.y - hero.y;
+ var angle = Math.atan2(dy, dx);
+ currentBullet.isShot = true;
+ currentBullet.speedX = Math.cos(angle) * 15;
+ currentBullet.speedY = Math.sin(angle) * 15;
+ hero.rotation = angle;
+ heroBullets.push(currentBullet);
+ currentBullet = null;
+ }
+});
+LK.on('tick', function () {
+ hero.updateMovement();
+ background._move_migrated();
+ if (currentBullet) {
+ var holdDuration = LK.ticks - holdTime;
+ var sizeMultiplier = Math.max(1, 1 + Math.abs(Math.sin(holdDuration / 60)) * 3);
+ if (currentBullet.scale.x < sizeMultiplier) {
+ currentBullet.scale.x = sizeMultiplier;
+ currentBullet.scale.y = sizeMultiplier;
+ if (currentBullet.bulletGraphics.width * currentBullet.scale.x > 150) {
+ currentBullet.bulletGraphics.tint = 0xFFA500;
}
- currentBullet.flicker = true;
- var flickerAmount = Math.abs(Math.sin(LK.ticks / 30)) * (currentBullet.flickerMaxAlpha - currentBullet.flickerMinAlpha);
- currentBullet.alpha = currentBullet.flickerMinAlpha + flickerAmount;
- if (currentBullet.flicker) {
- currentBullet.alpha += currentBullet.flickerSpeed;
- if (currentBullet.alpha <= currentBullet.flickerMinAlpha || currentBullet.alpha >= currentBullet.flickerMaxAlpha) {
- currentBullet.flickerSpeed *= -1;
- }
- currentBullet.alpha = Math.max(currentBullet.flickerMinAlpha, Math.min(currentBullet.alpha, currentBullet.flickerMaxAlpha));
- }
- currentBullet.rotation = hero.rotation;
- currentBullet.x = hero.x;
- currentBullet.y = hero.y - hero.height / 2 - currentBullet.height / 2 - 10;
- currentBullet.flickerSpeed = 0.1;
- currentBullet.flickerMinAlpha = 0.3;
- currentBullet.flickerMaxAlpha = 1;
}
- });
- var currentBullet = null;
- var holdTime = 0;
- var hero;
- hero = self.addChild(new Hero());
- hero.rotation = -Math.PI / 2;
- var touchActive = false;
- stage.on('down', function (obj) {
- if (!touchActive) {
- touchActive = true;
- var pos = obj.event.getLocalPosition(self);
- var dx = pos.x - hero.x;
- var dy = pos.y - hero.y;
- var angle = Math.atan2(dy, dx);
- hero.rotation = angle;
- currentBullet = new HeroBullet(hero);
- currentBullet.x = hero.x;
- currentBullet.y = hero.y - hero.height / 2 - currentBullet.height / 2 - 10;
- currentBullet.rotation = hero.rotation;
- self.addChild(currentBullet);
- if (self.scale.x > 2 && self.scale.y > 2) {
- bulletGraphics.tint = 0xFFA500;
+ currentBullet.flicker = true;
+ var flickerAmount = Math.abs(Math.sin(LK.ticks / 30)) * (currentBullet.flickerMaxAlpha - currentBullet.flickerMinAlpha);
+ currentBullet.alpha = currentBullet.flickerMinAlpha + flickerAmount;
+ if (currentBullet.flicker) {
+ currentBullet.alpha += currentBullet.flickerSpeed;
+ if (currentBullet.alpha <= currentBullet.flickerMinAlpha || currentBullet.alpha >= currentBullet.flickerMaxAlpha) {
+ currentBullet.flickerSpeed *= -1;
}
- holdTime = LK.ticks;
+ currentBullet.alpha = Math.max(currentBullet.flickerMinAlpha, Math.min(currentBullet.alpha, currentBullet.flickerMaxAlpha));
}
- });
- stage.on('up', function (obj) {
- touchActive = false;
- });
- stage.on('move', function (obj) {
- var pos = obj.event.getLocalPosition(self);
+ currentBullet.rotation = hero.rotation;
+ currentBullet.x = hero.x;
+ currentBullet.y = hero.y - hero.height / 2 - currentBullet.height / 2 - 10;
+ currentBullet.flickerSpeed = 0.1;
+ currentBullet.flickerMinAlpha = 0.3;
+ currentBullet.flickerMaxAlpha = 1;
+ }
+});
+var currentBullet = null;
+var holdTime = 0;
+var hero;
+hero = game.addChild(new Hero());
+hero.rotation = -Math.PI / 2;
+var touchActive = false;
+game.on('down', function (x, y, obj) {
+ if (!touchActive) {
+ touchActive = true;
+ var pos = game.toLocal(obj.global);
var dx = pos.x - hero.x;
var dy = pos.y - hero.y;
var angle = Math.atan2(dy, dx);
hero.rotation = angle;
- });
- var enemies = [];
- var heroBullets = [];
- var enemyBullets = [];
- var clouds = [];
- var particles = [];
- for (var i = 0; i < 2; i++) {
- var cloud = new Cloud();
- cloud.alpha = 0.3;
- cloud.x = Math.random() * 2048;
- cloud.y = Math.random() * -2732;
- clouds.push(cloud);
- self.addChildAt(cloud, 1);
+ currentBullet = new HeroBullet(hero);
+ currentBullet.x = hero.x;
+ currentBullet.y = hero.y - hero.height / 2 - currentBullet.height / 2 - 10;
+ currentBullet.rotation = hero.rotation;
+ game.addChild(currentBullet);
+ if (game.scale.x > 2 && game.scale.y > 2) {
+ bulletGraphics.tint = 0xFFA500;
+ }
+ holdTime = LK.ticks;
}
- var scoreTxt = new Text2('0', {
- size: 150,
- fill: "#ffffff",
- dropShadow: true,
- dropShadowColor: "#000000",
- dropShadowBlur: 4,
- dropShadowAngle: Math.PI / 6,
- dropShadowDistance: 6
- });
- LK.gui.topCenter.addChild(scoreTxt);
- var isGameOver = false;
- hero.x = 2048 / 2;
- hero.y = 2732 - 280;
- LK.setTimeout(function () {
- var startPosition = hero.y;
- var endPosition = startPosition - 500;
- var duration = 120;
- var step = (startPosition - endPosition) / duration;
- var currentStep = 0;
- var moveHero = function () {
- if (currentStep < duration) {
- hero.y -= step;
- currentStep++;
- } else if (currentStep < duration * 2) {
- hero.y += step;
- currentStep++;
- } else {
- hero.y = startPosition;
- LK.clearInterval(heroMoveInterval);
- }
- };
- var heroMoveInterval = LK.setInterval(moveHero, 1000 / 60);
- }, 0);
- LK.on('tick', function () {
- for (var i = 0; i < heroBullets.length; i++) {
- if (heroBullets[i]) heroBullets[i].move();
- for (var j = 0; j < enemies.length; j++) {
- if (heroBullets[i] && heroBullets[i].intersects(enemies[j])) {
- enemies[j].life -= heroBullets[i].damage * 10;
- if (enemies[j].life <= 0) {
- var scoreIncrement = enemies[j] instanceof EnemyBoss ? 50 : 10;
- scoreIncrement += Math.floor(LK.ticks / 3600);
- LK.setScore(LK.getScore() + scoreIncrement);
- scoreTxt.setText(LK.getScore().toString());
- enemies[j].destroy();
- enemies.splice(j, 1);
- }
- heroBullets[i].destroy();
- heroBullets.splice(i, 1);
- break;
+});
+game.on('up', function (x, y, obj) {
+ touchActive = false;
+});
+game.on('move', function (x, y, obj) {
+ var pos = game.toLocal(obj.global);
+ var dx = pos.x - hero.x;
+ var dy = pos.y - hero.y;
+ var angle = Math.atan2(dy, dx);
+ hero.rotation = angle;
+});
+var enemies = [];
+var heroBullets = [];
+var enemyBullets = [];
+var clouds = [];
+var particles = [];
+for (var i = 0; i < 2; i++) {
+ var cloud = new Cloud();
+ cloud.alpha = 0.3;
+ cloud.x = Math.random() * 2048;
+ cloud.y = Math.random() * -2732;
+ clouds.push(cloud);
+ game.addChildAt(cloud, 1);
+}
+var scoreTxt = new Text2('0', {
+ size: 150,
+ fill: "#ffffff",
+ dropShadow: true,
+ dropShadowColor: "#000000",
+ dropShadowBlur: 4,
+ dropShadowAngle: Math.PI / 6,
+ dropShadowDistance: 6
+});
+LK.gui.top.addChild(scoreTxt);
+var isGameOver = false;
+hero.x = 2048 / 2;
+hero.y = 2732 - 280;
+LK.setTimeout(function () {
+ var startPosition = hero.y;
+ var endPosition = startPosition - 500;
+ var duration = 120;
+ var step = (startPosition - endPosition) / duration;
+ var currentStep = 0;
+ var moveHero = function moveHero() {
+ if (currentStep < duration) {
+ hero.y -= step;
+ currentStep++;
+ } else if (currentStep < duration * 2) {
+ hero.y += step;
+ currentStep++;
+ } else {
+ hero.y = startPosition;
+ LK.clearInterval(heroMoveInterval);
+ }
+ };
+ var heroMoveInterval = LK.setInterval(moveHero, 1000 / 60);
+}, 0);
+LK.on('tick', function () {
+ for (var i = 0; i < heroBullets.length; i++) {
+ if (heroBullets[i]) {
+ heroBullets[i]._move_migrated();
+ }
+ for (var j = 0; j < enemies.length; j++) {
+ if (heroBullets[i] && heroBullets[i].intersects(enemies[j])) {
+ enemies[j].life -= heroBullets[i].damage * 10;
+ if (enemies[j].life <= 0) {
+ var scoreIncrement = enemies[j] instanceof EnemyBoss ? 50 : 10;
+ scoreIncrement += Math.floor(LK.ticks / 3600);
+ LK.setScore(LK.getScore() + scoreIncrement);
+ scoreTxt.setText(LK.getScore().toString());
+ enemies[j].destroy();
+ enemies.splice(j, 1);
}
- }
- if (heroBullets[i] && heroBullets[i].y < -50) {
heroBullets[i].destroy();
heroBullets.splice(i, 1);
- i--;
- i--;
+ break;
}
}
- for (var i = 0; i < enemyBullets.length; i++) {
- enemyBullets[i].move();
- if (enemyBullets[i].y > 2732 + 50) {
- enemyBullets[i].destroy();
- enemyBullets.splice(i, 1);
- }
+ if (heroBullets[i] && heroBullets[i].y < -50) {
+ heroBullets[i].destroy();
+ heroBullets.splice(i, 1);
+ i--;
+ i--;
}
- for (var i = 0; i < enemies.length; i++) {
- if (enemies[i].intersects(hero)) {
- isGameOver = true;
- break;
- }
+ }
+ for (var i = 0; i < enemyBullets.length; i++) {
+ enemyBullets[i]._move_migrated();
+ if (enemyBullets[i].y > 2732 + 50) {
+ enemyBullets[i].destroy();
+ enemyBullets.splice(i, 1);
}
- for (var i = 0; i < enemies.length; i++) {
- enemies[i].move();
- if (enemies[i].y > 2732) {
- enemies[i].destroy();
- enemies.splice(i, 1);
- i--;
- }
+ }
+ for (var i = 0; i < enemies.length; i++) {
+ if (enemies[i].intersects(hero)) {
+ isGameOver = true;
+ break;
}
- clouds.forEach(function (cloud) {
- cloud.move();
- });
- if (isGameOver) {
- LK.effects.flashScreen(0xff0000, 1000);
- LK.showGameOver();
+ }
+ for (var i = 0; i < enemies.length; i++) {
+ enemies[i]._move_migrated();
+ if (enemies[i].y > 2732) {
+ enemies[i].destroy();
+ enemies.splice(i, 1);
+ i--;
}
+ }
+ clouds.forEach(function (cloud) {
+ cloud._move_migrated();
});
-});
+ if (isGameOver) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+});
\ No newline at end of file
Goku arms doing kamehameha. seen from above. 8-bit. Cartoon. In game asset. No shadow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit. Cartoon. Orange energy ball. . In game asset. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rotate image 45 degrees
8-bit. cartoon. white energy ball. gradieint. transparent. in game asset. flicker. shoot. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8-bit. cartoon. front view. flying final boss. white. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.