Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: LK.setPause is not a function' in or related to this line: 'LK.setPause(true);' Line Number: 55
User prompt
Fix Bug: 'Uncaught TypeError: LK.pauseGame is not a function' in or related to this line: 'LK.pauseGame();' Line Number: 55
User prompt
Fix Bug: 'Uncaught TypeError: LK.setPause is not a function' in or related to this line: 'LK.setPause(true);' Line Number: 55
User prompt
Fix Bug: 'Uncaught TypeError: LK.pauseGame is not a function' in or related to this line: 'LK.pauseGame();' Line Number: 55
User prompt
Fix Bug: 'Uncaught TypeError: LK.pause is not a function' in or related to this line: 'LK.pause();' Line Number: 55
Code edit (3 edits merged)
Please save this source code
User prompt
fix
Code edit (5 edits merged)
Please save this source code
User prompt
fully fix the game so that there is no black screen
User prompt
still a black screen
User prompt
there is still a black screen make sure there isn't
User prompt
fix the fact that there is a black screen
Code edit (1 edits merged)
Please save this source code
User prompt
fix
User prompt
Fix Bug: 'Uncaught TypeError: LK.pause is not a function' in or related to this line: 'LK.pause();' Line Number: 55
Code edit (1 edits merged)
Please save this source code
User prompt
move versiontxt a bit lower
User prompt
move versiontxt a bit lower
User prompt
move versiontxt lower
User prompt
move versiontxt lower
User prompt
there is a black vertical mark that is covering a bit of the right of the screen. Is it possible to remove
User prompt
why is there a black part covering part of the screen on the right
User prompt
move versiontxt lower
User prompt
move versiontxt a lot lower
===================================================================
--- original.js
+++ change.js
@@ -3,85 +3,205 @@
****/
// BulletPack class
var BulletPack = Container.expand(function () {
var self = Container.call(this);
-} // ... (unchanged)
-);
+ var bulletPackGraphics = self.attachAsset('bulletPack', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.direction = Math.random() < 0.5 ? -1 : 1;
+ self.move = function () {
+ var speedIncreaseFactor = 0.1 + LK.ticks * 0.0002;
+ self.y += self.speed + speedIncreaseFactor;
+ self.x += self.direction * (10 + speedIncreaseFactor);
+ if (self.x < 0 || self.x > game.width) {
+ self.direction *= -1;
+ }
+ };
+});
// Character class
var Hero = Container.expand(function () {
var self = Container.call(this);
-} // ... (unchanged)
-);
+ var heroGraphics = self.attachAsset('hero', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.bulletLimit = 3; // Initialize bullet limit
+ self.canShoot = true; // Allow shooting initially
+ self.update = function () {
+ // Hero update logic
+ };
+ self.shoot = function () {
+ if (this.bulletLimit > 0 && this.canShoot) {
+ 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
+ this.canShoot = false; // Set shooting cooldown
+ LK.setTimeout(function () {
+ self.canShoot = true;
+ }, 500); // Cooldown of 500ms before next shot
+ }
+ };
+});
// Bullet class
var Bullet = Container.expand(function () {
var self = Container.call(this);
-} // ... (unchanged)
-);
+ var bulletGraphics = self.attachAsset('purpleBullet', {
+ anchorX: 0.0625,
+ anchorY: 0.0625
+ });
+ self.speed = -10;
+ self.move = function () {
+ self.y += self.speed;
+ };
+});
// Enemy class
var Enemy = Container.expand(function () {
var self = Container.call(this);
-} // ... (unchanged)
-);
+ var enemyGraphics = self.attachAsset('enemy', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.speed = 4;
+ self.direction = Math.random() < 0.5 ? -1 : 1;
+ self.move = function () {
+ self.y += self.speed;
+ var speedIncreaseFactor = 0.1 + LK.ticks * 0.0002; // Increase the speed factor over time
+ self.x += self.direction * (4 + speedIncreaseFactor);
+ 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
+ };
+});
// Button class
var Button = Container.expand(function (text, positionX, positionY, onClickCallback) {
var self = Container.call(this);
-} // ... (unchanged)
-);
+ 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);
-} // ... (unchanged)
-);
-// MainMenu class
-var MainMenu = Container.expand(function () {
+ self.interactive = true;
+ self.isDragging = false;
+ self.onMoveCallback = null;
+ self.setMoveCallback = function (callback) {
+ self.onMoveCallback = function (direction) {
+ callback({
+ x: direction.x,
+ y: 0
+ });
+ };
+ };
+ 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 = stickGraphics.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;
+ };
+});
+/****
+* Main Menu Code
+****/
+var mainMenu = Container.expand(function () {
var self = Container.call(this);
- // Create Play button
+ var titleTxt = new Text2('Game Title', {
+ size: 100,
+ fill: "#ffffff"
+ });
+ titleTxt.anchor.set(0.5);
+ titleTxt.x = game.width / 2;
+ titleTxt.y = game.height / 4;
var playButton = new Button('Play', game.width / 2, game.height / 2, function () {
- self.visible = false;
- difficultyMenu.visible = true;
+ self.visible = false; // Hide main menu
+ difficultyMenu.visible = true; // Show difficulty menu
});
+ self.addChild(titleTxt);
self.addChild(playButton);
- // Create Difficulty Menu
- var difficultyMenu = new Container();
+ self.visible = true; // Show main menu initially
+});
+/****
+* Difficulty Menu Code
+****/
+var difficultyMenu = Container.expand(function () {
+ var self = Container.call(this);
+ var titleTxt = new Text2('Select Difficulty', {
+ size: 80,
+ fill: "#ffffff"
+ });
+ titleTxt.anchor.set(0.5);
+ titleTxt.x = game.width / 2;
+ titleTxt.y = game.height / 4;
var easyButton = new Button('Easy', game.width / 2, game.height / 2 - 100, function () {
- startGame('easy');
+ startGame('easy'); // Start game with easy difficulty
});
- difficultyMenu.addChild(easyButton);
var mediumButton = new Button('Medium', game.width / 2, game.height / 2, function () {
- startGame('medium');
+ startGame('medium'); // Start game with medium difficulty
});
- difficultyMenu.addChild(mediumButton);
var hardButton = new Button('Hard', game.width / 2, game.height / 2 + 100, function () {
- startGame('hard');
+ startGame('hard'); // Start game with hard difficulty
});
- difficultyMenu.addChild(hardButton);
- difficultyMenu.visible = false;
- function startGame(difficulty) {
- // Reset game state and start the game with the selected difficulty
- // You may need to reset variables, clear the screen, etc.
- // For simplicity, I'm assuming a new game is created here.
- // Reset variables
- heroBullets = [];
- enemies = [];
- LK.setScore(0);
- // Clear the screen
- game.removeChildren();
- // Create a new hero and add it to the game
- hero = game.addChild(new Hero());
- hero.x = game.width / 2;
- hero.y = game.height - 100;
- // Add other game elements as needed
- // Resume game loop
- LK.resume();
- // Hide difficulty menu
- self.visible = false;
- difficultyMenu.visible = false;
- }
+ self.addChild(titleTxt);
+ self.addChild(easyButton);
+ self.addChild(mediumButton);
+ self.addChild(hardButton);
+ self.visible = false; // Hide difficulty menu initially
});
/****
* Initialize Game
****/
+// Initialize important asset arrays
// Create left movement button
var game = new LK.Game({
title: '(WIP)',
backgroundColor: 0x000000 // Init game with black background
@@ -89,12 +209,8 @@
/****
* Game Code
****/
-// Add main menu to the game
-var mainMenu = game.addChild(new MainMenu());
-// Pause the game initially
-LK.pause();
// Initialize important asset arrays
var heroBullets = [];
var enemies = [];
// Create character
@@ -160,9 +276,8 @@
game.on('move', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
hero.x = pos.x;
- // hero.y = pos.y; // Removed the line that sets the hero's y position
});
// Global event listener for shooting bullets
// Game tick event
LK.on('tick', function () {
@@ -240,6 +355,75 @@
enemies.push(bulletPack); // Add bullet pack to enemies array for collision detection
game.addChild(bulletPack);
}
});
-// Show main menu initially
-mainMenu.visible = true;
\ No newline at end of file
+// Function to start the game with the selected difficulty
+function startGame(difficulty) {
+ // Customize game parameters based on difficulty
+ var gameSpeed;
+ var enemySpawnRate;
+ switch (difficulty) {
+ case 'easy':
+ gameSpeed = 1;
+ enemySpawnRate = 90;
+ break;
+ case 'medium':
+ gameSpeed = 1.5;
+ enemySpawnRate = 75;
+ break;
+ case 'hard':
+ gameSpeed = 2;
+ enemySpawnRate = 60;
+ break;
+ default:
+ gameSpeed = 1;
+ enemySpawnRate = 90;
+ break;
+ }
+ // Set up game parameters
+ LK.setSpeed(gameSpeed);
+ LK.resetScore();
+ LK.resetTicks();
+ // Hide difficulty menu
+ difficultyMenu.visible = true;
+ // Show game components
+ hero.visible = true;
+ scoreTxt.visible = true;
+ highScoreTxt.visible = true;
+ bulletCountTxt.visible = true;
+ instructionsTxt.visible = true;
+ redLine.visible = true;
+ joystick.visible = true;
+ // Set up game tick event with adjusted speed
+ LK.on('tick', function () {
+ // Increment ticks based on game speed
+ LK.incrementTicks();
+ // Call the existing game tick logic
+ LK.trigger('tick');
+ });
+ // Show joystick
+ joystick.visible = true;
+ // Initialize important asset arrays
+ heroBullets = [];
+ enemies = [];
+ // Create character
+ hero = game.addChild(new Hero());
+ hero.x = game.width / 2;
+ hero.y = game.height - 100;
+ // Reset score display
+ scoreTxt.setText('Score: 0');
+ highScoreTxt.setText('High Score: ' + (localStorage.getItem('highScore') || '0') + ' (WIP)');
+ bulletCountTxt.setText('Bullets: 3');
+ // Reset game over screen
+ LK.hideGameOver();
+}
+// Add main menu and difficulty menu to the game
+game.addChild(mainMenu);
+game.addChild(difficultyMenu);
+// Show the main menu initially
+mainMenu.visible = true;
+difficultyMenu.visible = false;
+// Start the game when the play button is clicked
+game.on('down', function () {
+ mainMenu.visible = true; // Hide main menu
+ difficultyMenu.visible = true; // Show difficulty menu
+});
\ No newline at end of file
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