Esempio n. 1
0
        private void stateMenu(float dt)
        {
            gfx.RenderTarget.Backbuffer.Clear();

            shdBackground.Bind();
            shdBackground.LoadVector2(new Vector2(Width, Height), "resolution");
            shdBackground.LoadFloat(timeAcc, "time");
            screenQuad.Bind();
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, screenQuad.VertexCount);
            screenQuad.Unbind();
            shdBackground.Unbind();

            if (keyboard[(int)Key.Enter])
            {
                switch (selectedOption)
                {
                case 0:
                    resetGame();
                    gameState = GameState.Playing;
                    break;

                default:
                    Exit();
                    break;
                }
            }

            if ((keyboard[(int)Key.W] || keyboard[(int)Key.Up]) && (selectedOption == 1))
            {
                --selectedOption;
            }
            if ((keyboard[(int)Key.S] || keyboard[(int)Key.Down]) && (selectedOption == 0))
            {
                ++selectedOption;
            }

            if (selectedOption == 0)
            {
                fplayButton.Draw(shdUserInterface);
                exitButton.Draw(shdUserInterface);
            }
            else
            {
                playButton.Draw(shdUserInterface);
                fexitButton.Draw(shdUserInterface);
            }
            ggjIcon.Draw(shdUserInterface);
        }
Esempio n. 2
0
        public void Draw(gfx.Shader shader)
        {
            shader.LoadFloat((float)Math.Atan2(Velocity.Y, Velocity.X), "rotation");
            shader.LoadVector2(Position, "translation");

            sprite.Draw(shader);
        }
Esempio n. 3
0
        public void Draw(gfx.Shader shader)
        {
            Vector2 min_uv = new Vector2(offset * CurrentFrame, 0.0f);
            Vector2 max_uv = new Vector2(offset * CurrentFrame + offset, 1.0f);

            shader.LoadVector2(max_uv, "max_uv");
            shader.LoadVector2(min_uv, "min_uv");

            shader.LoadFloat(scale, "scale");

            texture.Bind(0);

            vbo.Bind();
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, vbo.VertexCount);
            vbo.Unbind();

            texture.Unbind(0);
        }
 public void Draw(gfx.Shader shader)
 {
     shader.Bind();
     texture.Bind(0);
     quad.Bind();
     shader.LoadVector2(Position, "translation");
     GL.DrawArrays(PrimitiveType.TriangleFan, 0, quad.VertexCount);
     quad.Unbind();
     texture.Unbind(0);
     shader.Unbind();
 }
Esempio n. 5
0
        public void DrawTraps(gfx.Shader shader)
        {
            shader.Bind();

            foreach (TrapDescriptor trap in TrapList)
            {
                if (trap.active)
                {
                    shader.LoadVector2(trap.position, "translation");
                    shader.LoadFloat((float)Math.PI, "rotation");
                    trap.sprite.Draw(shader);
                }
            }

            shader.Unbind();
        }
Esempio n. 6
0
        public void Draw(gfx.Shader shader)
        {
            float o = currentOffset % (0.1f / aspect);

            GL.ColorMask(false, false, false, false);
            GL.StencilMask(0xFF);
            GL.StencilFunc(StencilFunction.Always, 1, 0xFF);
            GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace);
            stencilQuad.Bind();
            shader.LoadVector2(new Vector2(0.0f, 0.6f), "translation");
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, stencilQuad.VertexCount);
            GL.StencilFunc(StencilFunction.Equal, 1, 0xFF);
            stencilQuad.Unbind();
            GL.StencilMask(0x00);
            GL.ColorMask(true, true, true, true);

            for (float x = -0.9f; x <= 0.9f; x += (0.1f / aspect))
            {
                chain1.Position = new Vector2(x + o, 0.58f);
                chain1.Draw(shader);
            }

            ruby.Position = new Vector2(currentOffset, 0.58f);
            ruby.Draw(shader);

            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One);
            ruby.Draw(shader);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            for (float x = -0.9f; x <= 0.9f; x += (0.1f / aspect))
            {
                chain1.Position = new Vector2(x - o, 0.54f);
                chain1.Draw(shader);
            }

            GL.StencilFunc(StencilFunction.Always, 1, 0xFF);

            skull1.Draw(shader);
            skull2.Draw(shader);
        }
Esempio n. 7
0
        private void statePlaying(float dt)
        {
            float lastTug = playerHP;

            if (player.Acceleration < 170.0f)
            {
                player.Acceleration += dt * 0.5f;
                enemy.Acceleration   = player.Acceleration * 0.4f;
            }

            arena.Update(dt);
            player.Update(dt, keyboard, arena);
            enemy.Update(dt, player.Position, player.State, arena);
            chainRenderer.Update(dt, playerHP);

            if (player.IsDead)
            {
                gameState = GameState.Menu;
            }
            if (enemy.IsDead)
            {
                gameState = GameState.Menu;
            }

            bloodyScreenTime -= dt;
            if ((playerHP - lastTug) > 0.0f)
            {
                bloodyScreenColor = new Vector3(0.25f, 0.25f, 0.0f);
                bloodyScreenTime  = 0.125f;
            }
            else if (playerHP - lastTug < 0.0f)
            {
                bloodyScreenColor = new Vector3(0.25f, 0.0f, 0.0f);
                bloodyScreenTime  = 0.125f;
            }
            else if (bloodyScreenTime <= 0.0f)
            {
                bloodyScreenColor = new Vector3(0.0f, 0.0f, 0.0f);
            }

            offscreen.Clear();

            shdBackground.Bind();
            shdBackground.LoadVector2(new Vector2(Width, Height), "resolution");
            shdBackground.LoadFloat((float)Math.Pow(timeAcc, 1.2), "time");
            screenQuad.Bind();
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, screenQuad.VertexCount);
            screenQuad.Unbind();
            shdBackground.Unbind();

            shdFloor.LoadVector2(player.Position, "camera");
            arena.DrawMap(shdFloor);

            shdTexture.LoadVector2(player.Position, "camera");
            arena.DrawTraps(shdTexture);
            player.Draw(shdTexture);
            enemy.Draw(shdTexture);

            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One);
            shdBloodyScreen.Bind();
            shdBloodyScreen.LoadVector3(bloodyScreenColor, "screenColor");
            screenQuad.Bind();
            if (enemy.Clawed)
            {
                texScratch.Bind(0);
            }
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, screenQuad.VertexCount);
            if (enemy.Clawed)
            {
                texScratch.Unbind(0);
            }
            screenQuad.Unbind();
            shdBloodyScreen.Unbind();
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            chainRenderer.Draw(shdUserInterface);

            offscreen.BindToTexture(1);

            gfx.RenderTarget.Backbuffer.Clear();

            shdFinalpass.Bind();
            shdFinalpass.SetSamplerUnit(1, "sceneFramebuffer");
            shdFinalpass.LoadVector4(Vector4.One, "ambientLight");

            screenQuad.Bind();
            GL.DrawArrays(PrimitiveType.TriangleFan, 0, screenQuad.VertexCount);
            screenQuad.Unbind();

            shdFinalpass.Unbind();
        }