private Vector2 spritePosition; // The current x, y position of the sprite #endregion Fields #region Constructors /// /// Constructor /// public Character(Game g, Vector2 startingPos, String charName) : base(g) { spritePosition = startingPos; // Initial position of the sprite // Description............................................ this.level = (g as Game1).level; // Each subclass/child class/class derived from Character (Kim, Ron, Rufus) // specifies own name when object is constructed (in Game1.cs) // This name is used to generate the file paths for all images for the character!! characterName = charName; isFacingRight = true; // the sprite sheets are by default right-facing IsSelected = false; // default to false // Kim child class overrides (she is initial starting character) // Initialize the array to contain the AnimatedTextures (different sprite animation loops) sprite = new AnimatedTexture[4]; //------------### need to do this or not??? // Just make sure these things are initialized, have to wait til loadcontent function // to actually make them right idleTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); runningTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); jumpingTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); specialMoveTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); //------------### // Set device frame rate to 30 fps. Game.TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0); }
///=========================================================================== /// Name: Initialize ///=========================================================================== protected override void Initialize() { // --- Add your initialization logic here --- // // // Centralized location where we specify all of the files to be used as sprite sheets for kim ron rufus // level = new Level(this); // level = new Platform(this); // Description...................... // Create the Character objects to use in the game // Second parameter specifies starting location on screen // Last parameter specifies last parameter specifies the characterName, // which is used to generate the images/sprite sheet asset names within the Character class // put the string names in the subclasses for further encapsulation //kim = new Kim(this, new Vector2(20, 300), "kim"); //ron = new Ron(this, new Vector2(30, 300), "ron"); //rufus = new Rufus(this, new Vector2(40, 300), "rufus"); kim = new Kim(this, new Vector2(20, 300)); ron = new Ron(this, new Vector2(30, 300)); rufus = new Rufus(this, new Vector2(40, 300)); Components.Add(level); // Add our characters to the game Components.Add(kim); Components.Add(ron); Components.Add(rufus); // The tornado nacho TornadoNacho(); // renamed from "FirstNacho()" //The Hamster Wheel nacho HamsterWheelNacho(); // Add the status bar Components.Add(new Stats(this, new Vector2(450, 70))); // The brick wall nacho...excellent commenting skillzz BrickWallNacho(); base.Initialize(); }
private Vector2 spritePosition; // The current x, y position of the sprite #endregion Fields #region Constructors /// /// Constructor for the Character class /// public Character(Game g, Vector2 startingPos, String charName) : base(g) { // Description............................................ this.level = (g as Game1).level; // Each subclass/child class/class derived from Character (Kim, Ron, Rufus) // specifies own name in its own constructor // (used to be Game1.cs, changed for further encapsulation) // This name is used to generate the file paths for all images for the character!! characterName = charName; spritePosition = startingPos; // Initial position of the sprite in the game initialPosition = startingPos; // Position that the character will return to if they die isFacingRight = true; // the sprite sheets are by default right-facing IsSelected = false; // default to false // Kim child class overrides (she is initial starting character) // Originally, these were private const member variables for animated sprites // since they don't get adjusted, just made them local variables //--- Member variables for animated sprites ---// float Rotation = 0; float Scale = 1.0f; float Depth = 0.5f; // Just make sure these things are initialized, // have to wait til loadcontent function to actually make them right idleTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); runningTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); jumpingTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); specialMoveTexture = new AnimatedTexture(Vector2.Zero, Rotation, Scale, Depth); // Initialize the array to contain the AnimatedTextures (different sprite animation loops) sprite = new AnimatedTexture[4]; // Set device frame rate to 30 fps. Game.TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0); }