Exemple #1
0
        public Entity(Vector2 position, Vector2 size, Texture tex, Vector2 texScale, bool solid)
        {
            float x = size.X / 2.0f;
            float y = size.Y / 2.0f;

            float[] vertices =
            {
                -x, y,
                -x, -y,
                x, y,
                x, -y
            };

            float[] texcoords =
            {
                0, 1,
                0, 0,
                1, 1,
                1, 0
            };

            byte[] indices =
            {
                0, 1, 2, 3
            };

            if (texScale != Vector2.One)
            {
                for (int i = 0; i < texcoords.Length; i += 2)
                {
                    texcoords[i] *= texScale.X;
                    texcoords[i + 1] *= texScale.Y;
                }
            }

            VBO verts = new VBO(), texC = new VBO(), ind = new VBO();
            verts.SetData(ref vertices, BufferUsageHint.StaticDraw);
            texC.SetData(ref texcoords, BufferUsageHint.StaticDraw);
            ind.SetData(ref indices, BufferUsageHint.StaticDraw);

            buffers = new BufferSet();
            buffers.VertexBuffer = verts;
            buffers.VertexSize = 2;
            buffers.TexCoordBuffer = texC;
            buffers.TexCoordSize = 2;
            buffers.IndexBuffer = ind;
            buffers.DrawMode = BeginMode.TriangleStrip;
            buffers.SetDrawState(DrawStates.Vertex | DrawStates.TexCoord);

            this.size = size;
            this.position = position;
            this.tex = tex;

            this.solid = solid;

            Name = string.Empty;
            Visible = true;

            RebuildModelMatrix();
        }
Exemple #2
0
        public Player(Vector2 position)
            : base(position, new Vector2(64, 64), Resources.Textures["playerf1.png"], Vector2.One, true)
        {
            texAltFrame = Resources.Textures["playerf2.png"];
            aBuf = Resources.Audio["move.wav"];
            aBuf.Looping = true;

            Inventory = new List<Entity>();

            AllowPickup = false;
        }
Exemple #3
0
 public Rock(Vector2 position, Texture tex)
     : base(position, new Vector2(tex.Size.Width, tex.Size.Height), tex, Vector2.One, true)
 {
     AllowPickup = false;
 }
Exemple #4
0
        public override void Update(double time)
        {
            base.Update(time);

            if (Moving)
            {
                if (aBuf.State != ALSourceState.Playing)
                    aBuf.Play();
                animTime += time;

                //on animation time, swap frames
                if (animTime >= 0.1)
                {
                    Texture temp = tex;
                    tex = texAltFrame;
                    texAltFrame = temp;
                    animTime = 0;
                }
            }

            else
            {
                aBuf.Stop();
            }
        }