Exemple #1
0
        /// <summary>
        /// Render
        /// </summary>
        public override void Render()
        {
            var demo = (DemoReel)RB.Game;

            RB.Clear(DemoUtil.IndexToRGB(1));

            mFormatStr.Set("@C// Test gamepad input for two players\n");
            mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_A, @[email protected]_ONE) {\n");
            mFormatStr.Append("   @C// Handle button A down for player one\n@N");
            mFormatStr.Append("}\n");
            mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_LEFT, @[email protected]_TWO) {\n");
            mFormatStr.Append("   @C// Handle button LEFT transitioning from \"up\" to \"down\"\n@N");
            mFormatStr.Append("}\n");
            mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_MENU, @[email protected]_ANY) {\n");
            mFormatStr.Append("   @C// Handle button MENU transitioning from \"down\" to \"up\"\n@N");
            mFormatStr.Append("}");

            RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            DrawGamepad(260, 15, RB.PLAYER_ONE);
            DrawGamepad(400, 15, RB.PLAYER_TWO);
            DrawMouse(540, 8);

            RB.DrawLine(new Vector2i(16, 85), new Vector2i(RB.DisplaySize.width - 16, 85), DemoUtil.IndexToRGB(2));

            mFormatStr.Set("@C// Test keyboard input\n");
            mFormatStr.Append("@Kif @N(@[email protected](@[email protected])) {\n");
            mFormatStr.Append("   @C// Handle Left Shift down\n@N");
            mFormatStr.Append("}\n\n");
            mFormatStr.Append("@C// Retrieve the string of characters typed since last update\n");
            mFormatStr.Append("@Kstring@n userInput += @[email protected]();");

            RB.Print(new Vector2i(50, 92), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            mFormatStr.Set("@C// Get pointer position (mouse or touch)\n");
            mFormatStr.Append("@[email protected](@L4@N, @[email protected]());\n\n");
            mFormatStr.Append("@C// Test pointer button input\n");
            mFormatStr.Append("@Kif @N(@[email protected](@[email protected]_POINTER_A)) {\n");
            mFormatStr.Append("   @C// Handle Pointer Button A down\n@N");
            mFormatStr.Append("}\n");

            RB.Print(new Vector2i(350, 92), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            DrawKeyboard(mKeyboardOffset.x, mKeyboardOffset.y);
            DrawInputString(14, 155);

            mNextButton.Render();
            mPrevButton.Render();

            if (RB.PointerPosValid())
            {
                RB.DrawSprite(4, RB.PointerPos());
            }

            if (!UnityEngine.Input.mousePresent)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (RB.PointerPosValid(i))
                    {
                        RB.DrawEllipse(RB.PointerPos(i), new Vector2i(64, 64), mTouchColor[i]);
                    }
                }
            }
        }
Exemple #2
0
        private void DrawGamepadDPad(int x, int y, int pressedMask, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int pressedColor = 5;
            int size         = 10;

            RB.DrawRect(new Rect2i(x + size, y, size, size * 3), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x, y + size, size * 3, size), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, (size * 3) - 2), DemoUtil.IndexToRGB(color));
            RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, (size * 3) - 2, size - 2), DemoUtil.IndexToRGB(color));

            // Up
            mFormatStr.Set((char)127);
            RB.DrawRectFill(new Rect2i(x + size + 1, y + 1, size - 2, size), (pressedMask & RB.BTN_UP) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Down
            mFormatStr.Set((char)128);
            RB.DrawRectFill(new Rect2i(x + size + 1, y + (size * 2) - 1, size - 2, size), (pressedMask & RB.BTN_DOWN) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + size + (size / 2) - 3, y + 2 + (size * 2)), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Left
            mFormatStr.Set((char)129);
            RB.DrawRectFill(new Rect2i(x + 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_LEFT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + 2, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);

            // Right
            mFormatStr.Set((char)130);
            RB.DrawRectFill(new Rect2i(x + (size * 2) - 1, y + size + 1, size, size - 2), (pressedMask & RB.BTN_RIGHT) != 0 ? DemoUtil.IndexToRGB(pressedColor) : DemoUtil.IndexToRGB(color));
            RB.Print(new Vector2i(x + (size * 2) + 3, y + size + 2), DemoUtil.IndexToRGB(colorOutline), mFormatStr);
        }
Exemple #3
0
        private void FireLoop()
        {
            int width  = mFireSize.width;
            int height = mFireSize.height;
            int i      = 0;
            int ri     = Random.Range(0, mRandomBuf.Length);

            for (i = width + 1; i < (width * (height - 1)) - 1; i++)
            {
                // Average out neighbours
                int sum =
                    mPrevFire[i - width] +
                    mPrevFire[i - 1] +
                    mPrevFire[i + 1] +
                    mPrevFire[i + width] +
                    mPrevFire[i - width - 1] +
                    mPrevFire[i - width + 1] +
                    mPrevFire[i + width - 1] +
                    mPrevFire[i + width + 1];

                int avg = sum / 8;

                // Cool down pixels if lower 2 bits are not set
                if ((sum & 3) == 0 &&
                    (avg > 0 || i >= (height - 18) * width))
                {
                    avg += mRandomBuf[ri];
                    ri++;
                    if (ri >= mRandomBuf.Length)
                    {
                        ri = 0;
                    }
                }

                mFire[i] = (byte)avg;
            }

            // Scroll up
            for (i = 0; i < width * (height - 2); i++)
            {
                mPrevFire[i] = mFire[i + width];
            }

            // Remove dark pixels from bottom row
            for (i = (height - 2) * width; i < width * height; i++)
            {
                if (mFire[i] < 12)
                {
                    mFire[i] = (byte)(20 - mFire[i]);
                }
            }

            // Update pixel buffer
            i = 0;
            var frameColor = DemoUtil.IndexToRGB(2);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    if (x < 2 || y < 2 || x >= width - 2 || y >= height - 2)
                    {
                        mPixelBuffer[i] = frameColor;
                    }
                    else
                    {
                        mPixelBuffer[i] = mFirePalette[mFire[i]];
                    }

                    i++;
                }
            }
        }
Exemple #4
0
        private void DrawTMX(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            if (mMap != null)
            {
                RB.Offscreen(2);

                RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), DemoUtil.IndexToRGB(22));

                RB.DrawMapLayer(0);
                RB.DrawMapLayer(1);

                RB.Offscreen(3);
                RB.Clear(new Color32(0, 0, 0, 0));
                RB.SpriteSheetSet(1);
                RB.DrawSprite(0, new Vector2i((int)mBouncePos.x, (int)mBouncePos.y), mVelocity.x > 0 ? RB.FLIP_H : 0);

                RB.Onscreen();

                RB.ShaderSet(0);
                RB.ShaderSpriteSheetTextureSet(0, "Mask", 3);
                RB.ShaderFloatSet(0, "Wave", RB.Ticks / 10.0f);
                RB.ShaderSpriteSheetFilterSet(0, 3, RB.Filter.Linear);

                RB.SpriteSheetSet(2);
                RB.DrawCopy(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), Vector2i.zero);

                RB.ShaderReset();

                RB.SpriteSheetSet(0);
            }
            else
            {
                RB.Print(new Vector2i(x, y + 250), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            string shaderName = "WavyMaskShader";

            mFormatStr.Set("@C// Custom shaders can be used for many things, like masking!\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"Demos/DemoReel/").Append(shaderName).Append("\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@C// Draw a tilemap to one offscreen surface\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L0@N, @L0@N,\n");
            mFormatStr.Append("   @[email protected], @[email protected]),\n");
            mFormatStr.Append("   @I22@N);\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@C// Draw a mask to the other offscreen surface\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("@[email protected](@Knew @MColor32@N(@L0@N, @L0@N, @L0@N, @L0@N));\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew @MVector2i@N(@L").Append((int)mBouncePos.x).Append("@N, @L").Append((int)mBouncePos.y).Append("@N)").Append(mVelocity.x > 0 ? ", RB.FLIP_H" : string.Empty).Append(");\n");

            mFormatStr.Append("\n");
            mFormatStr.Append("@C// Use a custom shader to combine the two!\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"Mask\"@N, @L1@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"Wave\"@N, @L").Append(RB.Ticks / 10.0f, 2).Append("f@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @L3@N, @MRB@N.@[email protected]);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L0@N, @L0@N,\n   @[email protected], @[email protected]),\n   @[email protected]);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected]();\n");
            DemoUtil.HighlightCode(mFormatStr, mCodeStr);

            mFormatStr.Set("@C// This shader multiplies in a mask and applies a wavy effect!\n");
            mFormatStr.Append("@KShader@N \"Unlit/").Append(shaderName).Append("\" {\n");
            mFormatStr.Append("  @KSubShader@N {\n");
            mFormatStr.Append("    @C...\n");
            mFormatStr.Append("    @KPass@N {\n");
            mFormatStr.Append("      @C...\n");
            mFormatStr.Append("      @C/*** Insert custom shader variables here ***/\n");
            mFormatStr.Append("      @Ksampler2D@N Mask;\n");
            mFormatStr.Append("      @Kfloat@N Wave;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("      @Nfrag_in vert(vert_in v, @Kout float4@N screen_pos : @MSV_POSITION@N) {\n");
            mFormatStr.Append("        @C...@N\n");
            mFormatStr.Append("      }\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("      @Kfloat4@N frag(frag_in i, @MUNITY_VPOS_TYPE@N screen_pos : @MVPOS@N) : @MSV_Target@N {\n");
            mFormatStr.Append("        @C...\n");
            mFormatStr.Append("        @C/*** Insert custom fragment shader code here ***/@N\n");
            mFormatStr.Append("        @C// Sample the mask texture@N\n");
            mFormatStr.Append("        i.uv.x += sin(Wave + i.uv.y * @L8@N) * @L0.025@N;\n");
            mFormatStr.Append("        i.uv.y += cos(Wave - i.uv.x * @L8@N) * @L0.015@N;\n");
            mFormatStr.Append("        @Kfloat4@N mask_color = @Mtex2D@N(Mask, i.uv).rgba;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("        @C// Multiply the sprite pixel by mask color@N\n");
            mFormatStr.Append("        @Kreturn@N sprite_pixel_color * mask_color;\n");
            mFormatStr.Append("      }\n");
            mFormatStr.Append("    }\n");
            mFormatStr.Append("  }\n");
            mFormatStr.Append("}\n");
            DemoUtil.HighlightCode(mFormatStr, mShaderStr);

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), mCodeStr);
            RB.Print(new Vector2i(x + 300, y), DemoUtil.IndexToRGB(5), mShaderStr);
        }
Exemple #5
0
 private void DrawBadSpritepack(int x, int y)
 {
     RB.Print(new Vector2i(x + 4, y + 4), DemoUtil.IndexToRGB(14), "Failed to load sprite pack!\nPlease try re-importing the sprite pack Demos/DemoReel/DemoSpritePack.sp in Unity");
 }
Exemple #6
0
        private void DrawTMX(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.SpriteSheetSet(0);

            mFormatStr.Set("@C// Load sprite packs at runtime just like any other spritesheet!\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"DemoReel/DemoSpritePack\"@N, @Knew@N @MVector2i@N(@L16@N, @L16@N));\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@C// Now you can draw sprites using their sprite path and name, there is\n");
            mFormatStr.Append("@C// no need to specify source rectangle, RetroBlit sprite packing\n");
            mFormatStr.Append("@C// creates an internal lookup table that takes care of that for you!\n");

            var outputFrameRect = new Rect2i(x + 130, y + 60, 20, 20);

            DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22);

            if (RB.Ticks % 40 < 20)
            {
                mFormatStr.Append("@[email protected](@S\"Characters/Hero1\"@N, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n");
                RB.DrawSprite("Characters/Hero1", new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2));
            }
            else
            {
                mFormatStr.Append("@[email protected](@S\"Characters/Hero2\"@N, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n");
                RB.DrawSprite("Characters/Hero2", new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2));
            }

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            y += 90;

            mFormatStr.Set("@C// You can also use sprite packs with tile maps\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L0@N, @L0@N), @S\"Terrain/GrassTopRight\"@N, @[email protected]_H);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L1@N, @L0@N), @S\"Terrain/GrassTop\"@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L2@N, @L0@N), @S\"Terrain/GrassTop\"@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L3@N, @L0@N), @S\"Terrain/GrassTopRight\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L0@N, @L1@N), @S\"Terrain/DirtSide\"@N, @[email protected]_H);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L1@N, @L1@N), @S\"Terrain/DirtCenter\"@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L2@N, @L1@N), @S\"Terrain/DirtCenter\"@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @Knew@N @MVector2i@N(@L3@N, @L1@N), @S\"Terrain/DirtSide\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](0);");
            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            RB.MapSpriteSet(0, new Vector2i(0, 0), mSpriteGrassTopRight, RB.FLIP_H);
            RB.MapSpriteSet(0, new Vector2i(1, 0), mSpriteGrassTop);
            RB.MapSpriteSet(0, new Vector2i(2, 0), mSpriteGrassTop);
            RB.MapSpriteSet(0, new Vector2i(3, 0), mSpriteGrassTopRight);

            RB.MapSpriteSet(0, new Vector2i(0, 1), mSpriteDirtSide, RB.FLIP_H);
            RB.MapSpriteSet(0, new Vector2i(1, 1), mSpriteDirtCenter);
            RB.MapSpriteSet(0, new Vector2i(2, 1), mSpriteDirtCenter);
            RB.MapSpriteSet(0, new Vector2i(3, 1), mSpriteDirtSide);

            outputFrameRect = new Rect2i(x + 105, y + 95, (16 * 4) + 4, (16 * 2) + 4);
            DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22);

            RB.DrawMapLayer(0, new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 4));

            y += 140;

            mFormatStr.Set("@C// Sometimes it can be useful to get the sprite source rectangle\n");
            mFormatStr.Append("@Kvar@N sprite = @[email protected](@S\"Terrain/Water\"@N);\n");
            mFormatStr.Append("@Kvar@N sourceRect = sprite.SourceRect;\n");
            mFormatStr.Append("sourceRect.x += @L").Append((int)((RB.Ticks / 2) % 16)).Append("@N;\n");
            mFormatStr.Append("@[email protected](sourceRect, @Knew@N @MVector2i@N(@L32@N, @L48@N));\n");
            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            outputFrameRect = new Rect2i(x + 130, y + 44, 16 + 4, 16 + 4);
            DemoUtil.DrawOutputFrame(outputFrameRect, -1, 21, 22);

            var sprite     = RB.PackedSpriteGet("Terrain/Water");
            var sourceRect = sprite.SourceRect;

            sourceRect.x    += (int)((RB.Ticks / 2) % 16);
            sourceRect.width = 16;
            RB.DrawCopy(sourceRect, new Vector2i(outputFrameRect.x + 2, outputFrameRect.y + 2));

            y += 72;

            mFormatStr.Set("@C// You can also use sprite packs for custom fonts, nine-slice images,\n");
            mFormatStr.Append("@C// and when loading map layers from TMX files!\n");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            y += 20;
            mFormatStr.Set("@w444");

            int count = mCounter;
            int ms    = count % 60;

            count /= 60;
            int s = count % 60;

            count /= 60;
            int m = count;

            mFormatStr.Append(m, 2).Append(':').Append(s, 2).Append(':').Append(ms, 2);

            mCounter++;
            if (mCounter >= 60 * 60 * 60)
            {
                mCounter = 0;
            }

            RB.Print(0, new Vector2i(x + 15, y + 8), Color.white, mFormatStr);

            int xGrow = (int)(Mathf.Sin(RB.Ticks / 40.0f) * 20.0f) + 20 + 20;
            int yGrow = (int)(Mathf.Sin(RB.Ticks / 20.0f) * 18.0f) + 18 + 16;

            RB.DrawNineSlice(new Rect2i(x + 130 - (xGrow / 2), y + 18 - (yGrow / 2), xGrow, yGrow), mNineSlice);

            RB.DrawMapLayer(1, new Vector2i(x + 190, y - 1));
        }
Exemple #7
0
        private void DrawMusicPlayer(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.Offscreen(mSpriteSheet2);
            RB.Clear(new Color32(0, 0, 0, 0));

            int spinnerSize = 32;

            RB.DrawRectFill(new Rect2i(spinnerSize / 4, spinnerSize - 2, (spinnerSize / 2) - 2, 5), DemoUtil.IndexToRGB(1));
            RB.DrawRectFill(new Rect2i(spinnerSize + (spinnerSize / 4) + 3, spinnerSize - 2, (spinnerSize / 2) - 2, 5), DemoUtil.IndexToRGB(1));
            RB.DrawRectFill(new Rect2i(spinnerSize - 2, spinnerSize / 4, 5, (spinnerSize / 2) - 2), DemoUtil.IndexToRGB(1));
            RB.DrawRectFill(new Rect2i(spinnerSize - 2, spinnerSize + (spinnerSize / 4) + 3, 5, (spinnerSize / 2) - 2), DemoUtil.IndexToRGB(1));

            RB.Onscreen();

            RB.CameraSet(new Vector2i(-x, -y));

            mFormatStr.Set("@C// Load music and play it\n");
            mFormatStr.Append("@NdemoMusic.Load(@S\"Demos/Demo/Music\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kif@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected](demoMusic);\n");
            mFormatStr.Append("} @Kelse if@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected]();\n");
            mFormatStr.Append("}");

            RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            RB.CameraSet(new Vector2i(-x, -y - 80));

            int cornerSize = 8;
            var deckRect   = new Rect2i(20, 40, 145, 100);

            RB.DrawEllipseFill(new Vector2i(deckRect.x + cornerSize, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(deckRect.x + cornerSize, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(deckRect.x + cornerSize, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(deckRect.x + cornerSize, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawRect(new Rect2i(deckRect.x + cornerSize, deckRect.y, deckRect.width - (cornerSize * 2), deckRect.height), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(deckRect.x + cornerSize, deckRect.y + 1, deckRect.width - (cornerSize * 2), deckRect.height - 2), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(deckRect.x, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(deckRect.x + 1, deckRect.y + cornerSize, cornerSize - 1, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(deckRect.x + deckRect.width - cornerSize, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            DrawSpinner(0, 0, spinnerSize);
            DrawSpinner(120, 0, spinnerSize);

            mMusicPlayButton.Render();

            RB.CameraReset();
        }
        /// <summary>
        /// Render
        /// </summary>
        public void Render()
        {
            var demo = (DemoReel)RB.Game;

            Vector2i labelSize = RB.PrintMeasure(mLabel);

            int yPos;

            if (mLabelBottomAligned)
            {
                yPos = mRect.y + mRect.height - labelSize.y - 4;
            }
            else
            {
                yPos = mRect.y + (mRect.height / 2) - (labelSize.y / 2);
            }

            if (mPressed)
            {
                RB.DrawRectFill(new Rect2i(mRect.x + 2, mRect.y + 2, mRect.width - 2, mRect.height - 2), DemoUtil.IndexToRGB(5));
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2) + 1, yPos + 1), DemoUtil.IndexToRGB(mLabelColor), mLabel);
            }
            else
            {
                RB.DrawRectFill(mRect, DemoUtil.IndexToRGB(mFaceColor));
                RB.Print(new Vector2i(mRect.x + (mRect.width / 2) - (labelSize.x / 2), yPos), DemoUtil.IndexToRGB(mLabelColor), mLabel);
                RB.DrawRect(mRect, DemoUtil.IndexToRGB(5));
            }

            mHitRect = new Rect2i(-RB.CameraGet().x + mHotZone.x, -RB.CameraGet().y + mHotZone.y, mHotZone.width, mHotZone.height);
        }
Exemple #9
0
        private void DrawPiano(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y));

            mFormatStr.Set("@C// Play sound at specific volume and pitch\n");
            mFormatStr.Append("@NsoundC5Note.Load(@S\"Demos/Demo/C5Note\"@N);\n");
            mFormatStr.Append("@[email protected](soundC5Note, @L0.@L5f@N, @L1.@L2f@N);\n");

            RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            RB.CameraSet(new Vector2i(-x, -y - 35));

            Rect2i pianoRect = mPianoRect;
            Rect2i holeRect  = pianoRect;

            pianoRect = pianoRect.Expand(8);
            holeRect  = holeRect.Expand(2);

            int cornerSize = 8;

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + cornerSize, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + pianoRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawRect(new Rect2i(pianoRect.x + cornerSize, pianoRect.y, pianoRect.width - (cornerSize * 2), pianoRect.height), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + cornerSize, pianoRect.y + 1, pianoRect.width - (cornerSize * 2), pianoRect.height - 2), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(pianoRect.x, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + 1, pianoRect.y + cornerSize, cornerSize - 1, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(pianoRect.x + pianoRect.width - cornerSize, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(pianoRect.x + pianoRect.width - cornerSize - 1, pianoRect.y + cornerSize, cornerSize, pianoRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(2));

            for (int i = 0; i < mPianoButtons.Length; i++)
            {
                mPianoButtons[i].Render();
            }

            RB.CameraReset();
        }
Exemple #10
0
        private void DrawSpinner(int x, int y, int spinnerSize)
        {
            var demo = (DemoReel)RB.Game;

            RB.DrawEllipseFill(new Vector2i(x + spinnerSize, y + spinnerSize), new Vector2i(spinnerSize, spinnerSize), DemoUtil.IndexToRGB(1));
            RB.DrawEllipseFill(new Vector2i(x + spinnerSize, y + spinnerSize), new Vector2i(spinnerSize - 6, spinnerSize - 6), DemoUtil.IndexToRGB(4));
            RB.DrawEllipseFill(new Vector2i(x + spinnerSize, y + spinnerSize), new Vector2i(8, 8), DemoUtil.IndexToRGB(1));
            RB.DrawEllipse(new Vector2i(x + spinnerSize, y + spinnerSize), new Vector2i(spinnerSize, spinnerSize), DemoUtil.IndexToRGB(4));

            RB.SpriteSheetSet(mSpriteSheet2);
            RB.DrawCopy(new Rect2i(0, 0, (spinnerSize * 2) + 1, (spinnerSize * 2) + 1), new Rect2i(x, y, (spinnerSize * 2) + 1, (spinnerSize * 2) + 1), new Vector2i(spinnerSize, spinnerSize), mMusicTicks / 50);
            RB.SpriteSheetSet(mSpriteSheet1);
        }
Exemple #11
0
        private void DrawTMX(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            Rect2i clipRect = new Rect2i(x, y, 340, 352);

            if (mMap != null)
            {
                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSize().width);

                RB.CameraSet(new Vector2i(256, 144));
                RB.DrawMapLayer(1, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSize().width), 0));
                RB.DrawMapLayer(2);
                RB.DrawMapLayer(3);

                var objs = mMap.objectGroups["Objects"].objects;
                for (int i = 0; i < objs.Count; i++)
                {
                    var obj = objs[i];

                    switch (obj.shape)
                    {
                    case TMXObject.Shape.Rectangle:
                        RB.DrawRect(obj.rect, Color.red);
                        RB.Print(obj.rect, Color.red, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, obj.properties.GetString("name"));
                        break;

                    case TMXObject.Shape.Polyline:
                        for (int j = 0; j < obj.points.Count - 1; j++)
                        {
                            RB.DrawLine(
                                obj.points[j] + new Vector2i(obj.rect.x, obj.rect.y),
                                obj.points[j + 1] + new Vector2i(obj.rect.x, obj.rect.y),
                                Color.green);
                        }

                        break;

                    case TMXObject.Shape.Ellipse:
                        RB.DrawEllipse(obj.rect.center, new Vector2i(obj.rect.width / 2, obj.rect.height / 2), Color.yellow);
                        RB.Print(obj.rect, Color.yellow, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, obj.properties.GetString("name"));
                        break;
                    }
                }
            }
            else
            {
                RB.CameraReset();
                RB.ClipReset();
                RB.Print(new Vector2i(x + 4, y + 4), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/TilemapProps.tmx in Unity");
            }

            RB.CameraReset();
            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));

            RB.ClipReset();

            x += 350;

            mFormatStr.Set("@C// Read shapes and their custom properties from TMX file\n");
            mFormatStr.Append("@NmyMap = @[email protected](@S\"Demos/DemoReel/TilemapProps\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kvar@N objs = myMap.objectGroups[@S\"Objects\"@N].objects;\n");
            mFormatStr.Append("@Kfor@N (@Kint@N i = @L0@N; i < objs.Count; i++)\n");
            mFormatStr.Append("{\n");
            mFormatStr.Append("    @Kvar@N obj = obj;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("    @Kswitch@N (obj.shape)\n");
            mFormatStr.Append("    {\n");
            mFormatStr.Append("        @Kcase@N @[email protected]:\n");
            mFormatStr.Append("            @[email protected](obj.rect, @[email protected]);\n");
            mFormatStr.Append("            @[email protected](obj.rect, @[email protected],\n");
            mFormatStr.Append("               @[email protected]_H_CENTER | @[email protected]_V_CENTER,\n");
            mFormatStr.Append("               obj.properties.GetString(\"name\"));\n");
            mFormatStr.Append("            @Kbreak@N;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("        @Kcase@N @[email protected]:\n");
            mFormatStr.Append("            @Kfor@N (@Kint@N j = @L0@N; j < obj.points.Count - @L1@N; j++)\n");
            mFormatStr.Append("            {\n");
            mFormatStr.Append("                @[email protected](\n");
            mFormatStr.Append("                   obj.points[j] + @Knew@N @MVector2i@N(obj.rect.x, obj.rect.y),\n");
            mFormatStr.Append("                   obj.points[j + @L1@N] + @Knew@N @MVector2i@N(obj.rect.x, obj.rect.y),\n");
            mFormatStr.Append("                   @[email protected]);\n");
            mFormatStr.Append("            }\n");
            mFormatStr.Append("            @Kbreak@N;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("        @Kcase@N @[email protected]:\n");
            mFormatStr.Append("            @[email protected](obj.rect.center,\n");
            mFormatStr.Append("               new @MVector2i@N(obj.rect.width / @L2@N, obj.rect.height / @L2@N),\n");
            mFormatStr.Append("               @[email protected]);\n");
            mFormatStr.Append("            @[email protected](obj.rect, @[email protected],\n");
            mFormatStr.Append("               @[email protected]_H_CENTER | RB.ALIGN_V_CENTER,\n");
            mFormatStr.Append("               obj.properties.GetString(@S\"name\"@N));\n");
            mFormatStr.Append("            @Kbreak@N;\n");
            mFormatStr.Append("    }\n");
            mFormatStr.Append("}\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@C// Also easily read tile custom properties\n");
            mFormatStr.Append("@Kvar@N props = @[email protected]<@MTMXProperties@N>(@L0@N, @Knew@N @MVector2i@N(@L2@N, @L5@N));\n");
            mFormatStr.Append("@Kint@N blocking = tileProps.GetInt(@S\"blocking\"@N);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
Exemple #12
0
        private void DrawShapes(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 66));

            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 263, 27), -1, mOutputFrame, mOutputBackground);

            for (int i = 0; i < mShapeSize.Length; i++)
            {
                mShapeSize[i].x = (int)((Mathf.Sin((RB.Ticks / 20.0f) + i) * 6) + 8);
                mShapeSize[i].y = (int)((Mathf.Sin((RB.Ticks / 2 / 20.0f) + i) * 6) + 8);
            }

            RB.DrawRect(new Rect2i(-mShapeSize[0].x + 13, -mShapeSize[0].y + 13, mShapeSize[0].x * 2, mShapeSize[0].y * 2), DemoUtil.IndexToRGB(6));
            RB.DrawRectFill(new Rect2i(40 - mShapeSize[1].x + 13, -mShapeSize[1].y + 13, mShapeSize[1].x * 2, mShapeSize[1].y * 2), DemoUtil.IndexToRGB(27));
            RB.DrawEllipse(new Vector2i(80 + 13, 13), new Vector2i(mShapeSize[2].x, mShapeSize[2].y), DemoUtil.IndexToRGB(8));
            RB.DrawEllipseFill(new Vector2i(120 + 13, 13), new Vector2i(mShapeSize[3].x, mShapeSize[3].y), DemoUtil.IndexToRGB(23));
            RB.DrawEllipseInvertedFill(new Vector2i(160 + 13, 13), new Vector2i(mShapeSize[4].x, mShapeSize[4].y), DemoUtil.IndexToRGB(2));
            Rect2i triRect = new Rect2i(-mShapeSize[5].x + 210, -mShapeSize[5].y + 13, mShapeSize[5].x * 2, mShapeSize[5].y * 2);

            RB.DrawTriangle(new Vector2i(triRect.x + (triRect.width / 2), triRect.y), new Vector2i(triRect.x, triRect.y + triRect.height), new Vector2i(triRect.x + triRect.width, triRect.y + triRect.height), DemoUtil.IndexToRGB(15));
            triRect = new Rect2i(-mShapeSize[6].x + 250, -mShapeSize[6].y + 13, mShapeSize[6].x * 2, mShapeSize[6].y * 2);
            RB.DrawTriangleFill(new Vector2i(triRect.x, triRect.y), new Vector2i(triRect.x + triRect.width, triRect.y), new Vector2i(triRect.x + (triRect.width / 2), triRect.y + triRect.height), DemoUtil.IndexToRGB(9));

            RB.CameraReset();

            mFormatStr.Set("@C// Draw primitive shapes\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L").Append(-mShapeSize[0].x + 13).Append("@N, @L").Append(-mShapeSize[0].y + 13).Append("@N, @L").Append(mShapeSize[0].x * 2).Append("@N, @L").Append(mShapeSize[0].y * 2).Append("@N), @I6);\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(40 - mShapeSize[1].x + 13).Append("@N, @L").Append(-mShapeSize[1].y + 13).Append("@N, @L").Append(mShapeSize[1].x * 2).Append("@N, @L").Append(mShapeSize[1].y * 2).Append("@N), @I27);\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i(@L").Append(80 + 13).Append("@N, @L13@N), @Knew @MVector2i@N(@L").Append(mShapeSize[2].x).Append("@N, @L").Append(mShapeSize[2].y).Append("@N), @I8);\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L").Append(120 + 13).Append("@N, @L13@N), @Knew @MVector2i@N(@L").Append(mShapeSize[3].x).Append("@N, @L").Append(mShapeSize[3].y).Append("@N),\n   @I31);\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L").Append(160 + 13).Append("@N, @L13@N),\n    @Knew @MVector2i@N(@L").Append(mShapeSize[4].x).Append("@N, @L").Append(mShapeSize[4].y).Append("@N), @I2);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
Exemple #13
0
        private void DrawPixels(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 41));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 256, 12), -1, mOutputFrame, mOutputBackground);

            for (int i = 0; i < 32; i++)
            {
                RB.DrawPixel(new Vector2i((int)(Mathf.Sin((RB.Ticks / 100.0f) + (i / 10.0f)) * 128) + 128, (int)(Mathf.Sin((RB.Ticks / 10.0f) + (i / 2.0f)) * 6) + 6), DemoUtil.IndexToRGB(i));
            }

            RB.CameraReset();

            mFormatStr.Set("@C// Draw individual pixels\n");
            mFormatStr.Append("@Kfor @N(@Kint @Ni = @L0@N; i < @L32@N; i++) {\n");
            mFormatStr.Append("    @[email protected](@Knew @MVector2i@N(@[email protected](@L").Append(RB.Ticks / 100.0f, 2).Append("f@N + i / @L10.0f@N) * @L128@N + @L128@N,\n");
            mFormatStr.Append("         @[email protected](@L").Append(RB.Ticks / 10.0f, 2).Append("f@N + i / @L2.0f@N) * @L6@N + @L6@N), MyRGBColor(i));\n}");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
Exemple #14
0
        private void DrawMouse(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y));

            int color1       = 4;
            int color2       = 3;
            int colorOutline = 0;

            RB.DrawEllipseFill(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipseFill(new Vector2i(26, 54), new Vector2i(26, 20), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(26, 54), new Vector2i(26, 20), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(0, 15, 53, 54 - 15), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(color1));

            RB.DrawLine(new Vector2i(52 / 3, 2), new Vector2i(52 / 3, 30), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(52 / 3 * 2, 2), new Vector2i(52 / 3 * 2, 30), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(0, 30), new Vector2i(52, 30), DemoUtil.IndexToRGB(colorOutline));

            if (RB.ButtonDown(RB.BTN_POINTER_A))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 1, -RB.CameraGet().y, (52 / 3) - 1, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_B))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 35, -RB.CameraGet().y, 52 / 3, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_C))
            {
                RB.ClipSet(new Rect2i(-RB.CameraGet().x + 18, -RB.CameraGet().y, (52 / 3) - 1, 30));
                RB.DrawEllipseFill(new Vector2i(26, 16), new Vector2i(26, 15), DemoUtil.IndexToRGB(5));
                RB.DrawEllipse(new Vector2i(26, 15), new Vector2i(26, 15), DemoUtil.IndexToRGB(colorOutline));
                RB.DrawRectFill(new Rect2i(1, 15, 53 - 2, 54 - 15), DemoUtil.IndexToRGB(5));
                RB.ClipReset();
            }

            if (RB.ButtonDown(RB.BTN_POINTER_A))
            {
                RB.Print(new Vector2i(9, 16), DemoUtil.IndexToRGB(colorOutline), "A");
            }
            else
            {
                RB.Print(new Vector2i(8, 15), DemoUtil.IndexToRGB(colorOutline), "A");
            }

            if (RB.ButtonDown(RB.BTN_POINTER_C))
            {
                RB.Print(new Vector2i(25, 16), DemoUtil.IndexToRGB(colorOutline), "C");
            }
            else
            {
                RB.Print(new Vector2i(24, 15), DemoUtil.IndexToRGB(colorOutline), "C");
            }

            if (RB.ButtonDown(RB.BTN_POINTER_B))
            {
                RB.Print(new Vector2i(41, 16), DemoUtil.IndexToRGB(colorOutline), "B");
            }
            else
            {
                RB.Print(new Vector2i(40, 15), DemoUtil.IndexToRGB(colorOutline), "B");
            }

            RB.DrawRectFill(new Rect2i(23, 36, 8, 24), DemoUtil.IndexToRGB(color2));
            int barSize = (int)(6 * mScrollDeltaAnim / 2.0f);

            barSize = Mathf.Clamp(barSize, -12, 12);

            if (barSize > 0)
            {
                RB.DrawRectFill(new Rect2i(23, 48 - barSize, 8, barSize), DemoUtil.IndexToRGB(5));
            }
            else if (barSize < 0)
            {
                RB.DrawRectFill(new Rect2i(23, 48, 8, -barSize), DemoUtil.IndexToRGB(5));
            }

            RB.DrawRect(new Rect2i(23, 36, 8, 24), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawLine(new Vector2i(24, 48), new Vector2i(29, 48), DemoUtil.IndexToRGB(colorOutline));

            RB.CameraReset();
        }
Exemple #15
0
        private void DrawPositional(int x, int y)
        {
            RB.CameraSet(new Vector2i(-x, -y));

            mFormatStr.Set("@C// RetroBlit supports positional sounds. Simply\n");
            mFormatStr.Append("@C// set the position of your sound, and the\n");
            mFormatStr.Append("@C// position of the listener!\n");
            mFormatStr.Append("@N\n");
            mFormatStr.Append("@Kvoid@N Init() {\n");
            mFormatStr.Append("   sndRef = @[email protected](waterfallSnd);\n");
            mFormatStr.Append("   @[email protected](sndRef, @Ltrue@N);\n");
            mFormatStr.Append("}\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kvoid@N Update() {\n");
            mFormatStr.Append("   @[email protected](sndRef, @Knew@N @MVector2i@N(@L" + mSoundPos.x + "@N, @L" + mSoundPos.y + "@N));\n");
            mFormatStr.Append("   @[email protected](@Knew@N @MVector2i@N(@L" + mListenerPos.x + "@N, @L" + mListenerPos.y + "@N));\n");
            mFormatStr.Append("}\n");

            RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            mPositionalButton.Render();

            for (int i = 0; i < (int)(10 * RB.SoundVolumeGet(mPosSoundRef)); i++)
            {
                int radius = 3;
                RB.DrawEllipse(new Vector2i((i * 23) + 4, mListenerPos.y - 3), new Vector2i(radius, radius), DemoUtil.IndexToRGB(2));
            }

            // Use absolute coordinates for drawing ear/rain drop
            RB.CameraReset();

            var volAlpha = (byte)(RB.SoundVolumeGet(mPosSoundRef) * 255);

            RB.AlphaSet(volAlpha);
            RB.DrawLine(mListenerPos, mSoundPos, DemoUtil.IndexToRGB(17));
            RB.DrawCopy(new Rect2i(0, 224, 14, 24), mListenerPos - new Vector2i(14 / 2, 24 / 2));
            RB.DrawCopy(new Rect2i(14, 224, 14, 24), mSoundPos - new Vector2i(14 / 2, 24 / 2));
            RB.AlphaSet(255);
        }
Exemple #16
0
        private void DrawKeyboard(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y));

            Rect2i keyboardRect = RectBetweenKeys("Esc", "KeypadEnter");

            keyboardRect = keyboardRect.Expand(8);

            int cornerSize = 8;

            RB.DrawEllipseFill(new Vector2i(keyboardRect.x + cornerSize, keyboardRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(keyboardRect.x + cornerSize, keyboardRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(keyboardRect.x + keyboardRect.width - cornerSize - 1, keyboardRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(keyboardRect.x + keyboardRect.width - cornerSize - 1, keyboardRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(keyboardRect.x + cornerSize, keyboardRect.y + keyboardRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(keyboardRect.x + cornerSize, keyboardRect.y + keyboardRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawEllipseFill(new Vector2i(keyboardRect.x + keyboardRect.width - cornerSize - 1, keyboardRect.y + keyboardRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3));
            RB.DrawEllipse(new Vector2i(keyboardRect.x + keyboardRect.width - cornerSize - 1, keyboardRect.y + keyboardRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2));

            RB.DrawRect(new Rect2i(keyboardRect.x + cornerSize, keyboardRect.y, keyboardRect.width - (cornerSize * 2), keyboardRect.height), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(keyboardRect.x + cornerSize, keyboardRect.y + 1, keyboardRect.width - (cornerSize * 2), keyboardRect.height - 2), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(keyboardRect.x, keyboardRect.y + cornerSize, cornerSize, keyboardRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(keyboardRect.x + 1, keyboardRect.y + cornerSize, cornerSize - 1, keyboardRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            RB.DrawRect(new Rect2i(keyboardRect.x + keyboardRect.width - cornerSize, keyboardRect.y + cornerSize, cornerSize, keyboardRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2));
            RB.DrawRectFill(new Rect2i(keyboardRect.x + keyboardRect.width - cornerSize - 1, keyboardRect.y + cornerSize, cornerSize, keyboardRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3));

            int holeColor = 2;

            Rect2i holeRect = RectBetweenKeys("Esc", "Esc");

            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("F1", "F4");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("F5", "F8");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("F9", "F12");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("PrintScreen", "Pause");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("~", "RightCtrl");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("Insert", "PageDown");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("Up", "Up");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("Left", "Right");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            holeRect = RectBetweenKeys("NumLock", "KeypadEnter");
            holeRect = holeRect.Expand(1);
            RB.DrawRectFill(holeRect, DemoUtil.IndexToRGB(holeColor));

            foreach (KeyValuePair <string, KeyboardKey> key in mKeys)
            {
                KeyboardKey k = key.Value;

                bool pressed = RB.KeyDown(k.Code1) || RB.KeyDown(k.Code2);

                if (pressed || IsVirtualKeyPressed(k))
                {
                    RB.DrawRectFill(new Rect2i(k.Rect.x + 2, k.Rect.y + 2, k.Rect.width - 2, k.Rect.height - 2), DemoUtil.IndexToRGB(5));
                    RB.Print(new Vector2i(k.Rect.x + 3, k.Rect.y + 3), DemoUtil.IndexToRGB(0), k.Label);
                }
                else
                {
                    RB.DrawRectFill(k.Rect, DemoUtil.IndexToRGB(4));
                    RB.Print(new Vector2i(k.Rect.x + 2, k.Rect.y + 2), DemoUtil.IndexToRGB(0), k.Label);
                    RB.DrawRect(k.Rect, DemoUtil.IndexToRGB(3));
                }
            }

            RB.CameraReset();
        }
Exemple #17
0
        private void DrawAll(int x, int y)
        {
            var demo      = (DemoReel)RB.Game;
            var gridColor = DemoUtil.IndexToRGB(14);

            RB.Offscreen(0);
            RB.SpriteSheetSet(1);
            mWaveOffset = (int)((RB.Ticks / 2) % 8);
            RB.DrawCopy(new Rect2i(mWaveOffset, 0, RB.SpriteSize()), new Vector2i(24, 8));
            RB.Onscreen();

            Rect2i clipRectOverlap = mClipRect;

            clipRectOverlap.width += 400;

            if (mMap != null)
            {
                RB.DrawRectFill(mClipRect, DemoUtil.IndexToRGB(22));
            }

            RB.ClipSet(clipRectOverlap);
            DrawTilemap(mClipRect.x, mClipRect.y);
            RB.ClipReset();

            RB.CameraReset();

            // Blank out right side
            RB.AlphaSet(196);
            RB.DrawRectFill(new Rect2i(mClipRect.x + mClipRect.width, mClipRect.y, 300, mClipRect.height), DemoUtil.IndexToRGB(1));
            RB.AlphaSet(255);

            // Blank out left side
            RB.DrawRectFill(new Rect2i(0, mClipRect.y, mClipRect.x - 1, mClipRect.height), DemoUtil.IndexToRGB(1));

            RB.DrawRect(mClipRect, DemoUtil.IndexToRGB(7));

            if (mMap == null)
            {
                return;
            }

            RB.AlphaSet(128);

            mFinalStr.Set("Chunk Tile Offset:");
            RB.Print(new Vector2i(mClipRect.x, mClipRect.y - 16), gridColor, mFinalStr);

            RB.CameraSet(mChunkCameraPos - new Vector2i(mClipRect));

            int gxStart = 0;
            int gxEnd   = gxStart + (RB.DisplaySize.width * 2);

            for (int gx = gxStart; gx < gxEnd; gx += RB.MapChunkSize.width * RB.SpriteSize().x)
            {
                RB.DrawLine(new Vector2i(gx, -8), new Vector2i(gx, mClipRect.height + 4), gridColor);

                mFinalStr.Set(gx / RB.SpriteSize().x);
                RB.Print(new Vector2i(gx + 3, -8), gridColor, mFinalStr);
            }

            RB.AlphaSet(255);

            RB.CameraReset();

            RB.SpriteSheetSet(0);
        }
Exemple #18
0
        /// <summary>
        /// Render
        /// </summary>
        public override void Render()
        {
            var demo = (DemoReel)RB.Game;

            if (mMap != null)
            {
                RB.Clear(DemoUtil.IndexToRGB(22));
                RB.DrawMapLayer(0);
                RB.DrawMapLayer(1);
            }
            else
            {
                RB.Print(new Vector2i(2, 210), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            RB.EffectShader(0);
            RB.ShaderFloatSet(0, "Wave", RB.Ticks / 25.0f);

            RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, 200), DemoUtil.IndexToRGB(1));

            string shaderName = "PresentRippleShader";

            mFormatStr.Set("@C// Custom post-processing shader\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"Demos/DemoReel/").Append(shaderName).Append("\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L1@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected](@L0@N);\n");
            mFormatStr.Append("@[email protected](@L0@N, @S\"Wave\"@N, @L").Append(RB.Ticks / 25.0f, 2).Append("f@N);\n");
            mFormatStr.Append("@[email protected](@MRB@N.@[email protected]);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected]();\n");
            DemoUtil.HighlightCode(mFormatStr, mCodeStr);

            mFormatStr.Set("@C// This shader multiplies in a mask and applies a wavy effect!\n");
            mFormatStr.Append("@KShader@N \"Unlit/").Append(shaderName).Append("\" {\n");
            mFormatStr.Append("  @KSubShader@N {\n");
            mFormatStr.Append("    @C...\n");
            mFormatStr.Append("    @KPass@N {\n");
            mFormatStr.Append("      @C...\n");
            mFormatStr.Append("      @C/*** Insert custom shader variables here ***/\n");
            mFormatStr.Append("      @Kfloat@N Wave;\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("      @Nfrag_in vert(appdata v) {\n");
            mFormatStr.Append("        @C...@N\n");
            mFormatStr.Append("      }\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("      @Kfloat4@N frag(v2f i) : @MSV_Target@N {\n");
            mFormatStr.Append("        @C/*** Insert custom fragment shader code here ***/@N\n");
            mFormatStr.Append("        @Kfloat2@N centerOffset = @L-1.0@N + @L2.0@N * i.uv.xy;\n");
            mFormatStr.Append("        @Kfloat@N len = @Klength@N(centerOffset);\n");
            mFormatStr.Append("        i.uv.xy += (centerOffset / len) * cos(len * @L10.0@N - Wave) * @L0.005@N;\n");
            mFormatStr.Append("        @C...@N\n");
            mFormatStr.Append("        @Kreturn@N color;\n");
            mFormatStr.Append("      }\n");
            mFormatStr.Append("    }\n");
            mFormatStr.Append("  }\n");
            mFormatStr.Append("}\n");
            DemoUtil.HighlightCode(mFormatStr, mShaderStr);

            RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(0), mCodeStr);
            RB.Print(new Vector2i(304, 4), DemoUtil.IndexToRGB(0), mShaderStr);
        }
        /// <summary>
        /// Render
        /// </summary>
        public override void Render()
        {
            var demo = (DemoReel)RB.Game;

            RB.Clear(DemoUtil.IndexToRGB(22));

            if (mMap != null)
            {
                int cloudScrollPos = -mCloudTicks % (mMapSize.width * RB.SpriteSheetGet().grid.cellSize.width);

                RB.CameraSet(new Vector2i(mMapSize.width * RB.SpriteSheetGet().grid.cellSize.width / 4, 0));
                RB.DrawMapLayer(0, new Vector2i(cloudScrollPos, 0));
                RB.DrawMapLayer(0, new Vector2i(cloudScrollPos + (mMapSize.width * RB.SpriteSheetGet().grid.cellSize.width), 0));
                RB.DrawMapLayer(1);
                RB.DrawMapLayer(2);
                RB.CameraReset();
            }
            else
            {
                RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

            var color = DemoUtil.IndexToRGB(2);

            mFormatStr.Set(mEffectNames[(int)mEffect]).Append("\n@");
            mFormatStr.Append(color.r, 2, FastString.FORMAT_HEX_CAPS).Append(color.g, 2, FastString.FORMAT_HEX_CAPS).Append(color.b, 2, FastString.FORMAT_HEX_CAPS);
            mConvertString.Set(mEffectNames[(int)mEffect]).ToUpperInvariant();
            mFormatStr.Append("RB.EffectSet(RB.Effect.").Append(mConvertString).Append(mParamsText).Append(");");

            RB.Print(new Vector2i((RB.DisplaySize.width / 2) - 120, (RB.DisplaySize.height / 2) - 10), DemoUtil.IndexToRGB(0), mFormatStr);
        }
Exemple #20
0
        private void DrawSpritePacking(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            mFormatStr.Set(
                "@DRetroBlit features a sprite packer that can cram your folders\n" +
                "full of sprites into optimal sprite sheets! To use it simply\n" +
                "create a sprite pack file (.sp) and point it to your sprite folder.");

            RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(25), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            y += 16;

            int indent       = 16;
            int row          = 0;
            int rowSpacing   = 9;
            int imageSpacing = 3;
            int fileColor    = 5;
            int folderColor  = 3;
            int alphaSprite  = 7;

            // Draw sprite pack file
            RB.CameraSet(new Vector2i(-170, -16));
            RB.DrawRectFill(new Rect2i(x - 4, y - 4, 108, 112), DemoUtil.IndexToRGB(2));

            mFormatStr.Set("@C// Source folder(s)\n");
            mFormatStr.Append("@C// relative to project\n");
            mFormatStr.Append("@C// root\n");
            mFormatStr.Append("@MSOURCE_FOLDER@N=@LSprites@N\n\n");
            mFormatStr.Append("@C// Output size\n");
            mFormatStr.Append("@MOUTPUT_WIDTH@N=@L96@N\n");
            mFormatStr.Append("@MOUTPUT_HEIGHT@N=@L96@N\n\n");
            mFormatStr.Append("@C// Trim empty space\n");
            mFormatStr.Append("@MTRIM@N=@Ltrue@N");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(fileColor), "DemoSpritePack.sp");
            RB.DrawLine(new Vector2i(x, y + rowSpacing + 2), new Vector2i(x + 100, y + rowSpacing + 2), DemoUtil.IndexToRGB(3));
            RB.Print(new Vector2i(x, y + rowSpacing + rowSpacing), DemoUtil.IndexToRGB(fileColor), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            RB.DrawRectFill(new Rect2i(-32, 60, 6 * 3, 6), DemoUtil.IndexToRGB(5));
            RB.DrawRectFill(new Rect2i(-26, 54, 6, 6 * 3), DemoUtil.IndexToRGB(5));

            // Draw file listing
            RB.CameraSet(new Vector2i(-4, -16));
            RB.SpriteSheetSet(0);
            RB.DrawRectFill(new Rect2i(x - 4, y - 4, 120, 266), DemoUtil.IndexToRGB(2));

            mFormatStr.Set(
                "@DYour sprite source folders can be anywhere, but it's best to keep\n" +
                "them out of your @NAssets@D folder so that Unity does not put your\n" +
                "source sprites into the game @NAsset Resources@D!\n" +
                "\n" +
                "When you change your source sprites be sure to manually re-import\n" +
                "your sprite pack because Unity can't detect sprite changes outside\n" +
                "of the @NAssets@D folder!");

            RB.Print(new Vector2i(x - 4, y - 4 + 270), DemoUtil.IndexToRGB(25), DemoUtil.HighlightCode(mFormatStr, mFinalStr));

            RB.Print(new Vector2i(x, y + row), DemoUtil.IndexToRGB(folderColor), "Sprites/");
            row += rowSpacing;

            RB.Print(new Vector2i(x + indent, y + row), DemoUtil.IndexToRGB(folderColor), "Characters/");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteHero1, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteHero1.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "Hero1.png");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteHero2, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteHero2.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "Hero2.png");
            row += rowSpacing;

            RB.Print(new Vector2i(x + indent, y + row), DemoUtil.IndexToRGB(folderColor), "Terrain/");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteDirtCenter, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteDirtCenter.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "DirtCenter.png");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteDirtSide, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteDirtSide.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "DirtSide.png");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteGrassTop, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteGrassTop.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "GrassTop.png");
            row += rowSpacing;

            RB.SpriteSheetSet(1);
            RB.DrawSprite(alphaSprite, new Vector2i(x + (indent * 2), y + row));
            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteGrassTopRight, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteGrassTopRight.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "GrassTopRight.png");
            row += rowSpacing;

            RB.SpriteSheetSet(0);
            RB.DrawSprite(mSpriteWater, new Vector2i(x + (indent * 2), y + row));
            row += mSpriteWater.Size.height + imageSpacing;
            RB.Print(new Vector2i(x + (indent * 2), y + row), DemoUtil.IndexToRGB(fileColor), "Water.png");
            row += rowSpacing;

            RB.Print(new Vector2i(x + indent, y + row), DemoUtil.IndexToRGB(folderColor), "Other/");
            row += rowSpacing;
            RB.Print(new Vector2i(x + (indent * 3), y + row), DemoUtil.IndexToRGB(folderColor), "...\n...\n...");

            // Draw packed sprite sheet
            RB.CameraSet(new Vector2i(-168, -172));
            RB.DrawRectFill(new Rect2i(x, y, RB.SpriteSheetSize().width + 4, RB.SpriteSheetSize().height + 4), DemoUtil.IndexToRGB(2));

            RB.SpriteSheetSet(1);
            for (int gx = 0; gx < 6; gx++)
            {
                for (int gy = 0; gy < 6; gy++)
                {
                    RB.DrawSprite(alphaSprite, new Vector2i(x + 2 + (gx * 16), y + 2 + (gy * 16)));
                }
            }

            RB.SpriteSheetSet(0);
            RB.DrawCopy(new Rect2i(0, 0, RB.SpriteSheetSize().width, RB.SpriteSheetSize().height), new Vector2i(x + 2, y + 2));

            Vector2i p0 = new Vector2i((RB.SpriteSheetSize().width / 2) + 6, 8);
            Vector2i p1 = new Vector2i(p0.x - 10, p0.y - 10);
            Vector2i p2 = new Vector2i(p0.x + 10, p0.y - 10);

            RB.DrawTriangleFill(p0, p1, p2, DemoUtil.IndexToRGB(5));
            RB.DrawRectFill(new Rect2i(p0.x - 6, p1.y - 10, 11, 10), DemoUtil.IndexToRGB(5));

            RB.CameraReset();
        }
        private void ApplyEffect()
        {
            var demo = (DemoReel)RB.Game;

            float progress = Mathf.Sin((RB.Ticks % 250) / 150f * Mathf.PI);

            progress = Mathf.Clamp(progress, 0, 1);

            Color32 rgb;

            switch (mEffect)
            {
            case RB.Effect.Scanlines:
            case RB.Effect.Noise:
            case RB.Effect.Desaturation:
            case RB.Effect.Curvature:
            case RB.Effect.Negative:
            case RB.Effect.Pixelate:
                RB.EffectSet(mEffect, progress);
                mParamsText.Set(", ").Append(progress, 2);
                break;

            case RB.Effect.Shake:
                RB.EffectSet(mEffect, progress * 0.1f);
                mParamsText.Set(", ").Append(progress * 0.1f, 2);
                break;

            case RB.Effect.Zoom:
                RB.EffectSet(mEffect, (progress * 5.0f) + 0.5f);
                mParamsText.Set(", ").Append((progress * 5.0f) + 0.5f, 2);
                break;

            case RB.Effect.Slide:
            case RB.Effect.Wipe:
                Vector2i slide = new Vector2i((int)(progress * RB.DisplaySize.width), 0);
                RB.EffectSet(mEffect, slide);
                mParamsText.Set(", new Vector2i(").Append(slide.x).Append(", ").Append(slide.y).Append(")");
                break;

            case RB.Effect.Rotation:
                RB.EffectSet(mEffect, progress * 360.0f);
                mParamsText.Set(", ").Append(progress * 360.0f, 0);
                break;

            case RB.Effect.ColorFade:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(20));
                rgb = DemoUtil.IndexToRGB(20);
                mParamsText.Set(", ").Append(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.ColorTint:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(31));
                rgb = DemoUtil.IndexToRGB(31);
                mParamsText.Set(", ").Append(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.Fizzle:
                RB.EffectSet(mEffect, progress, Vector2i.zero, DemoUtil.IndexToRGB(11));
                rgb = DemoUtil.IndexToRGB(11);
                mParamsText.Set(progress, 2).Append(", Vector2i.zero, new Color32").Append(rgb);

                break;

            case RB.Effect.Pinhole:
            case RB.Effect.InvertedPinhole:
                Vector2i pos =
                    new Vector2i(
                        (int)((Mathf.Sin(progress * 8) * (RB.DisplaySize.width / 6.0f)) + (RB.DisplaySize.width / 6.0f)),
                        (int)((Mathf.Cos(progress * 8) * (RB.DisplaySize.width / 6.0f)) + (RB.DisplaySize.width / 6.0f)));

                RB.EffectSet(mEffect, progress, pos, DemoUtil.IndexToRGB(0));
                rgb = DemoUtil.IndexToRGB(0);
                mParamsText.Set(", ").Append(progress, 2).Append(", new Vector2i").Append(pos).Append(", new Color32").Append(rgb);

                break;
            }
        }
        private void DrawEase(Ease.Func func, string funcName, int x, int y, int width, int height)
        {
            byte spriteAlpha = 255;

            if (mT > 1.5f)
            {
                spriteAlpha = (byte)(((1.5f - mT) / 0.5f) * 255);
            }

            var graphColor      = DemoUtil.IndexToRGB(2);
            var lineColor       = DemoUtil.IndexToRGB(3);
            var scaleColor      = DemoUtil.IndexToRGB(24);
            var interStartColor = DemoUtil.IndexToRGB(27);
            var interEndColor   = DemoUtil.IndexToRGB(23);

            RB.CameraSet(new Vector2i(-x, -y));

            width  -= 28;
            height -= 16;

            // Draw graph
            int spaceBetweenLines = (height + 8) - 8;

            RB.DrawLine(new Vector2i(0, 8), new Vector2i(width, 8), graphColor);
            RB.DrawLine(new Vector2i(0, 8 + spaceBetweenLines), new Vector2i(width, 8 + spaceBetweenLines), graphColor);
            RB.Print(new Vector2i(0, 10), graphColor, funcName);

            // Draw line
            Vector2i p0 = new Vector2i(0, 8 + height);

            for (int i = 1; i <= width; i += 1)
            {
                int val = 0;
                val = Ease.Interpolate(func, 0, height, i / (float)width);

                Vector2i p1 = new Vector2i(i, 8 + height - val);

                RB.DrawLine(p0, p1, lineColor);

                p0 = p1;
            }

            // Draw movement sprite
            float t = mT;

            if (t > 1)
            {
                t = 1;
            }

            float ti = Ease.Interpolate(func, 0, 1.0f, t);

            Vector2i pos = new Vector2i(width + 8 - 4, 8 + height - Mathf.RoundToInt(ti * height) - 4);

            RB.DrawSprite(RB.SpriteIndex(7, 12), new Vector2i(width + 8 - 4, 8 - 4));
            RB.DrawSprite(RB.SpriteIndex(7, 12), new Vector2i(width + 8 - 4, 8 + height - 4));

            RB.AlphaSet(spriteAlpha);
            var highlightPos = new Vector2i((t * width) - 1, pos.y + 3);

            RB.DrawSprite(RB.SpriteIndex(7, 13), highlightPos);
            RB.DrawSprite(RB.SpriteIndex(7, 11), pos);
            RB.AlphaSet(255);

            int scale = 4 + Mathf.RoundToInt(ti * ((spaceBetweenLines / 2) - 4));

            RB.DrawRectFill(new Rect2i(width + 16, (height / 2) - scale + 8, 3, (scale * 2) + 1), scaleColor);

            var interColor = Ease.Interpolate(func, interStartColor, interEndColor, t);

            RB.DrawRectFill(new Rect2i(width + 20, 8, 3, 3), interEndColor);
            RB.DrawRectFill(new Rect2i(width + 20, 8 + spaceBetweenLines - 4 + 2, 3, 3), interStartColor);
            RB.DrawRectFill(new Rect2i(width + 20, 9 + 3, 3, spaceBetweenLines - 7), interColor);

            RB.CameraReset();
        }
        private void DrawSpriteSheet(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            Rect2i ss0Rect       = new Rect2i(0, 0, 16 * 7, 16 * 6);
            Rect2i ss1Rect       = new Rect2i(0, ss0Rect.y + ss0Rect.height + 16, 16 * 7, 16 * 2);
            Rect2i copyRectWater = new Rect2i(mWaveOffset + ss1Rect.x - 1, ss1Rect.y - 1, 16 + 2, 16 + 2);
            Rect2i destRectWater = new Rect2i(ss0Rect.x + (3 * 16), ss0Rect.y + (4 * 16), 16, 16);
            Rect2i copyRectFish  = new Rect2i((mFishFrame * 16) + ss1Rect.x - 1, ss1Rect.y - 1 + 16, 16 + 2, 16 + 2);
            Rect2i destRectFish  = new Rect2i(ss0Rect.x + (5 * 16), ss0Rect.y + (4 * 16), 16, 16);

            RB.CameraSet(new Vector2i(-x, -y));

            RB.Print(new Vector2i(ss0Rect.x, ss0Rect.y + ss0Rect.height + 2), Color.gray, "myTilemapSpriteSheet");
            RB.Print(new Vector2i(ss0Rect.x, ss1Rect.y + ss1Rect.height + 2), Color.gray, "myAnimationSpriteSheet");

            RB.SpriteSheetSet(spriteSheet1);

            // Draw alpha grid for sprite sheet 0
            for (int gx = 0; gx < ss0Rect.width; gx += 16)
            {
                for (int gy = 0; gy < ss0Rect.height; gy += 16)
                {
                    RB.DrawSprite(RB.SpriteIndex(7, 0), new Vector2i(gx + ss0Rect.x, gy + ss0Rect.y));
                }
            }

            // Draw alpha grid for sprite sheet 1
            for (int gx = 0; gx < ss1Rect.width; gx += 16)
            {
                for (int gy = 0; gy < ss1Rect.height; gy += 16)
                {
                    RB.DrawSprite(RB.SpriteIndex(7, 0), new Vector2i(gx + ss1Rect.x, gy + ss1Rect.y));
                }
            }

            RB.SpriteSheetSet(spriteSheet2);
            RB.DrawCopy(new Rect2i(0, 0, RB.SpriteSheetGet().sheetSize), new Vector2i(ss1Rect.x, ss1Rect.y));
            RB.SpriteSheetSet(spriteSheet1);

            int color = 7;

            RB.DrawCopy(new Rect2i(0, 16 * 8, ss0Rect.width, ss0Rect.height), new Vector2i(ss0Rect.x, ss0Rect.y));

            // Water copy rects
            RB.DrawRect(copyRectWater, DemoUtil.IndexToRGB(color));
            destRectWater.Expand(1);
            RB.DrawRect(destRectWater, DemoUtil.IndexToRGB(color));
            RB.DrawLine(
                new Vector2i(copyRectWater.x + (copyRectWater.width / 2), copyRectWater.y),
                new Vector2i(destRectWater.x + 8, destRectWater.y + 18),
                DemoUtil.IndexToRGB(color));

            // Fish copy rects
            if (mFishFrame < 7)
            {
                RB.DrawRect(copyRectFish, DemoUtil.IndexToRGB(color));
                destRectFish.Expand(1);
                RB.DrawRect(destRectFish, DemoUtil.IndexToRGB(color));
                RB.DrawLine(
                    new Vector2i(copyRectFish.x + (copyRectFish.width / 2), copyRectFish.y),
                    new Vector2i(destRectFish.x + 8, destRectFish.y + 18),
                    DemoUtil.IndexToRGB(color));
            }

            RB.CameraReset();
        }