/**** * Classes ****/ // Enemy class var Enemy = Container.expand(function () { var self = Container.call(this); var enemyGraphics = self.attachAsset('enemy', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 5; self.update = function () { // Enemy update logic }; }); // EnemyBullet class var EnemyBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('enemyBullet', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 10; self.update = function () { self.y += self.speed; }; }); //<Assets used in the game will automatically appear here> // Hero class with anime powers var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = 10; self.update = function () { // Hero update logic // Example of anime power: teleportation if (Math.random() < 0.01) { self.x = Math.random() * 2048; self.y = Math.random() * 2732; } // Example of anime power: temporary invincibility if (Math.random() < 0.01) { self.alpha = 0.5; // Make hero semi-transparent to indicate invincibility LK.setTimeout(function () { self.alpha = 1.0; // Revert back to normal after 1 second }, 1000); } }; self.down = function (x, y, obj) { // Hero down event logic // Example of anime weapon: energy blast var energyBlast = new HeroBullet(); energyBlast.x = self.x; energyBlast.y = self.y; energyBlast.speed = -20; // Faster speed for energy blast heroBullets.push(energyBlast); game.addChild(energyBlast); }; self.up = function (x, y, obj) { // Hero up event logic // Example of anime weapon: sword slash var swordSlash = new HeroBullet(); swordSlash.x = self.x; swordSlash.y = self.y; swordSlash.speed = -10; // Normal speed for sword slash heroBullets.push(swordSlash); game.addChild(swordSlash); }; }); // HeroBullet class var HeroBullet = Container.expand(function () { var self = Container.call(this); var bulletGraphics = self.attachAsset('heroBullet', { anchorX: 0.5, anchorY: 0.5, scaleX: 1.5, scaleY: 1.5 }); self.speed = -15; self.update = function () { self.y += self.speed; }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 //Init game with black background }); /**** * Game Code ****/ var level = 1; var levelDuration = 600; // 10 seconds per level at 60 FPS var levelTimer = 0; var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 - 200; var enemies = []; var heroBullets = []; var enemyBullets = []; function spawnEnemy() { var enemy = new Enemy(); enemy.x = Math.random() * 2048; enemy.y = -50; enemies.push(enemy); game.addChild(enemy); } function shootHeroBullet() { var bullet = new HeroBullet(); bullet.x = hero.x; bullet.y = hero.y; heroBullets.push(bullet); game.addChild(bullet); } function shootEnemyBullet(enemy) { var bullet = new EnemyBullet(); bullet.x = enemy.x; bullet.y = enemy.y; enemyBullets.push(bullet); game.addChild(bullet); } game.down = function (x, y, obj) { shootHeroBullet(); }; var level = 1; var levelDuration = 600; // 10 seconds per level at 60 FPS var levelTimer = 0; game.update = function () { levelTimer++; if (levelTimer >= levelDuration) { level++; levelTimer = 0; console.log("Level Up! Current Level: " + level); } for (var i = enemies.length - 1; i >= 0; i--) { enemies[i].update(); if (enemies[i].y > 2732) { enemies[i].destroy(); enemies.splice(i, 1); } } for (var i = heroBullets.length - 1; i >= 0; i--) { heroBullets[i].update(); if (heroBullets[i].y < -50) { heroBullets[i].destroy(); heroBullets.splice(i, 1); } } for (var i = enemyBullets.length - 1; i >= 0; i--) { enemyBullets[i].update(); if (enemyBullets[i].y > 2732) { enemyBullets[i].destroy(); enemyBullets.splice(i, 1); } } if (LK.ticks % (60 - level * 5) == 0) { // Increase enemy spawn rate with level spawnEnemy(); } for (var i = enemies.length - 1; i >= 0; i--) { if (Math.random() < 0.01 + level * 0.005) { // Increase enemy shooting rate with level shootEnemyBullet(enemies[i]); } } };
===================================================================
--- original.js
+++ change.js
@@ -5,9 +5,11 @@
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.attachAsset('enemy', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5
});
self.speed = 5;
self.update = function () {
// Enemy update logic
@@ -17,9 +19,11 @@
var EnemyBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('enemyBullet', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5
});
self.speed = 10;
self.update = function () {
self.y += self.speed;
@@ -30,9 +34,11 @@
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5
});
self.speed = 10;
self.update = function () {
// Hero update logic
@@ -74,9 +80,11 @@
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('heroBullet', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5
});
self.speed = -15;
self.update = function () {
self.y += self.speed;