User prompt
Use the asset "jungleBackground" as the background.
User prompt
Modify the white background and change it into a jungle.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 64
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fontSize')' in or related to this line: 'scoreText.style.fontSize = 100;' Line Number: 148
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fontSize')' in or related to this line: 'score.style.fontSize = 100;' Line Number: 148
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'fontSize')' in or related to this line: 'scoreText.style.fontSize = 100;' Line Number: 148
User prompt
Please fix the bug: 'TypeError: scoreText.setText is not a function' in or related to this line: 'scoreText.setText(LK.getScore());' Line Number: 65
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 84
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 77
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 77
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 77
User prompt
Design a scoreboard. Ten points will be awarded for eliminating each monster. The score will be displayed in white numbers above the game. After the game is over, the total score will be prominently displayed in an enlarged font size.
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 67
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 66
User prompt
Please fix the bug: 'LK.getText is not a function' in or related to this line: 'var scoreText = game.addChild(LK.getText('scoreText', {' Line Number: 78
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 66
User prompt
Please fix the bug: 'TypeError: scoreText.setText is not a function' in or related to this line: 'scoreText.setText('Score: ' + score);' Line Number: 35
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 67
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'text')' in or related to this line: 'LK.init.text('scoreText', {' Line Number: 67
User prompt
Design a scoreboard. Ten points will be awarded for eliminating each monster. After each game ends, the total score will be displayed. Moreover, the scoreboard also allows the input of names to show how many points a game player has obtained. The scores of the top ten players will be displayed at most.
User prompt
Modify the white background and change it into a jungle.
User prompt
Design a white background.
User prompt
The arrow is a weapon for attacking monsters. Whenever an arrow is shot at a monster and hits it, one monster will be eliminated.
User prompt
Create an asset named "Monster". It will spawn from all directions outside the screen and rush towards the asset "Archer". Once it touches the "Archer", the game will be judged as a failure.
User prompt
Create an asset named "Arrow". It is a projectile. Its function is that after clicking the mouse, it will be shot out from the position of the archer and reach the position where the mouse is clicked.
/****
* Classes
****/
//<Assets used in the game will automatically appear here>
// Arrow class
var Arrow = Container.expand(function () {
var self = Container.call(this);
var arrowGraphics = self.attachAsset('Arrow', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 10;
self.direction = {
x: 0,
y: 0
};
self.update = function () {
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
for (var i = monsters.length - 1; i >= 0; i--) {
if (self.intersects(monsters[i])) {
monsters[i].destroy();
monsters.splice(i, 1);
self.destroy();
LK.setScore(LK.getScore() + 10);
return;
}
}
};
});
// Monster class
var Monster = Container.expand(function () {
var self = Container.call(this);
var monsterGraphics = self.attachAsset('Monster', {
anchorX: 0.5,
anchorY: 0.5
});
self.speed = 5;
self.direction = {
x: 0,
y: 0
};
self.update = function () {
self.x += self.direction.x * self.speed;
self.y += self.direction.y * self.speed;
};
});
// Score class
var Score = Container.expand(function () {
var self = Container.call(this);
var scoreText = self.attachAsset('scoreText', {
anchorX: 0.5,
anchorY: 0.0
});
self.update = function () {
scoreText.setText(LK.getScore());
};
});
/****
* Initialize Game
****/
var game = new LK.Game();
/****
* Game Code
****/
LK.init.text('scoreText', {
text: '0',
style: {
fontFamily: 'Arial',
fontSize: 50,
fill: 'white',
align: 'center'
}
});
LK.init.text('scoreText', {
text: '0',
style: {
fontFamily: 'Arial',
fontSize: 50,
fill: 'white',
align: 'center'
}
});
LK.init.text('scoreText', {
text: '0',
style: {
fontFamily: 'Arial',
fontSize: 50,
fill: 'white',
align: 'center'
}
});
var background = game.addChild(LK.getAsset('jungleBackground', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
y: 0
}));
var score = game.addChild(new Score());
score.x = 2048 / 2;
score.y = 50;
var archer = game.addChild(LK.getAsset('Archer', {
anchorX: 0.5,
anchorY: 0.5,
x: 2048 / 2,
y: 2732 / 2
}));
var monsters = [];
game.update = function () {
if (LK.ticks % 60 == 0) {
var monster = game.addChild(new Monster());
var spawnSide = Math.floor(Math.random() * 4);
switch (spawnSide) {
case 0:
// top
monster.x = Math.random() * 2048;
monster.y = 0;
break;
case 1:
// right
monster.x = 2048;
monster.y = Math.random() * 2732;
break;
case 2:
// bottom
monster.x = Math.random() * 2048;
monster.y = 2732;
break;
case 3:
// left
monster.x = 0;
monster.y = Math.random() * 2732;
break;
}
var dx = archer.x - monster.x;
var dy = archer.y - monster.y;
var magnitude = Math.sqrt(dx * dx + dy * dy);
monster.direction.x = dx / magnitude;
monster.direction.y = dy / magnitude;
monsters.push(monster);
}
for (var i = monsters.length - 1; i >= 0; i--) {
if (monsters[i].intersects(archer)) {
LK.showGameOver();
scoreText.style.fontSize = 100;
scoreText.y = 2732 / 2;
}
}
};
game.down = function (x, y, obj) {
var arrow = game.addChild(new Arrow());
arrow.x = archer.x;
arrow.y = archer.y;
var dx = x - archer.x;
var dy = y - archer.y;
var magnitude = Math.sqrt(dx * dx + dy * dy);
arrow.direction.x = dx / magnitude;
arrow.direction.y = dy / magnitude;
}; ===================================================================
--- original.js
+++ change.js
@@ -82,8 +82,17 @@
fill: 'white',
align: 'center'
}
});
+LK.init.text('scoreText', {
+ text: '0',
+ style: {
+ fontFamily: 'Arial',
+ fontSize: 50,
+ fill: 'white',
+ align: 'center'
+ }
+});
var background = game.addChild(LK.getAsset('jungleBackground', {
anchorX: 0.0,
anchorY: 0.0,
x: 0,
A single, cartoonish little monster. It has fur and a big mouth, and its movement posture looks as if it's about to pounce forward.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
It's a 2D planar background. It's a jungle with green grass growing all over the ground and thick forests surrounding it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
An orangutan in a cartoon image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bunch of bananas in a cartoon image.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.