コード例 #1
0
ファイル: Player.cs プロジェクト: ttrammell98/Game
 public bool collidesWithCarrot(Carrot carrot)
 {
     if ((carrot.Bounds.X < position.X + FRAME_WIDTH) && (position.X < (carrot.Bounds.X + carrot.Bounds.Width)) && (carrot.Bounds.Y < position.Y + FRAME_HEIGHT) && (position.Y < carrot.Bounds.Y + carrot.Bounds.Height))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
 public Game1()
 {
     graphics = new GraphicsDeviceManager(this);
     Content.RootDirectory = "Content";
     player   = new Player(this);
     block1   = new Block(this, 0, 300);
     block2   = new Block(this, 550, 300);
     block3   = new Block(this, 995, 300); // middle of the new part of the world
     cake     = new Cake(this, 2, random);
     cookie   = new Cookie(this, 1, random);
     donut    = new Donut(this, 5, random);
     carrot   = new Carrot(this, -3, random);
     broccoli = new Broccoli(this, -5, random);
     blocks   = new List <Block>();
 }