Code edit (4 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
сделай чтобы после прыжка игрок не уменьшался
Code edit (7 edits merged)
Please save this source code
User prompt
добавь еще несколько типов объектов и комбинируй их
User prompt
добавь еще несколько типов объектов на орбиты и делай из них различные сочетания
Code edit (2 edits merged)
Please save this source code
User prompt
сделай чтобы игрок всегда смотрел в центр экрана
User prompt
Fix Bug: 'ReferenceError: Star is not defined' in or related to this line: 'if (child instanceof Star) {' Line Number: 359
User prompt
Fix Bug: 'ReferenceError: Star is not defined' in or related to this line: 'if (child instanceof Star) {' Line Number: 359
User prompt
добавь на задний фон эффект звезд летящих в экран
User prompt
добавь blackSphere эффект летящих звезд
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'player.radius = orbits[currentOrbitIndex].width / 2 - 50;' Line Number: 346
===================================================================
--- original.js
+++ change.js
@@ -1,17 +1,7 @@
/****
* Classes
****/
-/****
-TODO:
-* Maybe player should change orbit direction (and/or speed) with the orbit he jumps into?
-* Make sure orbits don't have too many obstacles.
-* Maybe skip player and obstacle updating while scaling?
-* Current min and max speeds of obstacles should be closer to each other.
-* Maybe background should tint with an offset on the colorwheel?
-* Rotate orbits with obstacles statically distributed on them instead of calculating obstacle positions (for performance).
-* Would also be cool to be able to jump in AND out of orbits, but hard to implement. Or maybe just tap on the orbit to go to?
-****/
// Player class
var Player = Container.expand(function () {
var self = Container.call(this);
var playerGraphics = self.attachAsset('player', {
@@ -80,17 +70,32 @@
self.x = self.radius * Math.cos(self.angle);
self.y = self.radius * Math.sin(self.angle);
};
});
+// Asteroid class
+var Asteroid = Container.expand(function () {
+ var self = Container.call(this);
+ var asteroidGraphics = self.attachAsset('obstacle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.orbitSpeed = -0.02;
+ self.move = function () {
+ self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (150 / self.width);
+ self.angle = (self.angle || 0) + self.orbitSpeed;
+ self.x = self.radius * Math.cos(self.angle);
+ self.y = self.radius * Math.sin(self.angle);
+ };
+});
// Powerup class
var Powerup1 = Container.expand(function () {
var self = Container.call(this);
var powerup1Graphics = self.attachAsset('powerup1', {
anchorX: 0.5,
anchorY: 0.5
});
//self.angleSpeed = 0.01;
- self.orbitSpeed = 0.075;
+ self.orbitSpeed = 0.03;
self.move = function () {
self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width) + 10;
self.angle = (self.angle || 0) + self.orbitSpeed;
self.x = self.radius * Math.cos(self.angle);
@@ -126,10 +131,16 @@
}
//self.barrierSpeed = Math.random() * currentOrbitIndex + 1 / 20;
self.barrierSpeed = 0.01 + Math.random() * 0.015 * self.direction;
for (var j = 0; j < this.numBarriers; j++) {
- self.addBarrier(self.barrierSpeed, j);
- //console.log('adding barrier: ', j);
+ var objectType = Math.random() < 0.5 ? 'obstacle' : Math.random() < 0.3 ? 'asteroid' : 'powerup';
+ if (objectType === 'obstacle') {
+ self.addBarrier(self.barrierSpeed, j);
+ } else if (objectType === 'asteroid') {
+ self.addAsteroid(self.barrierSpeed, j);
+ } else {
+ self.addPowerup(j);
+ }
}
}
};
var orbitGraphicsMask = self.attachAsset('blackSphere', {
@@ -160,8 +171,15 @@
powerup.angle = Math.PI * 1.5;
self.addChild(powerup);
obstacles.push(powerup);
};
+ self.addAsteroid = function (speed, index) {
+ var asteroid = new Asteroid();
+ asteroid.orbitSpeed = speed;
+ asteroid.angle = Math.random() * (Math.PI * 2);
+ self.addChild(asteroid);
+ obstacles.push(asteroid);
+ };
});
/****
* Initialize Game
@@ -388,9 +406,9 @@
}
};
var powerupText;
var showPowerupText = function showPowerupText() {
- powerupText = new Text2('Hyperjump Activated!\nAll visible obstacles cleared!\nTap to continue', {
+ powerupText = new Text2('Hyperjump Activated!\nThere are no obstacles for you!\nTap to continue', {
size: 100,
fill: "#bbbbbb",
align: 'center'
});
@@ -454,9 +472,9 @@
}
}
createOrbits();
// Add instruction text at the bottom of the screen
-var instructionText = new Text2('Tap to jump to the next orbit.\nDon\'t hit the red obstacles.', {
+var instructionText = new Text2('Tap to activate jet engine.\nDon\'t crash into space objects.', {
size: 50,
fill: "#bbbbbb",
align: 'center'
});
астероид. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Контейнер с энергией. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
черный круг с белыми точками. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.