Esempio n. 1
0
        public Punch(Vector2 p)
        {
            pos = p;

            Bounds bounds = new Bounds(20, 20);
            boundingBox = new BoundingBox(pos, bounds);

            rectangle = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            rectangle.setColor(255, 0, 0, 255);
        }
Esempio n. 2
0
        public Player(Vector2 p)
        {
            pos = p;
            //rectangle = new Rectangle(p.X, p.Y, PLAYER_WIDTH, PLAYER_HEIGHT);
            //rectangle.setTexture("../../res/tex/george.png");

            bounds = new Bounds(PLAYER_WIDTH, PLAYER_HEIGHT);

            boundingBox = new BoundingBox(p.X, p.Y, bounds);

            XLG.keyboard.KeyDown += new EventHandler<KeyboardKeyEventArgs>(OnKeyDown);
            XLG.keyboard.KeyUp += new EventHandler<KeyboardKeyEventArgs>(OnKeyUp);

            facing = -1;

            /// TIMER INIT
            timers  = new List<Timer>();
            punchCooldown = new Timer(40);
            punchLength = new Timer(2);

            timers.Add(punchCooldown);
            timers.Add(punchLength);

            /// ANIM INIT
            standingLAnim = new Animation(1, AnimationMode.PAUSE);
            standingRAnim = new Animation(1, AnimationMode.PAUSE);
            walkingLAnim = new Animation(8, AnimationMode.LOOP, LoopMode.PINGPONG);
            walkingRAnim = new Animation(8, AnimationMode.LOOP, LoopMode.PINGPONG);

            standingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_standing_L00), bounds.width, bounds.height);
            standingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_standing_R00), bounds.width, bounds.height);

            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L00), bounds.width, bounds.height);
            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L01), bounds.width, bounds.height);
            walkingLAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_L02), bounds.width, bounds.height);

            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R00), bounds.width, bounds.height);
            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R01), bounds.width, bounds.height);
            walkingRAnim.AddFrame(ImageManager.GetImage(ImageName.player_walking_R02), bounds.width, bounds.height);

            currentAnim = standingLAnim;
        }
Esempio n. 3
0
        public bool isColliding(BoundingBox other)
        {
            float myLeft = x - bounds.halfWidth;
            float myRight = x + bounds.halfWidth;
            float myTop = y - bounds.halfHeight;
            float myBottom = y + bounds.halfHeight;

            float theirLeft = other.x - other.bounds.halfWidth;
            float theirRight = other.x + other.bounds.halfWidth;
            float theirTop = other.y - other.bounds.halfHeight;
            float theirBottom = other.y + other.bounds.halfHeight;

            if (myLeft > theirRight ||
                myRight < theirLeft ||
                myTop > theirBottom ||
                myBottom < theirTop)
            {
                return false;
            }

            return true;
        }