예제 #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
             );
 }
예제 #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)));
            }
예제 #3
0
파일: Player.cs 프로젝트: ra4king/Shooter
        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));
                }
            }
        }
예제 #4
0
파일: Entity.cs 프로젝트: ra4king/Shooter
 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);
 }