User prompt
makeitsothattheplayersscorecantgointothenegivesandifitwouldmakeitcancelbothaffectsofthebutton
User prompt
Update the hero's move method to follow the cursor
User prompt
Please fix the bug: 'ReferenceError: WeakerMonster is not defined' in or related to this line: 'var monster = new WeakerMonster();' Line Number: 200
User prompt
remove the monster walsing animations and the strong monster
User prompt
Please fix the bug: 'ReferenceError: wall2 is not defined' in or related to this line: 'if (!self.intersects(wall1) && !self.intersects(wall2)) {' Line Number: 183
User prompt
place the wall into the center of the screen
User prompt
lets make some walls the player and the monster cant walk through
User prompt
Please fix the bug: 'ReferenceError: monster is not defined' in or related to this line: 'self.speed = 3 * monster.speed;' Line Number: 37
User prompt
limit the heroright and heroleft cursor following movement to 3 times the speed of the mnster
User prompt
Please fix the bug: 'TypeError: hero.shoot is not a function' in or related to this line: 'bullets.push(hero.shoot());' Line Number: 268
User prompt
Please fix the bug: 'TypeError: hero.update is not a function' in or related to this line: 'hero.update();' Line Number: 276
User prompt
Please fix the bug: 'ReferenceError: HeroRight is not defined' in or related to this line: 'if (!(hero instanceof HeroRight)) {' Line Number: 248
User prompt
Please fix the bug: 'ReferenceError: heroright is not defined' in or related to this line: 'heroright.update();' Line Number: 276
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'expand')' in or related to this line: 'var HeroLeft = Hero.expand(function () {' Line Number: 21
User prompt
FIX THE SHITY GAME YOU FUCKING PIECE OF SHIT
User prompt
fix it than
User prompt
show the button
User prompt
move the new button to the lower left corner
User prompt
Add a new button class is on the bottom left corner of the screen that when clicked, subtracts 100 points from the score how ever if the score is negative make sure that the button doesn't do anything. when the button is successfully clicked reduce the bullet cool-down by 0.5 seconds for both 'heroleft' and 'heroright' classes
User prompt
load the button so I can see it
User prompt
make it so I can see and click the button
User prompt
put the level up button in the lower left corner of the screen
User prompt
sho the level up button
User prompt
fix the level up button
User prompt
make it so that every time I click it fires a bullet
===================================================================
--- original.js
+++ change.js
@@ -1,14 +1,41 @@
/****
* Classes
****/
+var CooldownButton = Container.expand(function () {
+ var self = Container.call(this);
+ self.attachAsset('button', {
+ anchorX: 0.0,
+ // Bottom left anchor x-coordinate
+ anchorY: 1.0 // Bottom left anchor y-coordinate
+ });
+ self.x = 0; // Position x-coordinate at bottom left
+ self.y = 2732; // Position y-coordinate at bottom left
+ self.on('down', function () {
+ if (LK.getScore() >= 100) {
+ LK.setScore(LK.getScore() - 100);
+ hero.shootCooldown = Math.max(0, hero.shootCooldown - 15); // Reduce cooldown by 0.25 seconds (15 frames at 60FPS)
+ }
+ });
+});
+// Add CooldownButton to the game
+var Button = Container.expand(function () {
+ var self = Container.call(this);
+ self.attachAsset('button', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.on('down', function () {
+ LK.setScore(LK.getScore() - 100);
+ hero.shootCooldown = Math.max(0, hero.shootCooldown - 15); // 0.25 seconds at 60FPS
+ });
+});
var Hero = Container.expand(function () {
var self = Container.call(this);
self.update = function () {
if (self.shootTimer > 0) {
self.shootTimer--;
}
- self.speed = 6;
};
self.destroyMonsters = function () {
monsters.forEach(function (monster) {
monster.destroy();
@@ -20,21 +47,14 @@
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
- self.move = function (direction) {
- if (direction === 'left') {
- self.x -= self.speed;
- }
- if (direction === 'right') {
- self.x += self.speed;
- }
- if (direction === 'up') {
- self.y -= self.speed;
- }
- if (direction === 'down') {
- self.y += self.speed;
- }
+ self.move = function (targetX, targetY) {
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var angle = Math.atan2(dy, dx);
+ self.x += Math.cos(angle) * self.speed;
+ self.y += Math.sin(angle) * self.speed;
};
self.shootCooldown = 120; // 2 seconds at 60FPS
self.shootTimer = 0;
self.shoot = function () {
@@ -48,29 +68,45 @@
}
return null;
};
});
-// Add CooldownButton to the game
-var Button = Container.expand(function () {
+var StrongerMonster = Container.expand(function () {
var self = Container.call(this);
- self.attachAsset('button', {
+ var monsterGraphics = self.attachAsset('strongMonster', {
anchorX: 0.5,
anchorY: 0.5
});
- self.on('down', function () {
- if (LK.getScore() >= 100) {
- LK.setScore(LK.getScore() - 100);
- hero.shootCooldown = Math.max(0, hero.shootCooldown - 30); // 0.5 seconds at 60FPS
+ self.health = 5;
+ self.speed = 2;
+ self.hit = false;
+ self.hitTimer = 0;
+ self.update = function () {
+ if (self.hit) {
+ self.hitTimer--;
+ if (self.hitTimer <= 0) {
+ self.hit = false;
+ }
}
- });
+ };
+ self.moveTowards = function (targetX, targetY) {
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var angle = Math.atan2(dy, dx);
+ var newX = self.x + Math.cos(angle) * self.speed;
+ var newY = self.y + Math.sin(angle) * self.speed;
+ if (!self.hit) {
+ self.x = newX;
+ self.y = newY;
+ }
+ };
});
var Bullet = Container.expand(function () {
var self = Container.call(this);
var bulletGraphics = self.attachAsset('bullet', {
anchorX: 0.5,
anchorY: 0.5
});
- self.speed = 15;
+ self.speed = 10;
self.move = function () {
self.y -= self.speed;
};
});
@@ -82,8 +118,49 @@
});
self.x = 2048 / 2;
self.y = 128;
});
+var WeakerMonster = Container.expand(function () {
+ var self = Container.call(this);
+ self.animationFrames = ['monster_walk1', 'monster_walk2', 'monster_walk3', 'monster_walk4'];
+ self.currentFrameIndex = 0;
+ self.frameCounter = 0;
+ self.frameChangeRate = 15; // Change frame every 15 ticks (1/4 second at 60FPS)
+ self.monsterGraphics = self.attachAsset(self.animationFrames[self.currentFrameIndex], {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.health = 2;
+ self.speed = 2;
+ self.hit = false;
+ self.hitTimer = 0;
+ self.update = function () {
+ if (self.hit) {
+ self.hitTimer--;
+ if (self.hitTimer <= 0) {
+ self.hit = false;
+ }
+ }
+ // Handle walking animation
+ self.frameCounter++;
+ if (self.frameCounter >= self.frameChangeRate) {
+ self.currentFrameIndex = (self.currentFrameIndex + 1) % self.animationFrames.length;
+ self.monsterGraphics.texture = LK.getAsset(self.animationFrames[self.currentFrameIndex], {}).texture;
+ self.frameCounter = 0;
+ }
+ };
+ self.moveTowards = function (targetX, targetY) {
+ var dx = targetX - self.x;
+ var dy = targetY - self.y;
+ var angle = Math.atan2(dy, dx);
+ var newX = self.x + Math.cos(angle) * self.speed;
+ var newY = self.y + Math.sin(angle) * self.speed;
+ if (!self.hit) {
+ self.x = newX;
+ self.y = newY;
+ }
+ };
+});
/****
* Initialize Game
****/
@@ -91,43 +168,15 @@
/****
* Game Code
****/
-// Joystick for hero movement
// Add CooldownButton to the game
-var joystick = new Container();
-var joystickBase = joystick.attachAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 150,
- y: 2732 - 150
-});
-var joystickKnob = joystick.attachAsset('button', {
- anchorX: 0.5,
- anchorY: 0.5,
- x: 150,
- y: 2732 - 150
-});
-joystickKnob.draggable = true;
game.on('move', function (obj) {
- var pos = obj.event.getLocalPosition(game);
- var dx = pos.x - heroright.x;
- var dy = pos.y - heroright.y;
- var distance = Math.sqrt(dx * dx + dy * dy);
- if (distance > heroright.speed) {
- var angle = Math.atan2(dy, dx);
- heroright.x += Math.cos(angle) * heroright.speed;
- heroright.y += Math.sin(angle) * heroright.speed;
- } else {
- heroright.x = pos.x;
- heroright.y = pos.y;
- }
+ var event = obj.event;
+ var pos = event.getLocalPosition(game);
+ hero.move(pos.x, pos.y);
});
-joystick.on('up', function (obj) {
- joystickKnob.x = joystickBase.x;
- joystickKnob.y = joystickBase.y;
-});
-game.addChild(joystick);
+var cooldownButton = game.addChild(new CooldownButton());
var button = game.addChild(new Button());
button.x = 100;
button.y = 2732 - 100;
// Score bar at the top
@@ -143,25 +192,46 @@
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
-var heroright = game.addChild(new Hero());
-heroright.x = 2048 / 2;
-heroright.y = 2732 / 2;
+var hero = game.addChild(new Hero());
+hero.x = 2048 / 2;
+hero.y = 2732 / 2;
// Add keyboard event listeners for arrow key movement and space for destroying monsters
+LK.on('keydown', function (obj) {
+ var event = obj.event;
+ switch (event.key) {
+ case 'ArrowLeft':
+ hero.move('left');
+ break;
+ case 'ArrowRight':
+ hero.move('right');
+ break;
+ case 'ArrowUp':
+ hero.move('up');
+ break;
+ case 'ArrowDown':
+ hero.move('down');
+ break;
+ case ' ':
+ // Space key
+ hero.destroyMonsters();
+ break;
+ }
+});
var door = game.addChild(new Door());
var monsters = [];
var bullets = [];
game.on('up', function (obj) {
- bullets.push(heroright.shoot());
+ bullets.push(hero.shoot());
});
LK.on('tick', function () {
// Increment score every second
if (LK.ticks % 60 === 0) {
LK.setScore(LK.getScore() + 1);
scoreBar.setText(LK.getScore().toString());
}
- heroright.update();
+ hero.update();
var spawnRate = LK.getScore() >= 80 ? 300 : LK.getScore() >= 50 ? 360 : 420;
var spawnWeakCounter = 0;
var spawnStrong = false;
var strongMonsterExists = false;
@@ -177,23 +247,56 @@
}
}
if (spawnDelayTimer > 0) {
spawnDelayTimer--;
- } else if (spawnWeakCounter < 4 && LK.ticks % spawnRate === 0) {} else if (spawnWeakCounter >= 4 && !strongMonsterExists && spawnDelayTimer === 0) {
+ } else if (spawnWeakCounter < 4 && LK.ticks % spawnRate === 0) {
+ var monster = new WeakerMonster();
+ monster.x = door.x;
+ monster.y = door.y;
+ monsters.push(monster);
+ game.addChild(monster);
+ spawnWeakCounter++;
+ } else if (spawnWeakCounter >= 4 && !strongMonsterExists && spawnDelayTimer === 0) {
var strongMonster = new StrongerMonster();
strongMonster.x = door.x;
strongMonster.y = door.y;
monsters.push(strongMonster);
game.addChild(strongMonster);
strongMonsterExists = true;
spawnWeakCounter = 0;
}
+ monsters.forEach(function (monster, index) {
+ monster.update();
+ monster.moveTowards(hero.x, hero.y);
+ if (monster.intersects(hero)) {
+ LK.effects.flashScreen(0xff0000, 1000);
+ LK.showGameOver();
+ }
+ if (monster instanceof StrongerMonster && monster.health <= 0) {
+ strongMonsterExists = false;
+ }
+ });
bullets.forEach(function (bullet, index) {
if (bullet) {
bullet.move();
}
if (bullet && bullet.y < 0) {
bullet.destroy();
bullets.splice(index, 1);
+ } else {
+ monsters.forEach(function (monster, mIndex) {
+ if (bullet && bullet.intersects(monster)) {
+ monster.health -= 1;
+ monster.hit = true;
+ monster.hitTimer = 30; // 0.5 seconds at 60FPS
+ if (monster.health <= 0) {
+ monster.destroy();
+ monsters.splice(mIndex, 1);
+ LK.setScore(LK.getScore() + 1);
+ }
+ bullet.destroy();
+ bullets.splice(index, 1);
+ }
+ });
}
});
});
\ No newline at end of file
wooden door thats round at the top 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
wisard 8 bit from the top down. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tentacle monster 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8 bit tentacle monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
8 bit stone brick dungeon floor with a tiny amount of moss with tinny little bricks and very low contrast make it darker to. Single Game Texture. In-Game asset. 2d. Blank background.. No shadows.
8 bit fireball with a flame trail that goes down. Single Game Texture. In-Game asset. 2d. Blank background.. No shadows.
just move the tentacles a tinny litle bit
make the monster move
green button 8 bit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.