Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Point is not a constructor' in or related to this line: 'var globalPlayerPosition = player.toGlobal(new Point(0, 0));' Line Number: 307
User prompt
please factor into the lookatplayer and shootatplayer functions, that they should work in the global scope, because player and the turretobstacle can be children of different containers.
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: speed is not defined' in or related to this line: 'turret.initialPosition(speed, angle, radius);' Line Number: 444
Code edit (1 edits merged)
Please save this source code
Code edit (20 edits merged)
Please save this source code
User prompt
please implement obstacleturrets shootatplayer method, so it sends turretshot in players direction
User prompt
please implement obstacleTurret's lookAtPlayer function, so it does what it says
Code edit (1 edits merged)
Please save this source code
Code edit (15 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'player.radius = orbits[currentOrbitIndex].width / 2 - 65;' Line Number: 783
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'width')' in or related to this line: 'player.radius = orbits[currentOrbitIndex].width / 2 - 65;' Line Number: 767
Code edit (1 edits merged)
Please save this source code
Code edit (22 edits merged)
Please save this source code
User prompt
in the dragon move function, please adjust the segment's radius up and down to convey a wavelike, snakelike slithering movement of the whole dragons body.
Code edit (1 edits merged)
Please save this source code
Code edit (10 edits merged)
Please save this source code
User prompt
implement the obstacleseeker function determineDirection
Code edit (10 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'particles[i].update();' Line Number: 706
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -1,9 +1,12 @@
/****
* Classes
****/
/****
+/****
TODO:
+* level system to determine orbit order.
+* Make turretshots lethal.
* Need fresh eyes on this tomorrow. I feel there's perhaps some uncanny valley effect going on, where adding richness
just makes it look more like a cheap version of something really cool, whereas the simple look made it feel like
it over-delivered on gameplay, compared to how it looked.
* Make some orbits with many evenly spread collectibles.
@@ -282,27 +285,26 @@
self.x = self.radius * Math.cos(self.angle);
self.y = self.radius * Math.sin(self.angle);
};
self.lookAtPlayer = function () {
- var globalPlayerPosition = player.toGlobal();
- var globalTurretPosition = self.toGlobal();
- var playerAngle = Math.atan2(globalPlayerPosition.y - globalTurretPosition.y, globalPlayerPosition.x - globalTurretPosition.x);
+ //var globalTurretPosition = self.toGlobal();
+ //var playerAngle = Math.atan2(player.y - globalTurretPosition.y, player.x - globalTurretPosition.x);
+ var playerAngle = Math.atan2(player.y - (self.y + self.parent.y), player.x - (self.x + self.parent.x));
self.rotation = playerAngle;
};
self.shootAtPlayer = function () {
- var globalPlayerPosition = player.toGlobal();
- var globalTurretPosition = self.toGlobal();
- var playerAngle = Math.atan2(globalPlayerPosition.y - globalTurretPosition.y, globalPlayerPosition.x - globalTurretPosition.x);
+ //var globalTurretPosition = self.toGlobal();
+ var playerAngle = Math.atan2(player.y - (self.y + self.parent.y), player.x - (self.x + self.parent.x));
var turretShot = new Container();
var shotGraphics = turretShot.attachAsset('turretShot', {
anchorX: 0.5,
anchorY: 0.5
});
- turretShot.x = globalTurretPosition.x;
- turretShot.y = globalTurretPosition.y;
- turretShot.rotation = playerAngle;
- turretShot.speedX = Math.cos(playerAngle) * 5;
- turretShot.speedY = Math.sin(playerAngle) * 5;
+ turretShot.x = (self.x + self.parent.x) / self.parent.scale.x;
+ turretShot.y = (self.y + self.parent.y) / self.parent.scale.y;
+ turretShot.rotation = playerAngle + Math.PI / 2;
+ turretShot.speedX = Math.cos(playerAngle) * 10;
+ turretShot.speedY = Math.sin(playerAngle) * 10;
turretShot.update = function () {
turretShot.x += turretShot.speedX;
turretShot.y += turretShot.speedY;
if (turretShot.x < 0 || turretShot.x > 2048 || turretShot.y < 0 || turretShot.y > 2732) {
@@ -313,11 +315,14 @@
//obstacles.push(turretShot);
};
self._move_migrated = function () {
self.lookAtPlayer();
- if (LK.ticks % 120 === 0) {
- // Shoot every 2 seconds (assuming 60 FPS)
- self.shootAtPlayer();
+ // Should only be true when player and turret in same layer.
+ if (self.parent.scale.x == 1) {
+ if (LK.ticks % 30 === 0) {
+ // Shoot every 2 seconds (assuming 60 FPS)
+ self.shootAtPlayer();
+ }
}
self.angle = (self.angle || 0) + self.orbitSpeed;
self.angle %= Math.PI * 2;
self.x = self.radius * Math.cos(self.angle);
@@ -330,14 +335,33 @@
var orbitGraphics = self.attachAsset('orbit1', {
anchorX: 0.5,
anchorY: 0.5,
//tint: Math.floor(Math.random() * 16777215)
- tint: rainbowColors[orbitsCreated % rainbowColors.length]
+ //tint: rainbowColors[orbitsCreated % rainbowColors.length]
+ tint: rainbowColors[colorOffset % rainbowColors.length]
});
orbitsCreated++;
+ colorOffset++;
orbitGraphics.alpha = 0.5; //0.5;
self.direction = Math.random() < 0.5 ? 1 : -1;
self.positionOrbit = function (i) {
+ // Set position and scale.
+ self.x = centerX;
+ self.y = centerY;
+ self.width = self.height = 1900 - i * 500;
+ // First orbit is always empty.
+ if (i == 0) {
+ return;
+ }
+ // Determine contents of this orbit.
+ // Every 17th orbit is reserved for a powerup.
+ if (orbitsCreated % 17 == 0) {
+ self.addCollectible(10);
+ self.addPowerup();
+ return;
+ }
+ };
+ self.OBS_positionOrbit = function (i) {
self.x = 2048 / 2;
self.y = 2732 / 2;
//this.width = 1900 - i * 500;
self.width = self.height = 1900 - i * 500;
@@ -382,9 +406,9 @@
var orbitGraphicsMask = self.attachAsset('blackSphere', {
anchorX: 0.5,
anchorY: 0.5,
tint: 0x000000
- //tint: rainbowColors[(orbitsCreated + 1) % rainbowColors.length]
+ //tint: rainbowColors[(colorOffset + 1) % rainbowColors.length]
});
orbitGraphicsMask.alpha = 0;
orbitGraphicsMask.width = self.width - 200;
orbitGraphicsMask.height = self.height - 200;
@@ -440,17 +464,20 @@
self.addChild(powerup);
obstacles.push(powerup);
}
};
- self.addCollectible = function () {
- var collectible = new Collectible();
- // TODO: Maybe orbitspeed should always be 0 (or close to 0) for these collectibles, But they should pulse in place instead.
- //collectible.orbitSpeed = 0.01 + Math.random() * 0.015 * self.direction;
- collectible.orbitSpeed = 0.0005 * self.direction;
- collectible.angle = Math.random() * (Math.PI * 2);
- collectible.radius = 880;
- self.addChild(collectible);
- obstacles.push(collectible);
+ self.addCollectible = function (num) {
+ var angleOffset = Math.random() * (Math.PI * 2);
+ for (var i = 0; i < num; i++) {
+ var collectible = new Collectible();
+ // TODO: Maybe orbitspeed should always be 0 (or close to 0) for these collectibles, But they should pulse in place instead.
+ //collectible.orbitSpeed = 0.01 + Math.random() * 0.015 * self.direction;
+ collectible.orbitSpeed = 0.0005 * self.direction;
+ collectible.angle = Math.PI * 2 / i; //Math.random() * (Math.PI * 2);
+ collectible.radius = 880;
+ self.addChild(collectible);
+ obstacles.push(collectible);
+ }
};
});
var Particle = Container.expand(function (i) {
var self = Container.call(this);
@@ -505,9 +532,9 @@
self.radius = 0; // Fallback radius if targetOrbit is not defined
}
self.x = centerX + self.radius * Math.cos(self.angle);
self.y = centerY + self.radius * Math.sin(self.angle);
- game.setBackgroundColor(rainbowColors[(orbitsCreated + 4) % rainbowColors.length]);
+ game.setBackgroundColor(rainbowColors[(colorOffset + 4) % rainbowColors.length]);
//self.scale.x = 0.70;
//self.scale.y = 0.70;
self.width = 70;
self.height = self.width;
@@ -567,27 +594,40 @@
/****
* Game Code
****/
-/****
-TODO:
-* What if holding mouse down didn't just stall movement, but move player the other way?
-* Update the instructions to explain the new hold to stall mechanic.
-* Perhaps give player 3 lives?
-* Implement the seeker type enemy.
-* Figure out why stuff shows up in the center on start?
-* Sound & Music.
-* Maybe skip player and obstacle updating while scaling?
-* 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?
-****/
-// Initialize player
var centerX = 2048 / 2;
var centerY = 2732 / 2;
var ENEMY_WOBBLE = false;
var PARTICLES_ON = true;
var INCREASE_DIFFICULTY_EVERY_X_LEVELS = 15;
+var GAME_ENDED = false;
var maxEnemiesPerOrbit = 2;
+var player;
+var playerSpeed = 0.005; //0.01;
+var maxEnemySpeed = 0.01;
+var collectiblesCollected = 0;
+var orbits = [];
+var obstacles = [];
+var currentOrbitIndex = 0;
+var scaling = false;
+var scalingCounter = 0;
+var scalingSpeed = 50;
+var scalingTarget = 500;
+var powerupText;
+var stalling = false;
+var powerup1Activated = false;
+var numColors = 18;
+var orbitsCreated = 0; //Math.floor(Math.random() * numColors);
+var colorOffset = Math.floor(Math.random() * numColors);
+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 fullscreenBackground = LK.getAsset('fullscreenBackground', {
anchorX: 0.507,
anchorY: 0.46,
x: 2048 / 2,
@@ -642,9 +682,8 @@
} 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",
@@ -677,31 +716,8 @@
}, 0);
};
// Initialize assets used in this game.
// Game variables
-var player;
-var playerSpeed = 0.005; //0.01;
-var maxEnemySpeed = 0.01;
-var collectiblesCollected = 0;
-var orbits = [];
-var obstacles = [];
-var currentOrbitIndex = 0;
-var scaling = false;
-var scalingCounter = 0;
-var scalingSpeed = 50;
-var scalingTarget = 500;
-var numColors = 18;
-var orbitsCreated = Math.floor(Math.random() * numColors);
-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 scoreText = new Text2('0', {
size: 150,
align: 'center',
fill: "#ffffff",
@@ -761,14 +777,14 @@
console.log('CurrentOrbitIndex is now: ' + currentOrbitIndex);
console.log('width of currentorbit is now: ' + orbits[currentOrbitIndex].width);
*/
function increaseDifficulty() {
- maxEnemiesPerOrbit++;
- maxEnemySpeed += 0.002;
- playerSpeed += 0.002;
+ if (maxEnemiesPerOrbit < 8) {
+ maxEnemiesPerOrbit++;
+ }
+ maxEnemySpeed += 0.001;
+ playerSpeed += 0.001;
}
-var stalling = false;
-var GAME_ENDED = false;
// Game logic
game.on('down', function (x, y, obj) {
if (!GAME_ENDED) {
if (!stalling) {
Make the circle completely black on all pixels.
A white star. Flat vector art.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
The line-color should be white, and the circle a bit thinner.
a wonderful but not very dense starfield. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A glowing blue comic energy orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
I'd like a top down image of a super fine and thin white empty cicular band on a transparent background. It should be flatly white and with no other details, and of course perfectly round with blank space in the center. The band's width should be less than one percent of the width of the circle itself, as if a 1 cm band were laid out in a circle with a diameter of 100 cm. Single Game Texture. In-Game asset. 2d. Blank background.