Difference between revisions of "Game Programming Class6"

esse quam videri
Jump to: navigation, search
(PacMan Class Simplified and Generalized)
Line 23: Line 23:
  
 
==PacMan Class Simplified and Generalized==
 
==PacMan Class Simplified and Generalized==
 +
 +
<csharp>
 +
public enum PacManState { Spawning, Still, Chomping, SuperPacMan }
 +
 +
    public class PacMan
 +
    {
 +
 +
        protected PacManState _state;
 +
        public PacManState State
 +
        {
 +
            get { return _state; }
 +
            set
 +
            {
 +
                if (_state != value)
 +
                {
 +
                    this.Log(string.Format("{0} was: {1} now {2}", this.ToString(), _state, value));
 +
                   
 +
                    _state = value;
 +
                }
 +
            }
 +
        }
 +
 +
        public PacMan()
 +
        {
 +
           
 +
            //Set default state will call notify so make sure this.Ghosts is intitialized first
 +
            this.State = PacManState.Still;
 +
 +
        }
 +
 +
        //Extra method for logging state change
 +
        public virtual void Log(string s)
 +
        {
 +
            //nothing
 +
            Console.WriteLine(s);
 +
        }
 +
    }
 +
</csharp>
  
 
==Simple Animation==
 
==Simple Animation==

Revision as of 17:12, 3 March 2015


Physics

http://box2d.org/

c# Box2D https://code.google.com/p/box2dx/

https://github.com/d-snp/Farseer-Physics

http://farseerphysics.codeplex.com/

http://www.mataliphysics.com/

Protability

Separation of Concerns

Single Responsibility Principle

PacMan Class Simplified and Generalized

<csharp> public enum PacManState { Spawning, Still, Chomping, SuperPacMan }

   public class PacMan 
   {
       protected PacManState _state;
       public PacManState State
       {
           get { return _state; }
           set
           {
               if (_state != value)
               {
                   this.Log(string.Format("{0} was: {1} now {2}", this.ToString(), _state, value));
                   
                   _state = value;
               }
           }
       }
       public PacMan()
       {
           
           //Set default state will call notify so make sure this.Ghosts is intitialized first
           this.State = PacManState.Still;
       }
       //Extra method for logging state change
       public virtual void Log(string s)
       {
           //nothing
           Console.WriteLine(s);
       }
   }

</csharp>

Simple Animation

what extra fields do we need for animation?

http://create.msdn.com/en-US/education/catalog/sample/sprite_sheet

Platformer Example

Show platformer starter kit

http://msdn.microsoft.com/en-us/library/dd254918(v=xnagamestudio.31).aspx

simple and elegant but not that flexible

Animation Classes

Way too many classes for me to type here

  • PacMan States
  • PacMan Dying Animation
  • PacMan Eating

IntroAnimation Project IntroAnimation.zip

Complicated but flexible

  • DrawableAnimatableSprite.cs
  • CelAnimationManager.cs

Homework

Shooting Game

  • must use game components
  • must be multiplayer (both on keyboard or multiple game pads) don't use networking
  • must be able to shoot at each other or work together to shoot enemies
  • include shot manager and or shot manager

PadManShootCapture.PNG