public AnimatedSprite(Texture2D texture,int rows, int columns, int count)
 {
     this.Texture = texture;
     this.Rows = rows;
     this.Columns = columns;
     currentFrame = 0;
     totalFrames = count;
 }
Esempio n. 2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            //texture = ContentPipe.LoadTexture("texture.png");

            GL.Enable(EnableCap.Texture2D);
            tileset = ContentPipe.LoadTexture("TileSet1.png");
            level = new Level("Content/labirint.tmx");
            texture = ContentPipe.LoadTexture("Waiting.png");
            hero = new AnimatedSprite(texture,1,5,4);
            texture = ContentPipe.LoadTexture("runnerLeft.png");
            runnerLeft = new AnimatedSprite(texture, 1, 4, 4);
            texture = ContentPipe.LoadTexture("runnerRight.png");
            runnerRight = new AnimatedSprite(texture, 1, 4, 4);
            texture = ContentPipe.LoadTexture("runnerClimb.png");
            runnerClimb = new AnimatedSprite(texture, 1, 2, 2);

            gameState=GameState.Menu;
            runnerState = RunnerState.Right;
            runnerPosX=50;
            runnerPosY=377;

            melodyMenu =  "Content/AKINALO.WAV";
            melodyGame = "Content/MS3ALL_F_00010.wav";

            simpleSound = new SoundPlayer(melodyMenu);
            simpleSound.PlayLooping();

            view = new View(Vector2.Zero, 2.0, 0);
            view.SetPosition(new Vector2(195,145));
            //player = new Player(new Vector2(200,150));

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        }
        public static void Draw(Texture2D texture, Vector2 position, Vector2 scale, Color color, Vector2 origin, RectangleF? sourceRec = null)
        {
            Vector2[] vertices = new Vector2[4]
            {
                new Vector2(0,0),
                new Vector2(1,0),
                new Vector2(1,1),
                new Vector2(0,1),

            };

            GL.BindTexture(TextureTarget.Texture2D, texture.ID);

            GL.Begin(PrimitiveType.Quads);
            GL.Color3(color);
            for (int i = 0; i < 4; i++)
            {
                if (sourceRec == null)
                    GL.TexCoord2(vertices[i]);
                else
                {
                    GL.TexCoord2((sourceRec.Value.Left + vertices[i].X * sourceRec.Value.Width) / texture.Width,
                        (sourceRec.Value.Top + vertices[i].Y * sourceRec.Value.Height) / texture.Height);
                }

                vertices[i].X *= (sourceRec == null) ? texture.Width : sourceRec.Value.Width;
                vertices[i].Y *= (sourceRec == null) ? texture.Height : sourceRec.Value.Height;
                vertices[i] -= origin;
                vertices[i] *= scale;
                vertices[i] += position;

                GL.Vertex2(vertices[i]);
            }

            GL.End();
        }