User prompt
move Cosmic Credits a bit lower
User prompt
put Cosmic Credits below High Score
User prompt
make a new currency named "Cosmic Credits" under High Score. 5 cosmic credits per enemy
User prompt
under high score, make a currency system called "Cosmic Credits"
User prompt
name the button test
User prompt
add an interactive button asset at the bottom left of the screen
User prompt
make the font size on the button 50
User prompt
change the button name to "10 Bullets: 50 Cosmic Credits"
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
at the bottom left of the screen, add a button
User prompt
put the button on the bottom left
User prompt
make the button grey so that it is visible
User prompt
make the button visible
User prompt
add button on the bottom left of the screen. Call the button "10 Bullets: 50 Cosmic Credits"
User prompt
remove the lower red line
User prompt
make enemy and bulletpack disappear and become null when hitting the red line
User prompt
move the red line to 5/8 of the screen
User prompt
make the hero a bit lower
User prompt
make the hero a bit loweer
User prompt
make the hero a bit lower
User prompt
make the bottom button a button
User prompt
if i have 50 cosmic credits and i press on the bottom button, i will gain 10 purplebullets
User prompt
the button should be interactive
===================================================================
--- original.js
+++ change.js
@@ -68,9 +68,9 @@
});
var Button = Container.expand(function (text, positionX, positionY, onClickCallback) {
var self = Container.call(this);
var buttonText = new Text2(text, {
- size: 50,
+ size: 200,
fill: "#ffffff"
});
buttonText.anchor.set(0.5);
self.addChild(buttonText);
@@ -79,9 +79,9 @@
self.interactive = true;
self.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
- if (self.x - self.width / 2 <= pos.x && pos.x <= self.x + self.width / 2 && self.y - self.height / 2 <= pos.y && pos.y <= self.y + self.height / 2) {
+ if (self.containsPoint(pos)) {
onClickCallback();
}
});
});
@@ -135,23 +135,8 @@
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;
};
});
-var CosmicCredits = Container.expand(function () {
- var self = Container.call(this);
- self.amount = 0;
- self.creditTxt = new Text2('Cosmic Credits: 0', {
- size: 50,
- fill: "#ffffff"
- });
- self.creditTxt.anchor.set(1, 0);
- self.creditTxt.y = highScoreTxt.height * 2 + 40;
- LK.gui.topRight.addChild(self.creditTxt);
- self.addCredits = function (amount) {
- self.amount += amount;
- self.creditTxt.setText('Cosmic Credits: ' + self.amount);
- };
-});
/****
* Initialize Game
****/
@@ -166,8 +151,12 @@
****/
// 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"
@@ -180,28 +169,8 @@
highScoreTxt.anchor.set(1, 0);
highScoreTxt.y = scoreTxt.height + 20;
LK.gui.topRight.addChild(scoreTxt);
LK.gui.topRight.addChild(highScoreTxt);
-// Create a red line 3/4 down the screen
-var redLine = LK.getAsset('redLine', 'Horizontal Red Line', 0, 0);
-redLine.width = game.width;
-redLine.height = 5;
-redLine.y = game.height * (5 / 8);
-game.addChild(redLine);
-// Create character
-var hero = game.addChild(new Hero());
-hero.x = game.width / 2;
-hero.y = redLine.y + hero.height * 2;
-var cosmicCredits = game.addChild(new CosmicCredits());
-var highScoreTxt = new Text2('High Score: 0 (WIP)', {
- size: 50,
- fill: "#ffffff"
-});
-scoreTxt.anchor.set(1, 0);
-highScoreTxt.anchor.set(1, 0);
-highScoreTxt.y = scoreTxt.height + 20;
-LK.gui.topRight.addChild(scoreTxt);
-LK.gui.topRight.addChild(highScoreTxt);
// Create bullet count display
var bulletCountTxt = new Text2('Bullets: 3', {
size: 100,
fill: "#ffffff"
@@ -215,22 +184,22 @@
fill: "#ffffff"
});
instructionsTxt.anchor.set(0, 0);
LK.gui.topLeft.addChild(instructionsTxt);
+// Create a red line 3/4 down the screen
+var redLine = LK.getAsset('redLine', 'Horizontal Red Line', 0, 0);
+redLine.width = game.width;
+redLine.height = 5;
+redLine.y = game.height * 0.75;
+game.addChild(redLine);
// 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));
});
game.addChild(joystick);
-// Create a button at the bottom left of the screen
-var bottomLeftButton = new Button('10 Bullets: 50 Cosmic Credits', 150, game.height - 150, function () {
- // Define the action to be taken when the button is pressed
- console.log('Bottom left button pressed');
-});
-game.addChild(bottomLeftButton);
// Handle hero dragging
var dragNode = null;
game.on('down', function (obj) {
hero.shoot();
@@ -264,9 +233,8 @@
LK.setScore(newScore);
scoreTxt.setText('Score: ' + newScore);
var highScore = Math.max(newScore, Number((typeof localStorage !== 'undefined' ? localStorage.getItem('highScore') : '0') || '0'));
highScoreTxt.setText('High Score: ' + highScore + ' (WIP)');
- cosmicCredits.addCredits(5); // Award 5 Cosmic Credits for each enemy killed
if (typeof localStorage !== 'undefined' && newScore > highScore) {
localStorage.setItem('highScore', newScore.toString());
}
// Increment character's bullet limit
@@ -292,9 +260,9 @@
}
// Move enemies and check if they pass the red line
for (var k = enemies.length - 1; k >= 0; k--) {
enemies[k].move();
- if (enemies[k].y > redLine.y) {
+ if (enemies[k].y > game.height * 0.75) {
enemies[k].destroy();
enemies[k] = null;
enemies.splice(k, 1);
}
@@ -318,5 +286,10 @@
bulletPack.y = -bulletPack.height;
enemies.push(bulletPack); // Add bullet pack to enemies array for collision detection
game.addChild(bulletPack);
}
-});
\ No newline at end of file
+});
+// Create an interactive button at the bottom left of the screen
+var fireButton = new Button('Fire', 150, game.height - 150, function () {
+ hero.shoot();
+});
+LK.gui.bottomLeft.addChild(fireButton);
\ 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