コード例 #1
0
        private void DrawLines(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 58));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 260, 34), -1, mOutputFrame, mOutputBackground);

            Vector2i lineCenter = new Vector2i(130, 33);

            for (int i = 0; i < mLinePoint.Length; i++)
            {
                mLinePoint[i].x = (int)(Mathf.Cos((i / (float)mLinePoint.Length * Mathf.PI) + Mathf.PI) * 128);
                mLinePoint[i].y = -(int)(Mathf.Sin(i / ((float)mLinePoint.Length - 1) * Mathf.PI) * 34);
                mLinePoint[i]  += lineCenter;
            }

            for (int i = 0; i < mLinePoint.Length; i++)
            {
                RB.DrawLine(lineCenter, mLinePoint[i], DemoUtil.IndexToRGB((i + (((int)RB.Ticks / 10) % 32)) % 32));
            }

            RB.CameraReset();

            mFormatStr.Set("@C// Draw lines\n");
            mFormatStr.Append("@Kfor @N(@Kint@N i = @L0@N; i < @L32@N; i++) {\n");
            mFormatStr.Append("    @MVector2i@N p = @Knew @MVector2i@N(\n");
            mFormatStr.Append("        (@Kint@N)(@[email protected](i / @L38.0f@N * @[email protected] + @[email protected]) * @L128@N, \n");
            mFormatStr.Append("        @L-@N(@Kint@N)(@[email protected](i / @L37.0f@N * @[email protected]) * @L34h@N));\n");
            mFormatStr.Append("    @[email protected](@Knew @MVector2i@N(@L").Append(lineCenter.x).Append("@N, @L").Append(lineCenter.y).Append("@N), p, MyRGBColor(i + @L").Append(((int)RB.Ticks / 10) % 32).Append("@N) % @L32@N));\n};");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #2
0
        private void DrawNoisePad(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mFormatStr.Set("@C// Load sounds and play them\n");
            mFormatStr.Append("@NsoundCoin.Load(@S\"Demos/Demo/Coin\"@N);\n");
            mFormatStr.Append("@NsoundExplosion.Load(@S\"Demos/Demo/Explosion\"@N);\n");
            mFormatStr.Append("@NsoundJump.Load(@S\"Demos/Demo/Jump\"@N);\n");
            mFormatStr.Append("@NsoundLaser.Load(@S\"Demos/Demo/Laser\"@N);\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kif@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected](soundCoin);\n");
            mFormatStr.Append("} @Kelse if@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected](soundExplosion);\n");
            mFormatStr.Append("} @Kelse if@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected](soundJump);\n");
            mFormatStr.Append("} @Kelse if@N (@[email protected](@[email protected]) {\n");
            mFormatStr.Append("   @[email protected](soundLaser);\n");
            mFormatStr.Append("}");

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

            RB.CameraSet(new Vector2i(-x, -y - 123));
            for (int i = 0; i < mEffectButtons.Length; i++)
            {
                mEffectButtons[i].Render();
            }

            RB.CameraReset();
        }
コード例 #3
0
        private void DrawTint(int x, int y, int spriteIndex)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 50));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 64, 16), -1, mOutputFrame, mOutputBackground);

            RB.TintColorSet(Color.white);
            RB.DrawSprite(spriteIndex, new Vector2i(0, 0));
            RB.TintColorSet(DemoUtil.IndexToRGB(12));
            RB.DrawSprite(spriteIndex, new Vector2i(24, 0));
            RB.TintColorSet(DemoUtil.IndexToRGB((int)(RB.Ticks / 10) % 32));
            RB.DrawSprite(spriteIndex, new Vector2i(48, 0));
            RB.TintColorSet(Color.white);

            RB.CameraReset();

            mFormatStr.Set("@C// Set tint color for drawing (RGB Mode only)\n");
            mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N));\n");
            mFormatStr.Append("@[email protected](@I12);\n").Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L24@N, @L0@N));\n");
            mFormatStr.Append("@[email protected](@I").Append((RB.Ticks / 10) % 32, 2).Append(");\n");
            mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i(@L48@N, @L0@N));");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #4
0
        private void DrawSystemFont(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 49, 6), -1, mOutputFrame, mOutputBackground);

            int c1 = ((int)RB.Ticks / 10) % 32;
            int c2 = (((int)RB.Ticks / 10) + 10) % 32;
            int c3 = (((int)RB.Ticks / 10) + 20) % 32;

            var color1 = DemoUtil.IndexToRGB(c1);
            var color2 = DemoUtil.IndexToRGB(c2);
            var color3 = DemoUtil.IndexToRGB(c3);

            mFormatStr.Set("Hello @");
            mFormatStr.Append(color1.r, 2, FastString.FORMAT_HEX_CAPS).Append(color1.g, 2, FastString.FORMAT_HEX_CAPS).Append(color1.b, 2, FastString.FORMAT_HEX_CAPS).Append("fr@");
            mFormatStr.Append(color2.r, 2, FastString.FORMAT_HEX_CAPS).Append(color2.g, 2, FastString.FORMAT_HEX_CAPS).Append(color2.b, 2, FastString.FORMAT_HEX_CAPS).Append("ie@");
            mFormatStr.Append(color3.r, 2, FastString.FORMAT_HEX_CAPS).Append(color3.g, 2, FastString.FORMAT_HEX_CAPS).Append(color3.b, 2, FastString.FORMAT_HEX_CAPS).Append("nd");

            RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(6), mFormatStr);

            RB.CameraReset();

            mFormatStr.Set("@C// Print text with default system font, with inline color support\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L0@N, @L0@N), @I06@N,\n").Append("   @S\"Hello @s@@");
            mFormatStr.Append(color1.r, 2, FastString.FORMAT_HEX_CAPS).Append(color1.g, 2, FastString.FORMAT_HEX_CAPS).Append(color1.b, 2, FastString.FORMAT_HEX_CAPS).Append("@Sfr@s@@");
            mFormatStr.Append(color2.r, 2, FastString.FORMAT_HEX_CAPS).Append(color2.g, 2, FastString.FORMAT_HEX_CAPS).Append(color2.b, 2, FastString.FORMAT_HEX_CAPS).Append("@Sie@s@@");
            mFormatStr.Append(color3.r, 2, FastString.FORMAT_HEX_CAPS).Append(color3.g, 2, FastString.FORMAT_HEX_CAPS).Append(color3.b, 2, FastString.FORMAT_HEX_CAPS).Append("@Snd\"@N);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #5
0
        /// <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);
        }
コード例 #6
0
        /// <summary>
        /// Render the console
        /// </summary>
        public void Render()
        {
            var game = (RetroDungeoneerGame)RB.Game;

            var cameraPos = RB.CameraGet();

            RB.CameraReset();

            int yOffset = 0;
            var curLine = mLogLines.First;

            byte alpha = 255;

            // Keep looping and printing log lines until we the console max height
            while (yOffset < size.height && curLine != null && curLine.Value.Length > 0)
            {
                var lineSize = RB.PrintMeasure(game.assets.fontSmall, new Rect2i(0, 0, size.width, 9999), RB.TEXT_OVERFLOW_WRAP, curLine.Value);

                // Draw text
                RB.AlphaSet(alpha);
                RB.Print(game.assets.fontSmall, new Rect2i(4, RB.DisplaySize.height - yOffset - 4 - lineSize.height, size.width, 9999), Color.white, RB.TEXT_OVERFLOW_WRAP, curLine.Value);
                RB.AlphaSet(255);
                alpha -= 15;
                if (alpha < 15)
                {
                    alpha = 15;
                }

                yOffset += lineSize.height + 2;

                curLine = curLine.Next;
            }

            RB.CameraSet(cameraPos);
        }
コード例 #7
0
        private void DrawSprite(int x, int y, int spriteIndex)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 17));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 16, 16), -1, mOutputFrame, mOutputBackground);

            mFormatStr.Clear();

            if (RB.Ticks % 200 < 100)
            {
                mFormatStr.Append("@C// Draw sprite from sprite sheet by its index\n");
                mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N));");
                RB.DrawSprite(spriteIndex, new Vector2i(0, 0));
            }
            else
            {
                mFormatStr.Append("@C// Draw sprite from sprite sheet by its index\n");
                mFormatStr.Append("@[email protected](@L").Append(spriteIndex).Append("@N, @Knew @MVector2i@N(@L0@N, @L0@N), @[email protected]_H );");
                RB.DrawSprite(spriteIndex, new Vector2i(0, 0), RB.FLIP_H);
            }

            RB.CameraReset();

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #8
0
        private void DrawCode(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mFormatStr.Set("@C// RetroBlit lets you draw pixel buffers!\n");
            mFormatStr.Append("@MColor32@N[] pixelBuffer = @Knew @MColor32@N[@L").Append(mFireSize.width).Append("@N * @L");
            mFormatStr.Append(mFireSize.height).Append("@N];\n");
            mFormatStr.Append("@C/* ... fill pixel buffer with pixel colors ... */\n\n");

            mFormatStr.Append("@C// Draw pixel buffer at 1:1 scale, anywhere on the screen\n");
            mFormatStr.Append("@[email protected](@NpixelBuffer, @Knew @MVector2i@N(@L").Append(mFireSize.width).Append("@N, @L");
            mFormatStr.Append(mFireSize.height).Append("@N), @Knew @MVector2i@N(@L").Append(mFirePos.x).Append("@N, @L").Append(mFirePos.y);
            mFormatStr.Append("@N));\n\n");

            mFormatStr.Append("@C// Or rotate and scale it just like a sprite!\n");
            mFormatStr.Append("@[email protected](@NpixelBuffer, @Knew @MVector2i@N(@L").Append(mFireSize.width).Append("@N, @L");
            mFormatStr.Append(mFireSize.height).Append("@N), @Knew @MRect2i@N(@L").Append(mFireRect.x).Append("@N, @L").Append(mFireRect.y);
            mFormatStr.Append("@N, @L").Append(mFireRect.width).Append("@N, @L").Append(mFireRect.height).Append("@N), ");
            mFormatStr.Append("@Knew @MVector2i@N(@L").Append(mFireSize.width / 2).Append("@N, @L").Append(mFireSize.height / 2).Append("@N), ");
            mFormatStr.Append("@L").Append(mRotation, 2).Append("@N);");

            RB.CameraReset();

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #9
0
ファイル: SceneInput.cs プロジェクト: svwilke/Spellzee
        private void DrawInputString(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            int width  = 612;
            int height = 32;

            RB.DrawRect(new Rect2i(0, 0, width, height), DemoUtil.IndexToRGB(25));
            RB.DrawRectFill(new Rect2i(1, 1, width - 2, height - 2), DemoUtil.IndexToRGB(27));

            RB.ClipSet(new Rect2i(x + 4, y + 4, width - 8, height - 2));

            if (RB.Ticks % 30 < 15)
            {
                RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString);
            }
            else
            {
                mInputString.Append('|');
                RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(23), RB.NO_ESCAPE_CODES, mInputString);
                mInputString.Truncate(mInputString.Length - 1);
            }

            RB.CameraReset();

            RB.ClipReset();
        }
コード例 #10
0
ファイル: SceneText.cs プロジェクト: svwilke/Spellzee
        private void DrawClip(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mDialogStr.Set("You there!\nThat's a nice\ngolden sword,\nand dragon\nhide armor!\nYou look like\nyou could use a\nfew coppers,\nhow about you\nclean out\nthe @dbab7710@- rats in\nmy basement?");

            var size     = (int)(Mathf.Sin(RB.Ticks / 20.0f) * 22) * 2;
            var textRect = new Rect2i(32 - (size / 2), 45, 80 + size, 128);

            DrawTextFrame(textRect, null);
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER | RB.TEXT_OVERFLOW_CLIP, mDialogStr);

            textRect = new Rect2i(32 - (size / 2) + 140, 45, 80 + size, 128);
            DrawTextFrame(textRect, null);
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER | RB.TEXT_OVERFLOW_WRAP | RB.TEXT_OVERFLOW_CLIP, mDialogStr);

            textRect = new Rect2i(32 - (size / 2) + 70, 180, 80 + size, 128);
            DrawTextFrame(textRect, null);
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER | RB.TEXT_OVERFLOW_WRAP, mDialogStr);

            mFormatStr.Set("@C// Clip and wrap text in a text rectangle\n").Append("@Kint@N center = @[email protected]_H_CENTER | @[email protected]_V_CENTER;\n");
            mFormatStr.Append("@[email protected](@Knew@N Rect2i(@L20@N, @L20@N, @L").Append(80 + size).Append("@N, @L128@N),\n   center | @[email protected]_OVERFLOW_CLIP, myText);\n");
            mFormatStr.Append("@[email protected](@Knew@N Rect2i(@L160@N, @L20@N, @L").Append(80 + size).Append("@N, @L128@N),\n   center | @[email protected]_OVERFLOW_WRAP | @[email protected]_OVERFLOW_CLIP, myText);\n");
            mFormatStr.Append("@[email protected](@Knew@N Rect2i(@L90@N, @L155@N, @L").Append(80 + size).Append("@N, @L128@N),\n   center | @[email protected]_OVERFLOW_WRAP, myText);\n");

            RB.CameraReset();

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #11
0
        private void DrawCode(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mFormatStr.Set("@C// RetroBlit assets can also be loaded asynchronously from Resources, WWW, and Addressable Assets (with Unity AA package installed)!@N\n");
            mFormatStr.Append("@MSpriteSheetAsset@N spriteSheet = @Knew@N SpriteSheetAsset();\n");
            mFormatStr.Append("@MAudioAsset@N audio = @Knew@N AudioAsset();\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kvoid @MInitialize@N() {\n");
            mFormatStr.Append("    spriteSheet.Load(@S\"https://www.retroblit.com/superflagrun.png\"@N, @MRB@N.@MAssetSource@N.@LWWW@N);\n");
            mFormatStr.Append("    audio.Load(@S\"ding\"@N, @MRB@N.@MAssetSource@N.@LAddressableAssets@N);\n");
            mFormatStr.Append("};\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kvoid@N Update() {\n");
            mFormatStr.Append("    @Kif@N (audio.status == @MRB@N.@MAssetStatus@N.@LReady@N) {\n");
            mFormatStr.Append("        @[email protected](audio);\n");
            mFormatStr.Append("    }\n");
            mFormatStr.Append("};\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("@Kvoid@N Render() {\n");
            mFormatStr.Append("    @Kif@N (spriteSheet.status == @MRB@N.@MAssetStatus@N.@LReady@N) {\n");
            mFormatStr.Append("        @[email protected](spriteSheet);\n");
            mFormatStr.Append("        @[email protected](@L0@N, @Knew@N Vector2i(@L100@N, @L50@N));\n");
            mFormatStr.Append("    }\n");
            mFormatStr.Append("\n");
            mFormatStr.Append("    @Kif@N (spriteSheet.status != @MRB@N.@MAssetStatus@N.@LReady@N) DrawSpriteSheetProgress(spriteSheet.progress);\n");
            mFormatStr.Append("    @Kif@N (audio.status != @MRB@N.@MAssetStatus@N.@LReady@N) DrawAudioProgress(audio.progress);\n");
            mFormatStr.Append("};\n");

            RB.CameraReset();

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #12
0
        private static void RenderMouseHover()
        {
            var tilePos = SceneGame.GetMouseTilePos();

            if (tilePos.x == -1)
            {
                return;
            }

            EntityFunctions.GetEntitiesStringAtTile(tilePos, C.FSTR);

            if (C.FSTR.Length > 0)
            {
                // Preserve camera location
                var cameraPos = RB.CameraGet();
                RB.CameraReset();

                var mousePos = RB.PointerPos();

                var anchorPos = new Vector2i(mousePos.x + 4, mousePos.y + 12);

                var textSize      = RB.PrintMeasure(C.FONT_SMALL, C.FSTR);
                var textRect      = new Rect2i(anchorPos.x, anchorPos.y, textSize.width, textSize.height);
                var textFrameRect = new Rect2i(textRect.x - 4, textRect.y - 4, textRect.width + 8, textRect.height + 8);

                RB.DrawRectFill(textFrameRect, C.COLOR_MENU_BACKGROUND);
                RB.DrawRect(textFrameRect, Color.white);
                RB.Print(C.FONT_SMALL, textRect, Color.white, 0, C.FSTR);

                RB.CameraSet(cameraPos);
            }
        }
コード例 #13
0
ファイル: ScenePixelStyle.cs プロジェクト: svwilke/Spellzee
        private void DrawTMX()
        {
            var demo = (DemoReel)RB.Game;

            int    spriteFrame   = (RB.Ticks % 40) > 20 ? 1 : 0;
            Rect2i clipRect      = new Rect2i(0, 0, 0, 0);
            int    cameraYOffset = 0;
            int    cameraXOffset = 0;
            int    cameraYRange  = 16;

            if (mStyle == RB.PixelStyle.Wide)
            {
                clipRect = new Rect2i((RB.DisplaySize.width / 2) - 100, RB.DisplaySize.height - 220, 200, 200);
            }
            else if (mStyle == RB.PixelStyle.Tall)
            {
                clipRect      = new Rect2i((RB.DisplaySize.width / 2) - 200, RB.DisplaySize.height - 110, 400, 100);
                cameraYOffset = 150;
                cameraXOffset = -120;
                cameraYRange  = 8;
            }

            if (mMap != null)
            {
                int      scrollPos = -(int)RB.Ticks % (mMapSize.width * RB.SpriteSize().width);
                Vector2i cameraPos = new Vector2i((int)((Mathf.Sin(RB.Ticks / 100.0f) * 420) + 450 + cameraXOffset), (int)((Mathf.Sin(RB.Ticks / 10.0f) * cameraYRange) + cameraYOffset));

                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                RB.CameraSet(cameraPos);
                RB.DrawMapLayer(0, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(0, new Vector2i(scrollPos + (mMapSize.width * RB.SpriteSize().width), 0));
                RB.DrawMapLayer(1);
                RB.DrawMapLayer(2);
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
                RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16));
                RB.CameraReset();
            }
            else
            {
                RB.Print(new Vector2i(clipRect.x + 2, clipRect.y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map\nDemos/DemoReel/Tilemap.tmx in Unity");
            }

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

            RB.ClipReset();

            mFormatStr.Set("@C// Use ").Append(mStyle == RB.PixelStyle.Wide ? "wide" : "tall").Append(" pixel format\n");
            mFormatStr.Append("@Kpublic @MHardwareSettings @NQueryHardware() {\n");
            mFormatStr.Append("   @Kvar @Nhw = @Knew @MHardwareSettings@N();\n");
            mFormatStr.Append("   @Nhw.DisplaySize = @Knew @MVector2i@N(@L").Append(RB.DisplaySize.width).Append("@N, @L").Append(RB.DisplaySize.height).Append("@N);\n");
            mFormatStr.Append("   @Nhw.PixelStyle = @KRetroBlit@N.@EPixelStyle@N.").Append(mStyle == RB.PixelStyle.Wide ? "Wide" : "Tall").Append(";\n");
            mFormatStr.Append("   @Kreturn @Nhw;\n");
            mFormatStr.Append("}");

            RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #14
0
ファイル: GameCamera.cs プロジェクト: svwilke/Spellzee
        /// <summary>
        /// Apply the camera position
        /// </summary>
        public void Apply()
        {
            Vector2i pos = mPos;

            pos.x -= (RB.DisplaySize.width / 2) - (RB.SpriteSize(0).width / 2);
            pos.y -= (RB.DisplaySize.height / 2) - (RB.SpriteSize(0).height / 2);

            RB.CameraSet(pos);
        }
コード例 #15
0
        private void DrawTMX(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            Rect2i   clipRect    = new Rect2i(x + 16, y + 142, 310, 207);
            Vector2i cameraPos   = new Vector2i((int)(Mathf.Sin(RB.Ticks / 100.0f) * 450) + 200, (int)Mathf.Sin(RB.Ticks / 10.0f) * 16);
            int      spriteFrame = (RB.Ticks % 40) > 20 ? 1 : 0;

            if (mMap != null && mMap.status == RB.AssetStatus.Ready)
            {
                int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width);

                RB.ClipSet(clipRect);
                RB.DrawRectFill(clipRect, DemoUtil.IndexToRGB(22));

                RB.CameraSet(cameraPos);

                RB.DrawMapLayer(1, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0));
                RB.DrawMapLayer(2);
                RB.DrawMapLayer(3);
                RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16));
                RB.DrawSprite(RB.SpriteIndex(6, 10) + spriteFrame, new Vector2i(67 * 16, 14 * 16));
            }
            else
            {
                RB.CameraReset();
                RB.ClipReset();
                RB.Print(new Vector2i(x + 18, y + 144), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity");
            }

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

            mMap.Load("Demos/DemoReel/Tilemap");

            mFormatStr.Set("@C// Load a map from a TMX file\n");
            mFormatStr.Append("@NmyTMXMap.Load(@S\"Demos/Demo/Tilemap\"@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Clouds\"@N, @L1@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Decoration\"@N, @L2@N);\n");
            mFormatStr.Append("@NmyTMXMap.LoadLayer(@S\"Terrain\"@N, @L3@N);\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N));\n");
            mFormatStr.Append("@[email protected](@Knew@N @MRect2i@N(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I22);\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L").Append(cameraPos.x).Append("@N, @L").Append(cameraPos.y).Append("@N));\n");
            mFormatStr.Append("@Kint@N pos = @L").Append(-(int)RB.Ticks).Append("@N % (myMap.size.width * @[email protected]);\n");
            mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos, @L0@N));\n");
            mFormatStr.Append("@[email protected](@L1@N, @Knew @MVector2i@N(pos + (myMap.size.width * @[email protected])), @L0@N));\n");
            mFormatStr.Append("@[email protected](@L2@N);\n");
            mFormatStr.Append("@[email protected](@L3@N);\n");
            mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N @MVector2i@N(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));\n");
            mFormatStr.Append("@[email protected](@L").Append(RB.SpriteIndex(6, 10) + spriteFrame).Append("@N, @Knew @MVector2i@N(@L").Append(67 * 16).Append("@N, @L").Append(14 * 16).Append("@N));\n");
            mFormatStr.Append("@[email protected]();\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L").Append(clipRect.x).Append("@N, @L").Append(clipRect.y).Append("@N, @L").Append(clipRect.width).Append("@N, @L").Append(clipRect.height).Append("@N), @I21);\n");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #16
0
        /// <summary>
        /// Render
        /// </summary>
        public void Render()
        {
            var game = (BrickBustGame)RB.Game;

            RB.DrawMapLayer(0);

            // Render in 2 passes, first pass renders shadows
            for (int renderPass = 0; renderPass < 2; renderPass++)
            {
                if (renderPass == 0)
                {
                    RB.ShaderSet(game.assets.shaderShadow);
                    game.assets.shaderShadow.ColorSet("_ShadowColor", new Color32(0, 0, 0, 96));
                    RB.CameraSet(new Vector2i(-4, -4));
                }
                else
                {
                    RB.TintColorSet(Color.white);
                    RB.ShaderReset();
                }

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

                mPaddle.Render();

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

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

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

                mParticles.Render();

                if (renderPass == 0)
                {
                    RB.AlphaSet(255);
                    RB.CameraReset();
                }
            }

            RB.DrawMapLayer(1, new Vector2i(-2, 0));

            mHud.Render();
        }
コード例 #17
0
        /// <summary>
        /// Apply the camera position
        /// </summary>
        public void Apply()
        {
            var game = (RetroDungeoneerGame)RB.Game;

            Vector2i pos = mPos;

            pos.x -= (RB.DisplaySize.width / 2) - (game.assets.spriteSheet.grid.cellSize.width / 2);
            pos.y -= (RB.DisplaySize.height / 2) - (game.assets.spriteSheet.grid.cellSize.height / 2);

            RB.CameraSet(pos);
        }
コード例 #18
0
ファイル: SceneText.cs プロジェクト: svwilke/Spellzee
        private void DrawAlign(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            mDialogStr.Set("\u30B3\u30F3\u30CB\u30C1\u30EF\n@dbab77RetroBlit@- supports\nunicode fonts!");

            var textRect = new Rect2i(2, 12, 96, 48);

            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_LEFT | @[email protected]_V_TOP"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_LEFT | RB.ALIGN_V_TOP, mDialogStr);

            textRect = new Rect2i(112, 12, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_CENTER | @[email protected]_V_TOP"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, mDialogStr);

            textRect = new Rect2i(222, 12, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_RIGHT | @[email protected]_V_TOP"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_RIGHT | RB.ALIGN_V_TOP, mDialogStr);

            textRect = new Rect2i(2, 112, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_LEFT | @[email protected]_V_CENTER"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_LEFT | RB.ALIGN_V_CENTER, mDialogStr);

            textRect = new Rect2i(112, 112, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_CENTER | @[email protected]_V_CENTER"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, mDialogStr);

            textRect = new Rect2i(222, 112, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_RIGHT | @[email protected]_V_CENTER"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_RIGHT | RB.ALIGN_V_CENTER, mDialogStr);

            textRect = new Rect2i(2, 212, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_LEFT | @[email protected]_V_BOTTOM"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_LEFT | RB.ALIGN_V_BOTTOM, mDialogStr);

            textRect = new Rect2i(112, 212, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_CENTER | @[email protected]_V_BOTTOM"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_CENTER | RB.ALIGN_V_BOTTOM, mDialogStr);

            textRect = new Rect2i(222, 212, 96, 48);
            DrawTextFrame(textRect, DemoUtil.HighlightCode(mFormatStr.Set("alignFlags = \n@[email protected]_H_RIGHT | @[email protected]_V_BOTTOM"), mFinalStr));
            RB.Print(textRect, DemoUtil.IndexToRGB(4), RB.ALIGN_H_RIGHT | RB.ALIGN_V_BOTTOM, mDialogStr);

            mFormatStr.Set("@C// Print text within a text rectangle, with specific alignment\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L8@N, @L8@N, @L96@N, @L48@N), alignFlags,\n");
            mFormatStr.Append("   @S\"\u30B3\u30F3\u30CB\u30C1\u30EF\\n@@dbab77RetroBlit@@- supports\\nunicode fonts!\"@N);");

            RB.CameraReset();

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #19
0
        private void DrawTilemap(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

            RB.Offscreen(spriteSheet1);
            RB.SpriteSheetSet(spriteSheet2);
            mWaveOffset = (int)((RB.Ticks / 2) % 16);
            mFishFrame  = (int)((RB.Ticks / 6) % 32);
            RB.DrawCopy(new Rect2i(mWaveOffset, 0, RB.SpriteSheetGet().grid.cellSize), new Vector2i(48, 192));
            RB.Clear(new Color32(0, 0, 0, 0), new Rect2i(80, 192, RB.SpriteSheetGet().grid.cellSize));
            if (mFishFrame < 7)
            {
                RB.DrawCopy(new Rect2i(mFishFrame * RB.SpriteSheetGet().grid.cellSize.width, RB.SpriteSheetGet().grid.cellSize.height, RB.SpriteSheetGet().grid.cellSize), new Vector2i(80, 192));
            }

            RB.Onscreen();

            Rect2i clipRect = new Rect2i(x, y + (RB.DisplaySize.height / 2) - 8, 632, 180);

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

                RB.CameraSet(new Vector2i(0, 0));
                RB.DrawMapLayer(2);
                RB.DrawMapLayer(3);

                RB.TintColorSet(Color.black);
                RB.AlphaSet(32);
                int scrollPos = -(int)RB.Ticks % (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width);
                RB.DrawMapLayer(1, new Vector2i(scrollPos + 8, 8));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width) + 8, 8));
                RB.TintColorSet(Color.white);

                RB.AlphaSet(196);
                RB.DrawMapLayer(1, new Vector2i(scrollPos, 0));
                RB.DrawMapLayer(1, new Vector2i(scrollPos + (mMap.size.width * RB.SpriteSheetGet().grid.cellSize.width), 0));
                RB.AlphaSet(255);

                RB.CameraReset();

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

            RB.DrawRect(clipRect, DemoUtil.IndexToRGB(21));
        }
コード例 #20
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();
        }
コード例 #21
0
        private void DrawOutputScreen(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, EXAMPLE_WIDTH, EXAMPLE_HEIGHT), 4, 2, 22);

            int spriteIndex = ((int)RB.Ticks / 20) % 2;

            RB.DrawSprite(spriteIndex, new Vector2i(120, 64));

            RB.Print(new Vector2i(110, 52), DemoUtil.IndexToRGB(0), "Hi there!");

            RB.CameraReset();
        }
コード例 #22
0
        private void DrawRotate(int x, int y, int spriteIndex)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 17));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 18, 18), -1, mOutputFrame, mOutputBackground);

            RB.DrawSprite(spriteIndex, new Vector2i(1, 1), new Vector2i(8, 8), (RB.Ticks * 4) % 360);

            RB.CameraReset();

            mFormatStr.Set("@C// Rotate sprites around pivot point\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i(@1@N, @L1@N), @Knew @MVector2i@N(@L8@N, @L8@N), @L").Append((RB.Ticks * 4) % 360).Append("@N);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #23
0
        private void DrawTilemap(int x, int y)
        {
            if (mMap == null)
            {
                RB.Print(new Vector2i(x + 2, y + 2), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/TilemapInfinite.tmx in Unity");
                return;
            }

            if (mMap.status != RB.AssetStatus.Ready)
            {
                return;
            }

            var chunkPixelSize = new Vector2i(RB.MapChunkSize.width * mSpriteSheet1.grid.cellSize.width, RB.MapChunkSize.height * mSpriteSheet1.grid.cellSize.height);

            // Figure out which map chunk is in the top left corner of the camera view
            var newTopLeftChunk = new Vector2i(mCameraPos.x / chunkPixelSize.width, mCameraPos.y / chunkPixelSize.height);

            if (newTopLeftChunk != mTopLeftChunk)
            {
                var shift = mTopLeftChunk - newTopLeftChunk;
                RB.MapShiftChunks(0, shift);

                for (int cy = 0; cy <= (mClipRect.height / chunkPixelSize.height) + 1; cy++)
                {
                    for (int cx = 0; cx <= (mClipRect.width / chunkPixelSize.width) + 1; cx++)
                    {
                        var chunkPos = new Vector2i(cx * RB.MapChunkSize.x, cy * RB.MapChunkSize.y);
                        var mapPos   = new Vector2i(newTopLeftChunk.x * RB.MapChunkSize.x, newTopLeftChunk.y * RB.MapChunkSize.y) + chunkPos;
                        mapPos.x = mapPos.x % mMap.size.width;

                        if (RB.MapChunkEmpty(0, chunkPos))
                        {
                            mMap.LoadLayerChunk("Terrain", 0, mapPos, chunkPos);
                        }
                    }
                }

                mTopLeftChunk = newTopLeftChunk;
            }

            mChunkCameraPos = new Vector2i(mCameraPos.x % chunkPixelSize.width, mCameraPos.y % chunkPixelSize.height);

            RB.CameraSet(mChunkCameraPos);
            RB.DrawMapLayer(0, new Vector2i(x + 1, y + 1));
            RB.CameraReset();
        }
コード例 #24
0
        private void DrawGamepad(int x, int y, int playerNum)
        {
            var demo = (DemoReel)RB.Game;

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

            int color1       = playerNum == RB.PLAYER_ONE ? 22 : 15;
            int color2       = playerNum == RB.PLAYER_ONE ? 21 : 14;
            int colorOutline = 0;

            DrawGamepadShoulder(25, -9, "LS", RB.ButtonDown(RB.BTN_LS, playerNum), color2, colorOutline);
            DrawGamepadShoulder(88, -9, "RS", RB.ButtonDown(RB.BTN_RS, playerNum), color2, colorOutline);

            RB.DrawEllipseFill(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1));
            RB.DrawEllipseFill(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(color1));

            RB.DrawEllipse(new Vector2i(26, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(102, 28), new Vector2i(26, 28), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(26, 0, 76, 57), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(26, 1, 76, 55), DemoUtil.IndexToRGB(color1));

#if ABXY_SWITCHED
            DrawGamepadABXY(87, 29, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline);
            DrawGamepadABXY(113, 29, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 16, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 41, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline);
#else
            DrawGamepadABXY(100, 16, "Y", RB.ButtonDown(RB.BTN_Y, playerNum), color2, colorOutline);
            DrawGamepadABXY(100, 41, "A", RB.ButtonDown(RB.BTN_A, playerNum), color2, colorOutline);
            DrawGamepadABXY(87, 29, "X", RB.ButtonDown(RB.BTN_X, playerNum), color2, colorOutline);
            DrawGamepadABXY(113, 29, "B", RB.ButtonDown(RB.BTN_B, playerNum), color2, colorOutline);
#endif

            DrawGamepadMenu(55, 20, RB.ButtonDown(RB.BTN_MENU, playerNum), color2, colorOutline);
            DrawGamepadSystem(57, 37, RB.ButtonDown(RB.BTN_SYSTEM, playerNum), color2, colorOutline);

            DrawGamepadDPad(
                10,
                14,
                (RB.ButtonDown(RB.BTN_UP, playerNum) ? RB.BTN_UP : 0) | (RB.ButtonDown(RB.BTN_DOWN, playerNum) ? RB.BTN_DOWN : 0) | (RB.ButtonDown(RB.BTN_LEFT, playerNum) ? RB.BTN_LEFT : 0) | (RB.ButtonDown(RB.BTN_RIGHT, playerNum) ? RB.BTN_RIGHT : 0),
                color2,
                colorOutline);

            RB.CameraReset();
        }
コード例 #25
0
        private static void RenderUI(Player player, Menu menu)
        {
            var cameraPos = RB.CameraGet();

            RB.CameraReset();

            var barSize = new Vector2i(96, 12);
            var barPos  = new Vector2i(4, 4);

            RenderBar(barPos, barSize, player.Stats[StatTypes.HEALTH], player.Stats[StatTypes.MAX_HEALTH], C.HealthBarFG, C.HealthBarBG);
            RB.Print(new Rect2i(barPos.x, barPos.y, barSize.width, barSize.height), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, $"HP: {player.Stats[StatTypes.HEALTH]}/{player.Stats[StatTypes.MAX_HEALTH]}");

            RenderMessageLog();

            menu?.Render();

            RB.CameraSet(cameraPos);
        }
コード例 #26
0
        private void DrawScrollingClouds()
        {
            SuperFlagRun game = (SuperFlagRun)RB.Game;

            if (game.GameMap == null)
            {
                return;
            }

            int totalMapWidth = game.GameMapSize.width * RB.SpriteSize().width;
            int offset        = (int)(Time.time * 25) % totalMapWidth;

            RB.CameraSet(new Vector2i(offset, 0));
            RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_CLOUDS);

            RB.CameraSet(new Vector2i(offset - totalMapWidth, 0));
            RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_CLOUDS);
        }
コード例 #27
0
        private void DrawCopy(int x, int y, int spriteIndex)
        {
            var demo = (DemoReel)RB.Game;

            RB.CameraSet(new Vector2i(-x, -y - 17));
            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 16, 16), -1, mOutputFrame, mOutputBackground);

            int copySize = (int)((Mathf.Sin(RB.Ticks / 20.0f) * 8) + 9);

            RB.DrawCopy(new Rect2i(0, 0, copySize, copySize), new Vector2i(0, 0));

            RB.CameraReset();

            mFormatStr.Set("@C// Draw rectangular areas from sprite sheet\n");
            mFormatStr.Append("@[email protected](@Knew @MRect2i(@L0@N, @L0@N, @L").Append(copySize).Append("@N, @L").Append(copySize).Append("@N), @Knew @MVector2i@N(@L0@N, @L0@N));");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #28
0
        private void DrawScrollingClouds(int xoffset, int yoffset)
        {
            var game = (SuperFlagRun)RB.Game;

            if (game.GameMap == null)
            {
                return;
            }

            int totalMapWidth = game.GameMapSize.width * RB.SpriteSheetGet().grid.cellSize.width;
            int offset        = (int)(Time.time * 25) % totalMapWidth;

            RB.CameraSet(new Vector2i(xoffset + offset, yoffset));
            RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_CLOUDS);

            RB.CameraSet(new Vector2i(xoffset + offset - totalMapWidth, yoffset));
            RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_CLOUDS);
        }
コード例 #29
0
        private void DrawFontEffects(int x, int y)
        {
            var demo = (DemoReel)RB.Game;

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

            DemoUtil.DrawOutputFrame(new Rect2i(0, 0, 136, 12), -1, mOutputFrame, mOutputBackground);

            mFormatStr.Set("@w243Wavy@w000 and @s1shaky!@s0. Why not @w243@s1both?");

            RB.Print(new Vector2i(0, 3), DemoUtil.IndexToRGB(6), mFormatStr);

            RB.CameraReset();

            mFormatStr.Set("@C// Apply wavy and shaky text effects!\n");
            mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L0@N, @L0@N), @I06@N,\n").Append("   @S\"@s@@w243@SWavy@s@@w000@S and @s@@s1@Sshaky!@s@@s0@S. Why not @s@@w243@@s1@Sboth?\"").Append("@N);");

            RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr));
        }
コード例 #30
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));
        }