User prompt
Planet should take in 4 parameters; x, y, radius and assetName
User prompt
Remove the tint for the grey planet
User prompt
Planet should return self at the bottom
User prompt
Fix Bug: 'TypeError: self is undefined' in this line: 'var planetGreyGraphics = self.createAsset('planetGrey', 'Grey Planet asset', 0.5, 0.5);' Line Number: 40
User prompt
the starter planet should be of PlanetGrey type
User prompt
PlanetGrey does not take in a radius parameter, instead it passes through a PLANET_RADIUS_GREY global to the Planet constructor
User prompt
Create a PlanetGrey class that inherits from Planet
User prompt
adjust the farms angle so its facing outwards
User prompt
create a farm around the perimeter of the planet based on the numPlots
User prompt
calculate how many plots a planet has by dividing its perimeter by the PLOT_SIZE+PLOT_GAP and rounding down
User prompt
define globals: PLOT_SIZE = 100 and PLOT_GAP = 25
User prompt
Planets should have their width and height set to twice the radius
User prompt
create a planet in the center of the screen
User prompt
remove the creation of the mainFarm and mainShip
User prompt
remove the market class
User prompt
create a planet class which has a radius member
Initial prompt
Farmer Nebula
/**** * Classes ****/ // Define the Farm class var Farm = Container.expand(function () { var self = Container.call(this); var farmGraphics = self.createAsset('farm', 'Farm asset', 0.5, 0.5); self.produce = function () { // Produce resources over time }; self.sell = function () { // Sell resources for currency }; }); // Define the Ship class var Ship = Container.expand(function () { var self = Container.call(this); var shipGraphics = self.createAsset('ship', 'Ship asset', 0.5, 0.5); self.travel = function () { // Travel to different planets }; self.trade = function () { // Trade resources between planets }; }); // Define the Planet class var Planet = Container.expand(function (x, y, radius, assetName) { var self = Container.call(this); self.x = x; self.y = y; self.radius = radius; var planetGraphics = self.createAsset(assetName, assetName + ' asset', 0.5, 0.5); planetGraphics.width = self.radius * 2; planetGraphics.height = self.radius * 2; // Calculate the number of plots based on the planet's perimeter var perimeter = 2 * Math.PI * self.radius; self.numPlots = Math.floor(perimeter / (PLOT_SIZE + PLOT_GAP)); return self; }); // Define the PlanetGrey class that inherits from Planet var PlanetGrey = Planet.expand(function () { var self = Planet.call(this, PLANET_RADIUS_GREY); var planetGreyGraphics = self.createAsset('planetGrey', 'Grey Planet asset', 0.5, 0.5); planetGreyGraphics.width = self.radius * 2; planetGreyGraphics.height = self.radius * 2; }); /**** * Initialize Game ****/ // Gap between farm plots var game = new LK.Game({ backgroundColor: 0x000000 // Init game with black background }); /**** * Game Code ****/ // Initialize important asset arrays var PLANET_RADIUS_GREY = 100; var PLOT_SIZE = 100; // Size of each farm plot var PLOT_GAP = 25; var farms = []; var ships = []; // Create initial game elements // Create a grey planet and place it in the center of the screen var planet = game.addChild(new PlanetGrey(2048 / 2, 2732 / 2, PLANET_RADIUS_GREY, 'planetGrey')); // Create farms around the perimeter of the planet for (var i = 0; i < planet.numPlots; i++) { var angle = i / planet.numPlots * 2 * Math.PI; var farmX = planet.x + planet.radius * Math.cos(angle); var farmY = planet.y + planet.radius * Math.sin(angle); var farm = new Farm(); farm.rotation = angle + Math.PI / 2; farm.x = farmX; farm.y = farmY; farms.push(farm); game.addChild(farm); } // Game logic LK.on('tick', function () { // Update farms for (var i = 0; i < farms.length; i++) { farms[i].produce(); } // Update ships for (var j = 0; j < ships.length; j++) { ships[j].travel(); } });
===================================================================
--- original.js
+++ change.js
@@ -23,12 +23,14 @@
// Trade resources between planets
};
});
// Define the Planet class
-var Planet = Container.expand(function (radius) {
+var Planet = Container.expand(function (x, y, radius, assetName) {
var self = Container.call(this);
+ self.x = x;
+ self.y = y;
self.radius = radius;
- var planetGraphics = self.createAsset('planet', 'Planet asset', 0.5, 0.5);
+ var planetGraphics = self.createAsset(assetName, assetName + ' asset', 0.5, 0.5);
planetGraphics.width = self.radius * 2;
planetGraphics.height = self.radius * 2;
// Calculate the number of plots based on the planet's perimeter
var perimeter = 2 * Math.PI * self.radius;
@@ -61,11 +63,9 @@
var farms = [];
var ships = [];
// Create initial game elements
// Create a grey planet and place it in the center of the screen
-var planet = game.addChild(new PlanetGrey());
-planet.x = 2048 / 2;
-planet.y = 2732 / 2;
+var planet = game.addChild(new PlanetGrey(2048 / 2, 2732 / 2, PLANET_RADIUS_GREY, 'planetGrey'));
// Create farms around the perimeter of the planet
for (var i = 0; i < planet.numPlots; i++) {
var angle = i / planet.numPlots * 2 * Math.PI;
var farmX = planet.x + planet.radius * Math.cos(angle);
pixel art of a tiny planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an alien currency symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet made of gold ore. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
plain black background with stars. 2d repeating Texture.
pixel art of a asteroid. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a cute alien farmer, side view. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a rocky explosion.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art flame particle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a large white, empty, rectangular, speech bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a red chevron. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of yellow grapes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.