Inheritance: SpringBody
Example #1
0
        public Enemy()
        {
            float scale = 0.5f;
            Vector2[] points = new Vector2[]
            {
                new Vector2(0,0),
                new Vector2(0,scale*0.5f),
                new Vector2(scale*0.5f,scale*0.5f),
                new Vector2(scale*0.5f,0),
            };

            shape = new Shape(points, true);

            body = new PressureBody(shape, 1, 1, 1300, 20, 1000, 20);

            max_speed = 2;
            radius = 2f;
        }
Example #2
0
        public Bubble(float scale)
        {
            this.scale = scale;
            this.curr_size = k.Length - 1;
            this.alpha = 1f;
            this.max_speed = 1.5f;

            List<Vector2> circle = new List<Vector2>();
            for (int i = 0; i < 360; i += 40)
                circle.Add(new Vector2((float)Math.Cos(MathHelper.ToRadians((float)-i)) * (scale + 0.005f), (float)Math.Sin(MathHelper.ToRadians((float)-i)) * (scale + 0.005f)));

            shape = new Shape(circle.ToArray(), true);
            body = new PressureBody(shape, 1, pressure[curr_size], k[curr_size], 20.0f, k[curr_size], 20.0f);

            vertices = circle;
            vertices.Add(Vector2.Zero);

            texture_coords = new List<Vector2>();
            for (int i = 0; i < circle.Count-1; i++)
            {
                Vector2 point = circle[i];
                if (point.X + point.Y != 0)
                {
                    point.Normalize();
                    point *= 1.025f;
                    point.X = (point.X + 1) * 0.5f;
                    point.Y = (point.Y + 1) * 0.5f;
                }

                texture_coords.Add(point);
            }
            texture_coords.Add(new Vector2(0.5f, 0.5f));

            SetSize(0);

            material = Resources.spriterenderer_material;
        }