Code edit (11 edits merged)
Please save this source code
User prompt
place the game logoon the screen
User prompt
make a gamelogo object
Code edit (1 edits merged)
Please save this source code
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: astronauy is not defined' in or related to this line: 'if (LK.getScore() > 300 && javelins[i].intersects(astronaut) && astronauy.y > 825) {' Line Number: 220
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
particle's update function should make them spread briefly and then disappear.
Code edit (9 edits merged)
Please save this source code
User prompt
create a function that creates a small dust particle explosion
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: austroanut is not defined' in or related to this line: 'if (austroanut.y < 818) {' Line Number: 196
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
update the score and scorelabel text every frame when thrown is true.
Code edit (13 edits merged)
Please save this source code
User prompt
make a score label top center of screen
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
create an actionmeter at the bottom of the screen
Code edit (11 edits merged)
Please save this source code
User prompt
make a text label at the bottom of the screen: "Tap to throw the javelin"
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,25 @@
/****
* Classes
****/
+var Astronaut = Container.expand(function () {
+ var self = Container.call(this);
+ var surfaceGraphics = self.attachAsset('athlete', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ /*
+ x: 1024,
+ y: 818,*/
+ vely: 0
+ });
+ self.move = function () {
+ self.x += 12;
+ self.rotation += 0.1;
+ };
+ self.vely = 0;
+ self.x = 1024;
+ self.y = 818;
+});
// DustParticle class
var DustParticle = Container.expand(function () {
var self = Container.call(this);
// Create a simple square shape for the particle
@@ -25,8 +43,33 @@
self.destroy();
}
};
});
+// GoreParticle class
+var GoreParticle = Container.expand(function () {
+ var self = Container.call(this);
+ // Create a simple square shape for the particle
+ var particleGraphics = self.attachAsset('particle2', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.width = 25 + Math.random() * 25;
+ self.height = self.width;
+ // Set initial speed and direction
+ self.speedX = Math.random() * 20;
+ self.speedY = Math.random() * 20 - 10;
+ // Set the particle to move and fade out over time
+ self.update = function () {
+ self.x += self.speedX;
+ self.y += self.speedY;
+ self.speedX *= 0.95; // Reduce speed for spreading effect
+ self.speedY *= 0.95; // Reduce speed for spreading effect
+ particleGraphics.alpha *= 0.95; // Increase alpha reduction for quicker disappearance
+ if (particleGraphics.alpha < 0.01) {
+ self.destroy();
+ }
+ };
+});
// Assets will be automatically generated based on usage in the code.
// Javelin class
var Javelin = Container.expand(function () {
var self = Container.call(this);
@@ -50,9 +93,9 @@
self.rotation = -0.30;
self.orbitSpeed = 0.045;
self.angle = 4.6;
self.radius = 570; //670 - 20 * (100 / 20);
- console.log('radius ' + self.radius);
+ //console.log('radius ' + self.radius);
self.move = function () {
//self.radius = 670 - 20 * (100 / 20);
//self.angle = (self.angle || 0) + self.orbitSpeed;
self.angle = (self.angle || 0) + speed;
@@ -66,8 +109,12 @@
self.rotation += 0.05;
createDustExplosion(self.x, self.y, 20);
}
};
+ self.hitUpdate = function () {
+ self.x += 12;
+ self.rotation += 0.1;
+ };
});
// Moon surface class for visual effect
var MoonSurface = Container.expand(function () {
var self = Container.call(this);
@@ -88,8 +135,16 @@
/****
* Game Code
****/
+/*
+* Show some educational texts, maybe linked via a quesition mark button, or as a fake preloader screen:
+- The first and only astronaut to actually throw a javelin on the moon was Edgar Mitchell. This is an actual quote
+(about his experience of looking at earth from space):
+ "You want to grab a politician by the scruff of the neck and drag him a quarter of a million miles out and say,
+ "Look at that, you son of a bitch." " -End quote.
+*/
+// TODO:
// Function to create a dust particle explosion
function createDustExplosion(x, y, count) {
for (var i = 0; i < count; i++) {
var particle = new DustParticle();
@@ -98,8 +153,17 @@
game.addChild(particle);
particles.push(particle);
}
}
+function createImpactExplosion(x, y, count) {
+ for (var i = 0; i < count; i++) {
+ var particle = new GoreParticle();
+ particle.x = x;
+ particle.y = y;
+ game.addChild(particle);
+ particles.push(particle);
+ }
+}
// Initialize important variables and arrays
var javelins = [];
var background = game.attachAsset('background', {
anchorX: 0.5,
@@ -109,15 +173,20 @@
alpha: 0.5
});
var moonSurface = game.addChild(new MoonSurface());
// Add the astronaut to the scene
-var astronaut = game.attachAsset('athlete', {
+var astronaut = game.addChild(new Astronaut());
+/*var astronaut = game.attachAsset('athlete', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 818,
vely: 0
});
+astronaut.move = function () {
+ self.x += speed;
+ self.rotation += 0.1;
+};*/
var javelin = game.addChild(new Javelin());
javelin.x = astronaut.x - 70;
javelin.y = astronaut.y;
var started = false;
@@ -174,8 +243,9 @@
var minSpeed = 0.02;
var maxSpeed = 0.045;
var speed = 0;
var landed = false;
+var playerHit = false;
// Touch event to launch a javelin
game.on('down', function (obj) {
if (!started) {
started = true;
@@ -188,9 +258,9 @@
//console.log('speed ' + speed);
launchJavelin();
} else {
//if (astronaut.vely == 0) {
- if (astronaut.y > 818) {
+ if (astronaut.y >= 818) {
astronaut.vely += 10;
}
}
});
@@ -204,10 +274,19 @@
}
if (thrown && !landed) {
for (var i = javelins.length - 1; i >= 0; i--) {
javelins[i].move();
- if (LK.getScore() > 300 && javelins[i].intersects(astronaut) && astronaut.y > 825) {
+ if (LK.getScore() > 300 && javelins[i].intersects(astronaut) && astronaut.y >= 818) {
landed = true;
+ createImpactExplosion(astronaut.x, astronaut.y, 20);
+ astronaut.removeChildAt(0);
+ astronaut.attachAsset('athlete-hit', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ rotation: Math.PI / 2
+ });
+ javelins[i].move = javelins[i].hitUpdate;
+ playerHit = true;
}
// Remove javelins that have fallen off the screen
/*if (javelins[i].y > 2732) {
javelins[i].destroy();
@@ -230,8 +309,12 @@
if (astronaut.y < 818) {
astronaut.y += 3;
}
if (landed) {}
+ if (playerHit) {
+ javelin.move();
+ astronaut.move();
+ }
for (var i = particles.length - 1; i >= 0; i--) {
particles[i].update();
}
});
pixelart. a beautiful moon.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart a beautiful starry sky seen in empty outer space.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. a javelin used for olympic games and athletics. Just the spear itself, horizontally laid out in the image. It should be a slim metal spear, pointy in both ends, and with a grip somewhere off center of the shaft.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. a metallic triangular pointer.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart lettering of the word 'LUNAR' with some blank space around it.
replace inpainted area with transparency.
pixelart. asteroid with craters. subtle shading.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixelart. asteroid with craters. subtle shading.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small light yellow star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete the inpainted areas.
Pixelart. A background window for an in-game shop, with a space theme. The center part should be a large blank area with space for the items and labels for sale in the game shop. The blank space could have the form of a black computer screen inside a spaceship.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixelart. An icon of a an arm holding javelin with fire around it.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Turn in-painted area solid blue like the area around it.
Pixelart. A rectangular silvery button with the text 'CLOSE'.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.