Пример #1
0
 public static bool CollidesWith(this BoundaryRectangle a, BoundaryRectangle b)
 {
     return(!(a.X > a.X + b.Width ||
              a.X + a.Width < b.X ||
              a.Y > b.Y + b.Height ||
              a.Y + a.Height < b.Y));
 }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Stuff             stuff = Content.Load <Stuff>("stuff");
            BoundaryRectangle bbr   = new BoundaryRectangle(200, 400, 100, 50);

            balloon = new Player(this, bbr, 400);
            balloon.LoadContent(Content, "balloon");
            world = new AxisList();
            foreach (Vector2 v in stuff.points)
            {
                BoundaryRectangle sbr = new BoundaryRectangle(v, 20, 50);
                Spikes            sp  = new Spikes(sbr);
                sp.LoadContent(Content, "spike");
                spikes.Add(sp);
                world.AddGameObject(sp);
            }
        }
Пример #3
0
 public Spikes(BoundaryRectangle br)
 {
     bounds = br;
 }
Пример #4
0
 public Player(Game1 g, BoundaryRectangle br, int gl)
 {
     game        = g;
     bounds      = br;
     groundLevel = gl;
 }
Пример #5
0
 public static bool CollidesWith(this BoundaryRectangle r, Vector2 v)
 {
     return(v.CollidesWith(r));
 }
Пример #6
0
 public static bool CollidesWith(this Vector2 v, BoundaryRectangle r)
 {
     return((r.X <= v.X && v.X <= r.X + r.Width) &&
            (r.Y <= v.Y && v.Y <= r.Y + r.Height));
 }