/// <summary> /// Construct a new jumpman. /// </summary> /// <param name="position">Position of the jumpman.</param> /// <param name="energy">Amount of energy to start with.</param> /// <param name="genome">The genes of the jumpman.</param> /// <param name="rand">A RNG used for random movement.</param> public Jumpman(Vector2 position, double energy, Genome genome, Random rand) : base(position, Vector2.one, Z_INDEX) { this.sprites = new Texture[] { new Texture(Globals.renderer, RIGHT_TEXTURE_NAME), new Texture(Globals.renderer, LEFT_TEXTURE_NAME), new Texture(Globals.renderer, FRONT_TEXTURE_NAME) }; this.energy = energy; this.genome = genome; this.rand = rand; this.attr = JumpmanAttributes.FromGenome(genome); // Apply the attr. this.transform.scale = Vector2.one * attr.size; this.velocity = attr.speed * Vector2.FromAngle(rand.NextDouble() * 2 * Math.PI); foreach (Texture t in sprites) { t.SetColorMod(attr.color); } }
public EnvironmentTracker(Environment environment) { nutrition = 0; jumpmanCount = 0; averageJumpmanAttr = new JumpmanAttributes(); // Create writers for the temporary data files. nutritionTmpPath = Path.GetTempFileName(); jumpmanCountTmpPath = Path.GetTempFileName(); averageJumpmanAttrTmpPath = Path.GetTempFileName(); nutritionSW = new StreamWriter(nutritionTmpPath, true); jumpmanCountSW = new StreamWriter(jumpmanCountTmpPath, true); averageJumpmanAttrSW = new StreamWriter(averageJumpmanAttrTmpPath, true); // Debug Console.WriteLine(nutritionTmpPath); Console.WriteLine(jumpmanCountTmpPath); Console.WriteLine(averageJumpmanAttrTmpPath); // Add the event handlers to the environment. environment.SceneObjectAdded += c_SceneObjectAdded; environment.SceneObjectRemoved += c_SceneObjectRemoved; }