Example #1
0
 public bool intersects(Rectangle2D r)
 {
     return ! ( r.x >= x + width
             || r.x + r.width <= x
             || r.y >= y + height
             || r.y + r.height <= y
             );
 }
Example #2
0
            public Particle(GameWorld world, double x, double y, double angle, double speed)
            {
                this.world = world;

                bounds = new Rectangle2D(x, y, 2, 2);

                velocity = new Vector2((float)(speed * Math.Cos(angle)), (float)(speed * Math.Sin(angle)));
            }
Example #3
0
        public void hurt(int damage)
        {
            health -= damage;

            if (hatLevel > 0)
            {
                Rectangle2D hat = new Rectangle2D(X, Y - 30, 20, 10);

                foreach (Entity e in World.getEntities())
                {
                    if (e.getBounds2D().intersects(hat))
                    {
                        while (hatLevel > 0)
                        {
                            hatLevel--;
                            World.add(new Hat(World, X, Y - 5, false));
                        }

                        return;
                    }
                }

                while (hatLevel > 0)
                {
                    hatLevel--;
                    World.add(new Hat(World, X, Y - 30 - 5 * hatLevel, false));
                }
            }
        }
Example #4
0
 public Entity(GameWorld world, double x, double y, double width, double height)
 {
     this.world = world;
     textures = new Dictionary<string, Texture2D>();
     bounds2D = new Rectangle2D(x, y, width, height);
 }