Ejemplo n.º 1
0
 public void attach(string id, bBody body, int xoffset=0, int yoffset=0)
 {
     if (attached.ContainsKey(id))
     {
         bBodyPart bodyPart = attached[id];
         bodyPart.xoffset = xoffset;
         bodyPart.yoffset = yoffset;
         bodyPart.bodyPart = body;
     }
     else
     {
         Console.WriteLine("Couldn't attach " + id + " to body, config file did not include it");
     }
 }
Ejemplo n.º 2
0
        public Pair<bBody, bBody>[] collides(bBody other)
        {
            List<Pair<bBody, bBody>> collisionPairs = new List<Pair<bBody, bBody>>();

            // compute lists of both bodies
            bBody[] selfBodies = toArray();
            bBody[] otherBodies = other.toArray();

            foreach (bBody selfBody in selfBodies)
                foreach (bBody otherBody in otherBodies)
                {
                    if (selfBody.mask.collides(otherBody.mask))
                        collisionPairs.Add(new Pair<bBody, bBody>(selfBody, otherBody));
                }

            return collisionPairs.ToArray();
        }
Ejemplo n.º 3
0
        public override void init()
        {
            base.init();

            mask.w = 22; mask.h = 40;

            body = new bBody(game, "ringo_body_sheet", 22, 40);
            body.name = "body";
            int[] gfs = { 0, 1, 2, 3, 4, 5 };
            body.add(new bAnim("idle", gfs, 0.2f));
            body.play("idle");
            int[] wbfs = { 6, 7, 8, 0 };
            body.add(new bAnim("walk-back", wbfs, 0.2f));
            int[] wffs = { 8, 7, 6, 0 };
            body.add(new bAnim("walk-forward", wffs, 0.2f));
            int[] dffs = { 9, 10, 9 };
            body.add(new bAnim("damage", dffs, 0.7f, false));

            bBody fists = new bBody(game, "ringo_fists_sheet", 19, 12);
            fists.name = "fists";
            fists.add(new bAnim("idle", gfs, 0.2f));
            fists.play("idle");
            int[] lffs = { 0, 6, 7, 8, 9, 10 };
            fists.add(new bAnim("left-punch", lffs, 1.0f, false));
            int[] rffs = { 0, 12, 13, 14, 15, 16 };
            fists.add(new bAnim("right-punch", rffs, 1.0f, false));
            body.attach("fists", fists);

            bBody head = new bBody(game, "ringo_head_sheet", 21, 20);
            head.name = "head";
            int[] hifs = { 0, 1, 0, 0, 1, 0 };
            head.add(new bAnim("idle", hifs, 0.2f));
            int[] hdfs = { 2, 3, 2 };
            head.add(new bAnim("damage", hdfs, .7f, false));
            head.play("idle");
            body.attach("head", head);

            body.attached["fists"].zindex = 2;
            body.attached["head"].zindex = 1;

            actionState = ActionState.idle;
            playerNo = 0;  // by default
        }