Ejemplo n.º 1
0
        public void Draw(gfx.Shader shader)
        {
            shader.LoadFloat((float)Math.Atan2(Velocity.Y, Velocity.X), "rotation");
            shader.LoadVector2(Position, "translation");

            sprite.Draw(shader);
        }
 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();
 }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void DrawMap(gfx.Shader shader)
        {
            shader.Bind();

            vbo.Bind();

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

            GL.BlendFunc(BlendingFactorSrc.One, BlendingFactorDest.One);

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

            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            vbo.Unbind();
            shader.Unbind();
        }
Ejemplo 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);
        }
Ejemplo n.º 7
0
        public Game(int windowWidth, int windowHeight) : base(windowWidth, windowHeight)
        {
            Title = "Infernal Selection";

            RenderFrame += eRenderFrame;
            KeyDown     += Game_KeyDown;
            KeyUp       += Game_KeyUp;
            Closing     += Game_Closing;

            aspect = (float)Width / Height;

            audioPlayer = new MusicStream();

            gameState = GameState.Menu;

            GL.ClearColor(0.1f, 0.1f, 0.1f, 1.0f);
            shdFloor         = gfx.ShaderFactory.CreateFloorShader();
            shdTexture       = gfx.ShaderFactory.CreateTextureShader();
            shdBackground    = gfx.ShaderFactory.CreateBackgroundShader();
            shdFinalpass     = gfx.ShaderFactory.CreateFinalpassShader();
            shdUserInterface = gfx.ShaderFactory.CreateUserInterfaceShader();
            shdBloodyScreen  = gfx.ShaderFactory.CreateBloodyScreenShader();

            Matrix4 ortho = Matrix4.CreateOrthographic(20f * aspect, 20f, -1.0f, 1.0f);

            shdTexture.LoadMatrix4(ortho, "projection");
            shdFloor.LoadMatrix4(ortho, "projection");

            offscreen = new gfx.RenderTarget(Width, Height);

            screenQuad = gfx.VertexBufferFactory.CreateQuad(2.0f, 2.0f);

            texScratch = new gfx.Texture2D($"{ContentDirectory}scratch.png");

            arena = new Arena(15.0f);

            playButton = new UserInterfaceWidget($"{ContentDirectory}playbtn.png",
                                                 new Vector2(0.2f * 200f / 75f, 0.2f),
                                                 new Vector2(0.0f, 0.4f));

            exitButton = new UserInterfaceWidget($"{ContentDirectory}quitbtn.png",
                                                 new Vector2(0.2f * 200f / 75f, 0.2f),
                                                 new Vector2(0.0f, 0.0f));

            fplayButton = new UserInterfaceWidget($"{ContentDirectory}fplaybtn.png",
                                                  new Vector2(0.2f * 200f / 75f, 0.2f),
                                                  new Vector2(0.0f, 0.4f));

            fexitButton = new UserInterfaceWidget($"{ContentDirectory}fquitbtn.png",
                                                  new Vector2(0.2f * 200f / 75f, 0.2f),
                                                  new Vector2(0.0f, 0.0f));

            ggjIcon = new UserInterfaceWidget($"{ContentDirectory}ggj.png",
                                              new Vector2(0.3f / aspect, 0.3f),
                                              new Vector2(0.7f, -0.7f));

            chainRenderer = new ChainRenderer(aspect, audioPlayer);

            GL.Enable(EnableCap.StencilTest);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            audioPlayer.Play($"{ContentDirectory}e1m1.ogg", true);
            audioPlayer.Play($"{ContentDirectory}background_sound.ogg", true, 0.5f);
        }