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
/****
* Classes
****/
var HeroLeft = Container.expand(function () {
var self = Container.call(this);
var heroGraphics = self.attachAsset('heroleft', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.shootCooldown = 120;
self.shootTimer = 0;
self.shoot = function () {
if (self.shootTimer <= 0) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
game.addChild(bullet);
self.shootTimer = self.shootCooldown;
return bullet;
}
return null;
};
});
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();
});
monsters.length = 0;
LK.setScore(LK.getScore() + monsters.length);
};
var heroGraphics = self.attachAsset('hero', {
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.shootCooldown = 120; // 2 seconds at 60FPS
self.shootTimer = 0;
self.shoot = function () {
if (self.shootTimer <= 0) {
var bullet = new Bullet();
bullet.x = self.x;
bullet.y = self.y;
game.addChild(bullet);
self.shootTimer = self.shootCooldown;
return bullet;
}
return null;
};
});
// 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 () {
if (LK.getScore() >= 100) {
LK.setScore(LK.getScore() - 100);
hero.shootCooldown = Math.max(0, hero.shootCooldown - 30); // 0.5 seconds at 60FPS
}
});
});
var StrongerMonster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('strongMonster', {
anchorX: 0.5,
anchorY: 0.5
});
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.move = function () {
self.y -= self.speed;
};
});
var Door = Container.expand(function () {
var self = Container.call(this);
var doorGraphics = self.attachAsset('door', {
anchorX: 0.5,
anchorY: 0.5
});
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
****/
var game = new LK.Game();
/****
* Game Code
****/
// Add CooldownButton to the game
// Joystick for hero movement
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 - hero.x;
var dy = pos.y - hero.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance > hero.speed) {
var angle = Math.atan2(dy, dx);
hero.x += Math.cos(angle) * hero.speed;
hero.y += Math.sin(angle) * hero.speed;
} else {
hero.x = pos.x;
hero.y = pos.y;
}
});
joystick.on('up', function (obj) {
joystickKnob.x = joystickBase.x;
joystickKnob.y = joystickBase.y;
});
game.addChild(joystick);
var button = game.addChild(new Button());
button.x = 100;
button.y = 2732 - 100;
// Score bar at the top
var scoreBar = new Text2('0', {
size: 150,
fill: "#ffffff",
anchorX: 0.5,
anchorY: 0
});
LK.gui.top.addChild(scoreBar);
var background = game.attachAsset('stoneBrickFloor', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
});
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
hero.y = 2732 / 2;
game.on('move', function (obj) {
var pos = obj.event.getLocalPosition(game);
var heroX = hero.x;
var heroY = hero.y;
if (pos.x > hero.x) {
if (!(hero instanceof Hero)) {
hero.destroy();
hero = game.addChild(new Hero());
hero.x = heroX;
hero.y = heroY;
}
} else {
if (!(hero instanceof HeroLeft)) {
hero.destroy();
hero = game.addChild(new HeroLeft());
hero.x = heroX;
hero.y = heroY;
}
}
});
// Add keyboard event listeners for arrow key movement and space for destroying monsters
var door = game.addChild(new Door());
var monsters = [];
var bullets = [];
game.on('down', function (obj) {
if (hero.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());
}
if (hero.update) {
hero.update();
}
var spawnRate = LK.getScore() >= 80 ? 300 : LK.getScore() >= 50 ? 360 : 420;
var spawnWeakCounter = 0;
var spawnStrong = false;
var strongMonsterExists = false;
var spawnDelayTimer = 0;
var spawnDelayDuration = 300; // 5 seconds at 60FPS
if (strongMonsterExists) {
var strongMonster = monsters.find(function (monster) {
return monster instanceof StrongerMonster;
});
if (!strongMonster) {
strongMonsterExists = false;
spawnDelayTimer = spawnDelayDuration;
}
}
if (spawnDelayTimer > 0) {
spawnDelayTimer--;
} 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() + 5);
}
bullet.destroy();
bullets.splice(index, 1);
}
});
}
});
});
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.