Exemple #1
0
        public Tank(string tank, string turret, string bulletF)
        {
            bullet     = new Bullet(bulletF);
            BulletAABB = bullet.bulletB;
            //Loading tank texture
            tankSprite.Load(tank);

            // sprite is facing the wrong way... fix that here
            tankSprite.SetRotate(-90 * (float)(Math.PI / 180.0f));

            // sets an offset for the base, so it rotates around the centre
            tankSprite.SetPosition(-tankSprite.Width / 2.0f, tankSprite.Height / 2.0f);

            //Loading turret texture
            turretSprite.Load(turret);

            // sprite is facing the wrong way... fix that here
            turretSprite.SetRotate(-90 * (float)(Math.PI / 180.0f));

            // set the turret offset from the tank base
            turretSprite.SetPosition(0, turretSprite.Width / 2.0f);
            Corners[0] = new SceneObject();
            Corners[0].SetPosition(-38, -40);

            Corners[1] = new SceneObject();
            Corners[1].SetPosition(32, -40);

            Corners[2] = new SceneObject();
            Corners[2].SetPosition(32, 35);

            Corners[3] = new SceneObject();
            Corners[3].SetPosition(-38, 35);

            AddChild(Corners[0]);
            AddChild(Corners[1]);
            AddChild(Corners[2]);
            AddChild(Corners[3]);


            // set up the scene object hierarchy - parent the turret to the base,
            // then the base to the tank sceneObject
            turretObject.AddChild(turretSprite);
            AddChild(tankSprite);
            AddChild(turretObject);

            // having an empty object for the tank parent means we can set the
            // position/rotation of the tank without
            // affecting the offset of the base sprite
            SetPosition(GetScreenWidth() / 2, GetScreenHeight() / 2);
        }
Exemple #2
0
 public bool Overlaps(AABB2 other)
 {
     // test for not overlapped as it exits faster
     return(!(max.x < other.min.x || max.y < other.min.y || min.x > other.max.x || min.y > other.max.y));
 }
Exemple #3
0
 public bool Overlaps(AABB2 other)
 {
     return(!(max.x < other.min.x || max.y < other.min.y || min.x > other.max.x || min.y > other.max.y));
 }