Example #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);
        }
Example #2
0
        public void Draw(Vector3 position, Bounds bounds)
        {
            GL.Enable(EnableCap.Texture2D);
            GL.BindTexture(TextureTarget.Texture2D, _id);
            GL.Begin(BeginMode.Quads);
            GL.Color4(color);

            GL.TexCoord2(0.0, 0.0);
            GL.Vertex2(position.X - bounds.halfWidth, position.Y - bounds.halfHeight);
            GL.TexCoord2(0.0, 1.0);
            GL.Vertex2(position.X - bounds.halfWidth, position.Y + bounds.halfHeight);
            GL.TexCoord2(1.0, 1.0);
            GL.Vertex2(position.X + bounds.halfWidth, position.Y + bounds.halfHeight);
            GL.TexCoord2(1.0, 0.0);
            GL.Vertex2(position.X + bounds.halfWidth, position.Y - bounds.halfHeight);

            GL.End();
            GL.Disable(EnableCap.Texture2D);
        }
Example #3
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;
        }
Example #4
0
        public Building(Vector2 pos, Bounds bounds)
        {
            health = 5;

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

            standing000 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing001 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing002 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            standing000.setTexture("../../res/tex/building/standing000.png");
            standing001.setTexture("../../res/tex/building/standing001.png");
            standing002.setTexture("../../res/tex/building/standing002.png");
            List<Rectangle> standingFrames = new List<Rectangle>();
            standingFrames.Add(standing000);
            standingFrames.Add(standing001);
            standingFrames.Add(standing002);
            standingAnim = new Animation(standingFrames, 100, AnimationMode.LOOP);

            hit000 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit001 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit002 = new Rectangle(pos.X, pos.Y, bounds.width, bounds.height);
            hit000.setTexture("../../res/tex/building/hit000.png");
            hit001.setTexture("../../res/tex/building/hit001.png");
            hit002.setTexture("../../res/tex/building/hit002.png");
            List<Rectangle> hitFrames = new List<Rectangle>();
            hitFrames.Add(hit000);
            hitFrames.Add(hit001);
            hitFrames.Add(hit002);
            hitAnim = new Animation(hitFrames, 8, AnimationMode.LOOP);

            hit = false;
            hitAnimTimer = new Timer(30);

            currentAnim = standingAnim;
        }
Example #5
0
 public Rectangle(float x, float y, int z, int w, int h)
 {
     bounds = new Bounds(w, h);
     position = new Vector3(x, y, z);
     MugicObjectManager.Register(this);
 }
Example #6
0
 public BoundingBox(float x, float y, Bounds bounds)
 {
     this.x      = x;
     this.y      = y;
     this.bounds = bounds;
 }
Example #7
0
 public BoundingBox(Vector2 vect, Bounds bounds)
     : this(vect.X, vect.Y, bounds)
 {
 }