コード例 #1
0
ファイル: Bullet.cs プロジェクト: ilay122/XNA-3D-Basics
        public Bullet(Model model,FirstPersonCamera cam)
        {
            shape = new Sprite3D(model);
            this.cam = cam;
            shape.setPosition(cam.getPosition());
            shape.setScale(Consts.WORLDSCALE / 10f);

            float dx = cam.getLookAt().X - shape.getPosition().X;
            float dy = cam.getLookAt().Y - shape.getPosition().Y;
            float dz = cam.getLookAt().Z - shape.getPosition().Z;
            float d = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz));

            this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED);
        }
コード例 #2
0
        public Bullet(Model model, FirstPersonCamera cam)
        {
            shape    = new Sprite3D(model);
            this.cam = cam;
            shape.setPosition(cam.getPosition());
            shape.setScale(Consts.WORLDSCALE / 10f);

            float dx = cam.getLookAt().X - shape.getPosition().X;
            float dy = cam.getLookAt().Y - shape.getPosition().Y;
            float dz = cam.getLookAt().Z - shape.getPosition().Z;
            float d  = (float)(Math.Sqrt(dx * dx + dy * dy + dz * dz));

            this.velocity = new Vector3(dx / d * Consts.BULLETSPEED, dy / d * Consts.BULLETSPEED, dz / d * Consts.BULLETSPEED);
        }
コード例 #3
0
 public bool collidesWithMap(Sprite3D spr)
 {
     foreach (Sprite3D block in Blocks)
     {
         if (spr.intersects(block))
         {
             return(true);
         }
     }
     foreach (Image3D img in images)
     {
         if (img.getBoundingBox().Contains(spr.getBoundings()) != ContainmentType.Disjoint)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: ilay122/XNA-3D-Basics
        public bool collidesWithMap(Sprite3D spr)
        {
            foreach (Sprite3D block in Blocks)
            {
                if (spr.intersects(block))
                {
                    return true;
                }

            }
            foreach (Image3D img in images)
            {
                if (img.getBoundingBox().Contains(spr.getBoundings()) != ContainmentType.Disjoint)
                {
                    return true;
                }
            }
            return false;
        }
コード例 #5
0
 public bool intersects(Sprite3D spr)
 {
     return(getBoundings().Contains(spr.getBoundings()) != ContainmentType.Disjoint);
 }
コード例 #6
0
ファイル: Sprite3D.cs プロジェクト: ilay122/XNA-3D-Basics
 public bool intersects(Sprite3D spr)
 {
     return getBoundings().Contains(spr.getBoundings()) != ContainmentType.Disjoint;
 }