User prompt
the enemy and bulletpack should disappear and become null when it reaches the red line
User prompt
the enemy does not disappear and become null 3/4 down the screen
User prompt
Fix Bug: 'TypeError: Cannot read properties of null (reading 'y')' in this line: 'self.y += self.speed;' Line Number: 62
User prompt
the enemy and bulletpack should become null when reaching 3/4 down the screen
User prompt
change instruction to say: "Tap anywhere to shoot"
User prompt
make it so you cannot just spam click
User prompt
the purple bullet should not disappear until it reaches the top of the screen
User prompt
Fix Bug: 'Uncaught TypeError: Graphics is not a constructor' in this line: 'var redLine = new Graphics();' Line Number: 188
User prompt
make a red line 3/4 down the screen
User prompt
make the enemies and bullet pack disappear 3/4 down the screen
User prompt
make the enemy move left and right faster as the game progresses
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'setItem')' in this line: 'localStorage.setItem('highScore', highScore.toString());' Line Number: 223
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highScore = Math.max(newScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highScore') : '0') || '0', 10));' Line Number: 222
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highScore = Math.max(newScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highScore') : '0') || '0', 10));' Line Number: 222
User prompt
Fix Bug: 'TypeError: parseInt is not a function' in this line: 'var highScore = Math.max(newScore, parseInt((typeof localStorage !== 'undefined' ? localStorage.getItem('highScore') : '0') || '0'));' Line Number: 222
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getItem')' in this line: 'var highScore = Math.max(newScore, parseInt(localStorage.getItem('highScore') || '0'));' Line Number: 222
User prompt
make a high score count
User prompt
make it so you can press anywhere to shoot purplebullets
User prompt
you should not be able to move the hero up and down
User prompt
make the hero only able to move left and right
User prompt
make the hero move wherever the mouse is
User prompt
remove the stick asset
User prompt
Fix Bug: 'ReferenceError: baseGraphics is not defined' in this line: 'var maxDistance = baseGraphics.width * 0.5;' Line Number: 118
User prompt
Fix Bug: 'Uncaught ReferenceError: stickGraphics is not defined' in this line: 'var stickOrigin = {' Line Number: 89
User prompt
get rid of the joystickstick and joystickbase
/****
* Classes
****/
// BulletPack class
var BulletPack = Container.expand(function () {
var self = Container.call(this);
var bulletPackGraphics = self.createAsset('bulletPack', 'Bullet Pack', 0.5, 0.5);
self.speed = 4;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.move = function () {
self.y += self.speed;
self.x += self.direction * 10;
if (self.x < 0 || self.x > game.width) {
self.direction *= -1;
}
};
});
// Character class
var Hero = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.createAsset('hero', 'Hero', 0.5, 0.5);
self.bulletLimit = 3; // Initialize bullet limit
self.update = function () {
// Hero update logic
};
self.on('down', function (obj) {
self.shoot();
});
self.shoot = function () {
if (this.bulletLimit > 0) {
var bullet = new Bullet();
bullet.x = this.x;
bullet.y = this.y - this.height / 2;
heroBullets.push(bullet);
game.addChild(bullet);
this.bulletLimit--;
bulletCountTxt.setText('Bullets: ' + this.bulletLimit); // Update bullet count display
}
};
});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.createAsset('purpleBullet', 'Purple Bullet', 0.0625, 0.0625);
self.speed = -10;
self.move = function () {
self.y += self.speed;
};
});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
var enemyGraphics = self.createAsset('enemy', 'Enemy character', 0.5, 0.5);
self.speed = 4;
self.direction = Math.random() < 0.5 ? -1 : 1;
self.move = function () {
self.y += self.speed;
var randomFactor = Math.random() * (0.1 + LK.ticks * 0.0001); // Random factor increases over time
self.x += self.direction * (4 + randomFactor);
if (self.x < 0 || self.x > game.width) {
self.direction *= -1;
}
self.speed += 0.02 + LK.ticks * 0.0001; // Increase speed over time with an accelerating factor
};
});
var Button = Container.expand(function (text, positionX, positionY, onClickCallback) {
var self = Container.call(this);
var buttonText = new Text2(text, {
size: 200,
fill: "#ffffff"
});
buttonText.anchor.set(0.5);
self.addChild(buttonText);
self.x = positionX;
self.y = positionY;
self.interactive = true;
self.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
if (self.containsPoint(pos)) {
onClickCallback();
}
});
});
// JoystickAsset class
var JoystickAsset = Container.expand(function () {
var self = Container.call(this);
self.interactive = true;
var stickOrigin = {
x: stickGraphics.x,
y: stickGraphics.y
};
self.isDragging = false;
self.onMoveCallback = null;
self.setMoveCallback = function (callback) {
self.onMoveCallback = callback;
};
self.on('down', function (obj) {
self.isDragging = true;
});
self.on('up', function (obj) {
self.isDragging = false;
stickGraphics.x = stickOrigin.x;
stickGraphics.y = stickOrigin.y;
if (self.onMoveCallback) {
self.onMoveCallback({
x: 0,
y: 0
});
}
});
self.on('move', function (obj) {
if (self.isDragging) {
var event = obj.event;
var pos = event.getLocalPosition(self);
var dx = pos.x - stickOrigin.x;
var maxDistance = baseGraphics.width * 0.5;
if (Math.abs(dx) > maxDistance) {
dx = maxDistance * (dx > 0 ? 1 : -1);
}
stickGraphics.x = stickOrigin.x + dx;
stickGraphics.y = stickOrigin.y;
if (self.onMoveCallback) {
self.onMoveCallback({
x: dx / maxDistance,
y: 0
});
}
}
});
self.containsPoint = function (point) {
return point.x >= self.x - self.width / 2 && point.x <= self.x + self.width / 2 && point.y >= self.y - self.height / 2 && point.y <= self.y + self.height / 2;
};
});
/****
* Initialize Game
****/
// Create left movement button
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Initialize important asset arrays
var heroBullets = [];
var enemies = [];
// Create character
var hero = game.addChild(new Hero());
hero.x = game.width / 2;
hero.y = game.height - 100;
// Create score display
var scoreTxt = new Text2('Score: 0', {
size: 50,
fill: "#ffffff"
});
scoreTxt.anchor.set(1, 0);
LK.gui.topRight.addChild(scoreTxt);
// Create bullet count display
var bulletCountTxt = new Text2('Bullets: 3', {
size: 100,
fill: "#ffffff"
});
bulletCountTxt.anchor.set(0, 0);
bulletCountTxt.y = scoreTxt.height + 50; // Position below the score display
LK.gui.topLeft.addChild(bulletCountTxt);
// Create instructions display
var instructionsTxt = new Text2('Use joystick to move. Tap anywhere to shoot', {
size: 50,
fill: "#ffffff"
});
instructionsTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(instructionsTxt);
// Create joystick instance
var joystick = new JoystickAsset();
joystick.x = joystick.width / 2 + 150;
joystick.y = game.height - joystick.height / 2 - 150;
joystick.setMoveCallback(function (direction) {
hero.x = Math.max(hero.width / 2, Math.min(game.width - hero.width / 2, hero.x + direction.x * 10));
hero.y = Math.max(hero.height / 2, Math.min(game.height - hero.height / 2, hero.y + direction.y * 10));
});
game.addChild(joystick);
// Handle hero dragging
var dragNode = null;
// Global event listener for shooting bullets
game.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
if (!joystick.containsPoint(pos)) {
hero.shoot();
}
});
// Global event listener for shooting bullets
// Game tick event
LK.on('tick', function () {
// Update character
hero.update();
// Move and check bullets
for (var i = heroBullets.length - 1; i >= 0; i--) {
var bullet = heroBullets[i];
bullet.move();
// Check for bullet collision with enemies and bullet packs
for (var j = enemies.length - 1; j >= 0; j--) {
if (bullet.intersects(enemies[j])) {
if (enemies[j] instanceof BulletPack) {
// If the enemy is a bullet pack
// Increment character's bullet limit by 5
hero.bulletLimit += 5;
} else {
// If the enemy is an actual enemy
// Update score
LK.setScore(LK.getScore() + 1);
scoreTxt.setText(LK.getScore());
// Increment character's bullet limit
hero.bulletLimit++;
}
bulletCountTxt.setText('Bullets: ' + hero.bulletLimit); // Update bullet count display
// Destroy enemy/bullet pack and bullet
enemies[j].destroy();
enemies.splice(j, 1);
bullet.destroy();
heroBullets.splice(i, 1);
break;
}
}
// Remove off-screen bullets and end the game if it's the last one
if (bullet.y < -50) {
bullet.destroy();
heroBullets.splice(i, 1);
if (heroBullets.length === 0 && hero.bulletLimit === 0) {
LK.showGameOver(); // End the game when the last bullet is out of frame
}
}
}
// Move enemies
for (var k = enemies.length - 1; k >= 0; k--) {
enemies[k].move();
}
var enemySpawnRate = 60; // Initialize enemy spawn rate
// Spawn enemies and bullet packs
if (LK.ticks % enemySpawnRate == 0) {
var enemy = new Enemy();
enemy.x = Math.random() * (game.width - enemy.width) + enemy.width / 2;
enemy.y = -enemy.height;
enemies.push(enemy);
game.addChild(enemy);
if (enemySpawnRate > 30) {
enemySpawnRate -= 0.5;
} // Decrease spawn rate over time to a minimum of 30 ticks
}
if (LK.ticks % 600 == 0) {
// Spawn a bullet pack every 600 ticks
var bulletPack = new BulletPack();
bulletPack.x = Math.random() * (game.width - bulletPack.width) + bulletPack.width / 2;
bulletPack.y = -bulletPack.height;
enemies.push(bulletPack); // Add bullet pack to enemies array for collision detection
game.addChild(bulletPack);
}
});
android. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
letter X png. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
space background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
galaxy background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
galaxy background. High quality
space background.. High contrast