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
/**** * 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', { anchorX: 0.5, anchorY: 0.5 }); self.radius = 900; self.angle = 0; self.jump = function () { currentOrbitIndex++; var targetOrbit = orbits[currentOrbitIndex]; self.angle = Math.atan2(self.y - 2732 / 2, self.x - 2048 / 2); if (targetOrbit) { //self.radius = (targetOrbit.width - 100) / 2; self.radius = targetOrbit.width / 2; //console.log('self.radius after setting it to targetOrbits: ' + self.radius); } else { self.radius = 0; // Fallback radius if targetOrbit is not defined } self.x = 2048 / 2 + self.radius * Math.cos(self.angle); self.y = 2732 / 2 + self.radius * Math.sin(self.angle); //self.scale.x = 0.70; //self.scale.y = 0.70; self.width = 70; self.height = self.width; scaling = true; LK.setScore(LK.getScore() + 1); scoreTxt.setText(LK.getScore()); /* var orbit = game.addChild(new Orbit()); orbit.positionOrbit(4); orbits.push(orbit); // Move player to the topmost z-index game.setChildIndex(player, game.children.length - 1); */ }; self.update = function () { var centerX = 2048 / 2; var centerY = 2732 / 2; self.angleSpeed = 0.01; self.angle = (self.angle || 0) + self.angleSpeed; self.x = centerX + self.radius * Math.cos(self.angle); self.y = centerY + self.radius * Math.sin(self.angle); }; }); // Obstacle class var Obstacle = Container.expand(function () { var self = Container.call(this); var obstacleGraphics = self.attachAsset('obstacle', { anchorX: 0.5, anchorY: 0.5 }); //self.angleSpeed = 0.01; self.orbitSpeed = -0.01; self.move = function () { // Obstacle move logic //var angleSpeed = -0.01 * self.parent.direction; //self.orbitSpeed; //self.radius = self.parent.width / 2 - self.width / 2; self.radius = self.parent.width / 2 * (1900 / self.parent.width) - self.width / 2 * (100 / self.width); self.angle = (self.angle || 0) + self.orbitSpeed; self.angle %= Math.PI * 2; 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.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); self.y = self.radius * Math.sin(self.angle); }; }); // Orbit class var Orbit = Container.expand(function () { var self = Container.call(this); var orbitGraphics = self.attachAsset('orbit1', { anchorX: 0.5, anchorY: 0.5, //tint: Math.floor(Math.random() * 16777215) tint: rainbowColors[orbitsCreated % rainbowColors.length] }); orbitsCreated++; orbitGraphics.alpha = 0.5; self.direction = Math.random() < 0.5 ? 1 : -1; self.positionOrbit = function (i) { self.x = 2048 / 2; self.y = 2732 / 2; this.width = 1900 - i * 500; this.height = 1900 - i * 500; if (i !== 0) { this.numBarriers = 1 + Math.floor(Math.random() * (i + currentOrbitIndex)); if (this.numBarriers > 12) { this.numBarriers = 12; } // Add powerup to some orbits if (orbitsCreated % 17 == 0) { this.numBarriers = 0; self.addPowerup(0); } //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 orbitGraphicsMask = self.attachAsset('blackSphere', { anchorX: 0.5, anchorY: 0.5, tint: 0x000000 //tint: rainbowColors[(orbitsCreated + 1) % rainbowColors.length] }); //orbitGraphicsMask.alpha = 0.1; orbitGraphicsMask.width = self.width - 200; orbitGraphicsMask.height = self.height - 200; self.addBarrier = function (speed, index) { var barrier = new Obstacle(); barrier.orbitSpeed = speed; //barrier.angle = index * (Math.PI * 2 / 20); barrier.angle = Math.random() * (Math.PI * 2); /* barrier.move = function () { barrier.angle += barrier.orbitSpeed * (self.direction === 1 ? 1 : -1); barrier.x = self.x + (self.width - barrier.width) / 2 * Math.cos(barrier.angle); barrier.y = self.y + (self.height - barrier.height) / 2 * Math.sin(barrier.angle); };*/ self.addChild(barrier); obstacles.push(barrier); }; self.addPowerup = function (index) { var powerup = new Powerup1(); powerup.angle = Math.PI * 1.5; self.addChild(powerup); obstacles.push(powerup); }; }); /**** * Initialize Game ****/ // Star class var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Star class function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) { descriptor.writable = true; } Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) { _defineProperties(Constructor.prototype, protoProps); } if (staticProps) { _defineProperties(Constructor, staticProps); } Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) { return t; } var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) { return i; } throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) { _setPrototypeOf(subClass, superClass); } } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) { return false; } if (Reflect.construct.sham) { return false; } if (typeof Proxy === "function") { return true; } try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var Star = /*#__PURE__*/function (_Container) { _inherits(Star, _Container); var _super = _createSuper(Star); function Star() { var _this; _classCallCheck(this, Star); _this = _super.call(this); var starGraphics = _this.attachAsset('blackSphere', { anchorX: 0.5, anchorY: 0.5, width: Math.random() * 10 + 1, height: Math.random() * 10 + 1 }); starGraphics.alpha = Math.random() * 0.5 + 0.5; _this.speed = Math.random() * 2 + 1; _this.z = Math.random() * 500 + 50; // Z position for depth effect return _this; } _createClass(Star, [{ key: "move", value: function move() { this.z -= this.speed; var scale = 500 / this.z; this.scale.x = this.scale.y = scale > 1 ? 1 : scale; // Ensure scale does not exceed 1 this.alpha = scale; // Fade out as it moves closer if (this.z <= 0) { this.x = Math.random() * 2048; this.y = Math.random() * 2732; this.z = Math.random() * 500 + 50; } } }]); return Star; }(Container); function hsvToHex(h, s, v) { var r, g, b, i, f, p, q, t; i = Math.floor(h * 6); f = h * 6 - i; p = v * (1 - s); q = v * (1 - f * s); t = v * (1 - (1 - f) * s); switch (i % 6) { case 0: r = v, g = t, b = p; break; case 1: r = q, g = v, b = p; break; case 2: r = p, g = v, b = t; break; case 3: r = p, g = q, b = v; break; case 4: r = t, g = p, b = v; break; case 5: r = v, g = p, b = q; break; } var toHex = function toHex(x) { var hex = Math.round(x * 255).toString(16); return hex.length === 1 ? '0' + hex : hex; }; return '0x' + toHex(r) + toHex(g) + toHex(b); } //console.log(rainbowColors); // A for our purposes optimized hitdetection, based on orbit layer and angle. var radIntersects = function radIntersects(p, t) { if (t.parent == orbits[currentOrbitIndex]) { var pa = (p.angle * (180 / Math.PI) + 180) % 360; var ta = (t.angle * (180 / Math.PI) + 180) % 360; if (Math.abs(pa - ta) < 6) { return true; } else { return false; } } else { return false; } }; var powerupText; var showPowerupText = function showPowerupText() { powerupText = new Text2('Powerup Activated!\nAll visible obstacles cleared!\nTap to continue', { size: 100, fill: "#bbbbbb", align: 'center' }); powerupText.y = 2700 / 2; powerupText.x = 2048 / 2; powerupText.anchor.set(0.5, 0.5); //instructionText.x = 2048 / 2; // Center horizontally //instructionText.y = 2732 - instructionText.height / 2; // Position at the bottom game.addChild(powerupText); LK.setTimeout(function () { var fadeDuration = 3000; var fadeStep = 30; var fadeInterval = fadeDuration / fadeStep; var currentStep = 0; var fadeOutInterval = LK.setInterval(function () { if (powerupText) { powerupText.alpha -= 1 / fadeStep; } currentStep++; if (currentStep >= fadeStep) { LK.clearInterval(fadeOutInterval); game.removeChild(powerupText); powerupText = null; } }, fadeInterval); }, 0); }; // Initialize assets used in this game. // Game variables var player; var orbits = []; var obstacles = []; var currentOrbitIndex = 0; var scaling = false; var scalingCounter = 0; var scalingSpeed = 50; //25; var scalingTarget = 500; var numColors = 18; var orbitsCreated = Math.floor(Math.random() * numColors); //0; var rainbowColors = function () { var colors = []; for (var i = 0; i < numColors; i++) { var hue = i * (360 / numColors) % 360; colors.push(hsvToHex(hue / 360, 1, 1)); } return colors; }(); var powerup1Activated = false; // Initialize player var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); LK.gui.top.addChild(scoreTxt); // Initialize orbits function createOrbits() { for (var i = 0; i < 5; i++) { var orbit = game.addChild(new Orbit()); orbit.positionOrbit(i); orbits.push(orbit); } } 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.', { size: 50, fill: "#bbbbbb", align: 'center' }); instructionText.y = 163; instructionText.x = 50; instructionText.anchor.set(0.5, 0); //instructionText.x = 2048 / 2; // Center horizontally //instructionText.y = 2732 - instructionText.height / 2; // Position at the bottom LK.gui.top.addChild(instructionText); //game.setBackgroundColor(rainbowColors[7] + 0xdddddd); player = game.addChild(new Player()); //player.x = 2048 / 2; //player.y = 2732 / 2 - 200; // Start the player 200px above the center /* console.log('Player radius is now: ' + player.radius); console.log('Orbits.length is now: ' + orbits.length); console.log('CurrentOrbitIndex is now: ' + currentOrbitIndex); console.log('width of currentorbit is now: ' + orbits[currentOrbitIndex].width); */ // Game logic game.on('down', function (obj) { if (powerupText) { game.removeChild(powerupText); powerupText = null; //return; } if (!scaling) { player.jump(currentOrbitIndex); LK.gui.top.removeChild(instructionText); } }); LK.on('tick', function () { player.update(); // Move stars for (var i = game.children.length - 1; i >= 0; i--) { var child = game.children[i]; if (child instanceof Star) { child.move(); } } if (powerup1Activated) { powerup1Activated = false; for (var i = obstacles.length - 1; i > 0; i--) { obstacles[i].destroy(); obstacles[i]._destroyed = true; } } if (scaling) { scalingCounter++; for (var i = 0; i < orbits.length; i++) { orbits[i].width += scalingSpeed; orbits[i].height += scalingSpeed; //player.radius += scalingSpeed * 0.1; } player.radius = orbits[currentOrbitIndex].width / 2 - 50; if (player.width < 100) { player.width += 0.3; player.height = player.width; } //player.scale.x = player.scale.y = if (scalingCounter == scalingTarget / scalingSpeed) { scaling = false; scalingCounter = 0; var orbit = game.addChild(new Orbit()); orbit.positionOrbit(4); orbits.push(orbit); game.setChildIndex(player, game.children.length - 1); player.width = 100; player.height = 100; //game.setBackgroundColor(rainbowColors[(10 + currentOrbitIndex) % 15] + 0xdddddd); /* console.log('Player radius is now: ' + player.radius); console.log('Orbits.length is now: ' + orbits.length); console.log('CurrentOrbitIndex is now: ' + currentOrbitIndex); console.log('width of currentorbit is now: ' + orbits[currentOrbitIndex].width); */ } } // Update orbits for (var i = orbits.length - 1; i > 0; i--) { //orbits[i].positionOrbit(i); var orb = orbits[i]; //if (orb && orb.width > 2700) { if (orb && orb.width > 3500) { for (var j = 0; j < orb.children.length; j++) { var child = orb.children[j]; if (child instanceof Obstacle || child instanceof Powerup1) { // child is an instance of YourClass, do something with it child._destroyed = true; } } orbits[i].destroy(); // Splice alters jump logic, so alter currentTargetOrbit too. orbits.splice(i, 1); currentOrbitIndex--; } } // Update obstacles for (var i = obstacles.length - 1; i > 0; i--) { if (obstacles[i] && !obstacles[i]._destroyed) { obstacles[i].move(); //if (player.intersects(obstacles[i])) { if (radIntersects(player, obstacles[i])) { var t = obstacles[i]; //console.log('collision occurred: (obstacle:', t.radius, t.angle % (Math.PI * 2), ') , (player: ', player.radius, player.angle % (Math.PI * 2)); var ta = (t.angle * (180 / Math.PI) + 180) % 360; var pa = (player.angle * (180 / Math.PI) + 180) % 360; //console.log(ta, pa); //if (radIntersects(player, obstacles[i], 100)) { if (obstacles[i] instanceof Powerup1) { obstacles[i].destroy(); obstacles[i]._destroyed = true; LK.effects.flashScreen(0xffffff, 1000); //LK.effects.flashScreen(rainbowColors[Math.floor(Math.random() * numColors)], 1000); powerup1Activated = true; showPowerupText(); } else { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } } } else { obstacles.splice(i, 1); //console.log('obstacles.length is now: ' + obstacles.length); } } }); // Star creation logic if (LK.ticks % 10 == 0) { var newStar = new Star(); newStar.x = 2048 / 2; newStar.y = 2732 / 2; game.addChild(newStar); }
===================================================================
--- original.js
+++ change.js
@@ -157,43 +157,185 @@
self.addChild(powerup);
obstacles.push(powerup);
};
});
-// Star class
-var Star = Container.expand(function () {
- var self = Container.call(this);
- var starGraphics = self.attachAsset('blackSphere', {
- anchorX: 0.5,
- anchorY: 0.5,
- width: Math.random() * 10 + 1,
- height: Math.random() * 10 + 1
- });
- starGraphics.alpha = Math.random() * 0.5 + 0.5;
- self.speed = Math.random() * 2 + 1;
- self.z = Math.random() * 500 + 50; // Z position for depth effect
- self.move = function () {
- self.z -= self.speed;
- var scale = 500 / self.z;
- self.scale.x = self.scale.y = scale > 1 ? 1 : scale; // Ensure scale does not exceed 1
- self.alpha = scale; // Fade out as it moves closer
- if (self.z <= 0) {
- self.x = Math.random() * 2048;
- self.y = Math.random() * 2732;
- self.z = Math.random() * 500 + 50;
- }
- };
-});
/****
* Initialize Game
****/
+// Star class
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
+// Star class
+function _typeof(o) {
+ "@babel/helpers - typeof";
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
+ return typeof o;
+ } : function (o) {
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
+ }, _typeof(o);
+}
+function _classCallCheck(instance, Constructor) {
+ if (!(instance instanceof Constructor)) {
+ throw new TypeError("Cannot call a class as a function");
+ }
+}
+function _defineProperties(target, props) {
+ for (var i = 0; i < props.length; i++) {
+ var descriptor = props[i];
+ descriptor.enumerable = descriptor.enumerable || false;
+ descriptor.configurable = true;
+ if ("value" in descriptor) {
+ descriptor.writable = true;
+ }
+ Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
+ }
+}
+function _createClass(Constructor, protoProps, staticProps) {
+ if (protoProps) {
+ _defineProperties(Constructor.prototype, protoProps);
+ }
+ if (staticProps) {
+ _defineProperties(Constructor, staticProps);
+ }
+ Object.defineProperty(Constructor, "prototype", {
+ writable: false
+ });
+ return Constructor;
+}
+function _toPropertyKey(t) {
+ var i = _toPrimitive(t, "string");
+ return "symbol" == _typeof(i) ? i : String(i);
+}
+function _toPrimitive(t, r) {
+ if ("object" != _typeof(t) || !t) {
+ return t;
+ }
+ var e = t[Symbol.toPrimitive];
+ if (void 0 !== e) {
+ var i = e.call(t, r || "default");
+ if ("object" != _typeof(i)) {
+ return i;
+ }
+ throw new TypeError("@@toPrimitive must return a primitive value.");
+ }
+ return ("string" === r ? String : Number)(t);
+}
+function _inherits(subClass, superClass) {
+ if (typeof superClass !== "function" && superClass !== null) {
+ throw new TypeError("Super expression must either be null or a function");
+ }
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
+ constructor: {
+ value: subClass,
+ writable: true,
+ configurable: true
+ }
+ });
+ Object.defineProperty(subClass, "prototype", {
+ writable: false
+ });
+ if (superClass) {
+ _setPrototypeOf(subClass, superClass);
+ }
+}
+function _setPrototypeOf(o, p) {
+ _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
+ o.__proto__ = p;
+ return o;
+ };
+ return _setPrototypeOf(o, p);
+}
+function _createSuper(Derived) {
+ var hasNativeReflectConstruct = _isNativeReflectConstruct();
+ return function _createSuperInternal() {
+ var Super = _getPrototypeOf(Derived),
+ result;
+ if (hasNativeReflectConstruct) {
+ var NewTarget = _getPrototypeOf(this).constructor;
+ result = Reflect.construct(Super, arguments, NewTarget);
+ } else {
+ result = Super.apply(this, arguments);
+ }
+ return _possibleConstructorReturn(this, result);
+ };
+}
+function _possibleConstructorReturn(self, call) {
+ if (call && (_typeof(call) === "object" || typeof call === "function")) {
+ return call;
+ } else if (call !== void 0) {
+ throw new TypeError("Derived constructors may only return object or undefined");
+ }
+ return _assertThisInitialized(self);
+}
+function _assertThisInitialized(self) {
+ if (self === void 0) {
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
+ }
+ return self;
+}
+function _isNativeReflectConstruct() {
+ if (typeof Reflect === "undefined" || !Reflect.construct) {
+ return false;
+ }
+ if (Reflect.construct.sham) {
+ return false;
+ }
+ if (typeof Proxy === "function") {
+ return true;
+ }
+ try {
+ Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
+ return true;
+ } catch (e) {
+ return false;
+ }
+}
+function _getPrototypeOf(o) {
+ _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
+ return o.__proto__ || Object.getPrototypeOf(o);
+ };
+ return _getPrototypeOf(o);
+}
+var Star = /*#__PURE__*/function (_Container) {
+ _inherits(Star, _Container);
+ var _super = _createSuper(Star);
+ function Star() {
+ var _this;
+ _classCallCheck(this, Star);
+ _this = _super.call(this);
+ var starGraphics = _this.attachAsset('blackSphere', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ width: Math.random() * 10 + 1,
+ height: Math.random() * 10 + 1
+ });
+ starGraphics.alpha = Math.random() * 0.5 + 0.5;
+ _this.speed = Math.random() * 2 + 1;
+ _this.z = Math.random() * 500 + 50; // Z position for depth effect
+ return _this;
+ }
+ _createClass(Star, [{
+ key: "move",
+ value: function move() {
+ this.z -= this.speed;
+ var scale = 500 / this.z;
+ this.scale.x = this.scale.y = scale > 1 ? 1 : scale; // Ensure scale does not exceed 1
+ this.alpha = scale; // Fade out as it moves closer
+ if (this.z <= 0) {
+ this.x = Math.random() * 2048;
+ this.y = Math.random() * 2732;
+ this.z = Math.random() * 500 + 50;
+ }
+ }
+ }]);
+ return Star;
+}(Container);
function hsvToHex(h, s, v) {
var r, g, b, i, f, p, q, t;
i = Math.floor(h * 6);
f = h * 6 - i;
астероид. 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.