Esempio n. 1
0
    private void RenderCard(int xPos, int w, LobbyPlayer player, bool self)
    {
        int topLeftX = xPos - w / 2 + 2;
        int topLeftY = 32;

        RB.DrawRectFill(new Rect2i(topLeftX - 1, topLeftY - 1, new Vector2i(w, size.height - 90)), Color.black);
        RB.DrawRectFill(new Rect2i(topLeftX - 2, topLeftY - 2, new Vector2i(w, size.height - 90)), Color.green);
        RB.DrawRect(new Rect2i(topLeftX, topLeftY, new Vector2i(w - 4, size.height - 94)), Color.gray);
        if (self)
        {
            if (!nameInput.isVisible)
            {
                nameInput.SetText(player.charName);
            }
            readyButton.isVisible     = true;
            nameInput.isVisible       = true;
            prevClassButton.isVisible = true;
            nextClassButton.isVisible = true;
        }
        else
        {
            RB.Print(new Rect2i(topLeftX + 1, topLeftY + 49, w - 4, 12), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName);
            RB.Print(new Rect2i(topLeftX, topLeftY + 48, w - 4, 12), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_TOP, player.charName);
            RB.Print(new Vector2i(xPos - 26, topLeftY + size.height - 115), Color.black, RB.NO_INLINE_COLOR, "Ready?");
            RB.Print(new Vector2i(xPos - 27, topLeftY + size.height - 116), Color.white, "Ready?");
        }

        RB.Print(new Rect2i(topLeftX + 11, topLeftY + 71, w - 24, 20), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName());
        RB.Print(new Rect2i(topLeftX + 10, topLeftY + 70, w - 24, 20), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, DB.Classes[player.charClass].GetName());
        RB.DrawEllipseFill(new Vector2i(xPos + 16, topLeftY - 2 + size.height - 110), new Vector2i(5, 5), Color.black);
        RB.DrawEllipseFill(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), player.ready ? Color.green : Color.red);
        RB.DrawEllipse(new Vector2i(xPos + 15, topLeftY - 3 + size.height - 110), new Vector2i(5, 5), Color.white);
    }
Esempio n. 2
0
    /// <summary>
    /// Render, your drawing code should go here.
    /// </summary>
    public void Render()
    {
        RB.Clear(new Color32(127, 213, 221, 255));

        // Print "Hi there" centered in a rectangular area near the top of the screen
        RB.Print(new Rect2i(0, (RB.DisplaySize.height / 2) - 48, RB.DisplaySize.width, 32), Color.black, RB.ALIGN_H_CENTER, "Hi there!");

        // Draw some ground
        RB.DrawEllipseFill(new Vector2i(RB.DisplaySize.width / 2, RB.DisplaySize.height - 24), new Vector2i(RB.DisplaySize.width / 5 * 4, RB.DisplaySize.height / 2), new Color32(74, 198, 138, 255));

        // Draw character
        var position    = new Vector2i((RB.DisplaySize.width / 2) - (RB.SpriteSize().width / 2), (RB.DisplaySize.height / 2) - 36);
        int spriteIndex = ((int)RB.Ticks / 20) % 2;

        // Draw character shadow
        RB.DrawEllipseFill(position + new Vector2i(RB.SpriteSize().width / 2, RB.SpriteSize().height - 1), new Vector2i(6 + spriteIndex, 2), new Color32(54, 150, 104, 255));

        // Draw a sprite just below
        RB.DrawSprite(spriteIndex, position);

        // Print some more text
        RB.Print(
            new Rect2i(0, (RB.DisplaySize.height / 2) + 12, RB.DisplaySize.width, 64),
            new Color32(35, 101, 71, 255),
            RB.ALIGN_H_CENTER | RB.TEXT_OVERFLOW_WRAP,
            "Now it's @ffffff@w165your@w000@- time to shine!\n\nPlease enjoy@- @ffffffRetroBlit@-! I sincerely hope it inspires, and enables you\nto create the next great retro game!\n" +
            "\nIf you enjoyed @ffffffRetroBlit@-, and would like to continue supporting its development then please share your review on the @ffffffUnity Asset Store@-!" +
            "\n\nThank you!");
    }
Esempio n. 3
0
        private void DrawGamepadABXY(int x, int y, string label, bool pressed, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int faceColor = pressed ? 5 : color;

            RB.DrawEllipseFill(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor));
            RB.DrawEllipse(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline));
            RB.Print(new Vector2i(x - 2, y - 3), DemoUtil.IndexToRGB(colorOutline), label);
        }
Esempio n. 4
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();
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        private static void RenderTrail(EntityID entity)
        {
            var moveTrail = entity.e.moveTrail;

            RB.TintColorSet(Color.white);

            for (int i = 0; i < moveTrail.trail.Count; i++)
            {
                var t = moveTrail.trail[i];
                RB.AlphaSet(t.fade);
                RB.DrawEllipseFill(t.pos + new Vector2i(RB.SpriteSize(0).width / 2, RB.SpriteSize(0).height / 2), new Vector2i(2, 2), Color.white);
            }

            RB.AlphaSet(255);
        }
        private static void RenderTrail(EntityID entity)
        {
            var game      = (RetroDungeoneerGame)RB.Game;
            var moveTrail = entity.e.moveTrail;

            RB.TintColorSet(Color.white);

            for (int i = 0; i < moveTrail.trail.Count; i++)
            {
                var t = moveTrail.trail[i];
                RB.AlphaSet(t.fade);
                RB.DrawEllipseFill(t.pos + new Vector2i(game.assets.spriteSheet.grid.cellSize.width / 2, game.assets.spriteSheet.grid.cellSize.height / 2), new Vector2i(2, 2), Color.white);
            }

            RB.AlphaSet(255);
        }
Esempio n. 8
0
    public override void RenderForeground()
    {
        for (int i = 0; i < battle.rolls.Length; i++)
        {
            if (battle.locks[i])
            {
                RB.DrawSprite("Lock", lockPositions[i] - new Vector2i(6, 6));
                //RB.Print(new Rect2i(lockPositions[i] - new Vector2i(16, 8), new Vector2i(32, 16)), Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, "Locked");
            }
        }

        for (int i = 0; i < battle.rollsLeft; i++)
        {
            RB.DrawEllipseFill(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.white);
            RB.DrawEllipse(new Vector2i(size.x / 5 - 10 + i * 10, size.y / 2 + 44), new Vector2i(4, 4), Color.black);
        }

        if (infoPane.GetOpenTabIndex() == 1)
        {
            ElementDisplay[] displays = viewedSpell.GetElementDisplays(battle.BuildContext());
            for (int i = 0; i < displays.Length; i++)
            {
                displays[i].Render(size.width / 2 + 5 + i * 18, size.height - 50);
            }
        }

        if (renderTargeting)
        {
            if (targetPawn != null)
            {
                RB.AlphaSet(96);
                RB.DrawRectFill(new Rect2i(0, 0, size), Color.black);
                RB.AlphaSet(255);
                pawnCards[targetPawn].Render();
                RB.DrawRect(targetRect, Color.yellow);
                RB.DrawPixel(targetPoint - new Vector2i(1, 0), Color.white);
                //RB.DrawRect(targetRect.Offset(new Vector2i(0, 0)).Expand(1), Color.black);
                originButton.Render();
            }
            RB.DrawPixel(originPoint + new Vector2i(1, 0), Color.white);
            //RB.DrawRect(new Rect2i(originButton.pos, originButton.size).Expand(2), Color.black);
            RB.DrawLine(originPoint + new Vector2i(0, 1), targetPoint + new Vector2i(0, 1), Color.yellow);
            RB.DrawLine(originPoint, targetPoint, Color.white);
            RB.DrawLine(originPoint - new Vector2i(0, 1), targetPoint - new Vector2i(0, 1), Color.yellow);
        }
    }
Esempio n. 9
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();
        }
Esempio n. 10
0
        private void DrawGamepadSystem(int x, int y, bool pressed, int color, int colorOutline)
        {
            var demo = (DemoReel)RB.Game;

            int faceColor = pressed ? 5 : color;

            RB.DrawEllipseFill(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor));
            RB.DrawEllipseFill(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(faceColor));

            RB.DrawEllipse(new Vector2i(x, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawEllipse(new Vector2i(x + 6, y), new Vector2i(7, 7), DemoUtil.IndexToRGB(colorOutline));
            RB.DrawRect(new Rect2i(x - 1, y - 7, 10, 15), DemoUtil.IndexToRGB(colorOutline));

            RB.DrawRectFill(new Rect2i(x - 1, y - 6, 10, 13), DemoUtil.IndexToRGB(faceColor));

            RB.Print(new Vector2i(x - 4, y - 3), DemoUtil.IndexToRGB(colorOutline), "SYS");
        }
Esempio n. 11
0
        /// <summary>
        /// Run the stress test
        /// </summary>
        protected override void StressTest()
        {
            Random.InitState(0);

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

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

            // Generate texture on first offscreen surface
            for (int i = 0; i < 64; i++)
            {
                int radius = Random.Range(2, 5);
                RB.DrawEllipseFill(
                    new Vector2i(Random.Range(-4, 36), Random.Range(-4, 36)),
                    new Vector2i(radius, radius),
                    mRandomColor[i]);
            }

            // Copy the generate texture mirrored on second offscreen surface
            RB.Offscreen(3);
            RB.SpriteSheetSet(2);
            RB.DrawCopy(new Rect2i(0, 0, 32, 32), Vector2i.zero, RB.FLIP_H | RB.FLIP_V);

            RB.Onscreen();

            for (int i = 0; i < mStressLevel; i++)
            {
                var randPos = mRandomPos[i];
                randPos += GetWiggle();

                // Draw half the sprites from offscreen 0 and half from 1.
                int offscreen = 2;
                if (i >= mStressLevel / 2)
                {
                    offscreen = 3;
                }

                RB.SpriteSheetSet(offscreen);
                RB.DrawCopy(new Rect2i(0, 0, 32, 32), randPos);
            }
        }
        /// <summary>
        /// Run the stress test
        /// </summary>
        protected override void StressTest()
        {
            Random.InitState(0);

            for (int i = 0; i < mStressLevel; i++)
            {
                var randPos = mRandomPos[i];
                randPos += GetWiggle();

                int type = mRandomColor[i].r % 2;
                if (type == 0)
                {
                    RB.DrawEllipse(randPos, mRandomRadius[i], mRandomColor[i]);
                }
                else if (type == 1)
                {
                    RB.DrawEllipseFill(randPos, mRandomRadius[i], mRandomColor[i]);
                }
            }
        }
Esempio n. 13
0
        /// <summary>
        /// Render the effect
        /// </summary>
        public override void Render()
        {
            var game = (RetroDungeoneerGame)RB.Game;

            var cameraPos = RB.CameraGet();

            var portalClipRect = new Rect2i(mPortal.e.pos.x * game.assets.spriteSheet.grid.cellSize.width, mPortal.e.pos.y * game.assets.spriteSheet.grid.cellSize.height, game.assets.spriteSheet.grid.cellSize.width, game.assets.spriteSheet.grid.cellSize.height);

            portalClipRect.x -= cameraPos.x;
            portalClipRect.y -= cameraPos.y;

            float rise = Ease.Interpolate(Ease.Func.QuadOut, 0.0f, 1.0f, mRiseTime);

            var portalPos    = new Vector2i(mPortal.e.pos.x * game.assets.spriteSheet.grid.cellSize.width, (mPortal.e.pos.y + (1.0f - rise)) * game.assets.spriteSheet.grid.cellSize.height);
            var portalCenter = new Vector2i(portalPos.x + (game.assets.spriteSheet.grid.cellSize.width / 2), (mPortal.e.pos.y * game.assets.spriteSheet.grid.cellSize.height) + game.assets.spriteSheet.grid.cellSize.height - 2);

            if (Random.Range(0, 10) == 0)
            {
                mShrinkLight = mShrinkLight == 0 ? 1 : 0;
            }

            var outerLightSize = new Vector2i((game.assets.spriteSheet.grid.cellSize.width * 2 * 0.8f) - mShrinkLight, (game.assets.spriteSheet.grid.cellSize.height * 0.8f) - mShrinkLight);
            var innerLightSize = new Vector2i((game.assets.spriteSheet.grid.cellSize.width * 2 * 0.5f) - mShrinkLight, (game.assets.spriteSheet.grid.cellSize.height * 0.5f) - mShrinkLight);

            outerLightSize *= rise;
            innerLightSize *= rise;

            RB.DrawEllipseFill(portalCenter, outerLightSize, new Color32(255, 255, 255, 32));
            RB.DrawEllipseFill(portalCenter, innerLightSize, new Color32(255, 255, 255, 32));

            if (mRiseTime != 1.0f)
            {
                Color32 color = new Color32(0x3c, 0xac, 0xd7, 255);

                RB.TintColorSet(color);

                RB.ClipSet(portalClipRect);
                RB.DrawSprite(S.PORTAL, portalPos);
                RB.ClipReset();
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Render the effect
        /// </summary>
        public override void Render()
        {
            RB.TintColorSet(Color.white);

            var landingCenter = new Vector2i(mLandingPos.x + (RB.SpriteSize(0).width / 2), mLandingPos.y + RB.SpriteSize(0).height);

            if (Random.Range(0, 10) == 0)
            {
                mShrinkLight = mShrinkLight == 0 ? 1 : 0;
            }

            RB.DrawEllipseFill(landingCenter, new Vector2i((RB.SpriteSize(0).width * 2 * 0.8f) - mShrinkLight, (RB.SpriteSize(0).height * 0.8f) - mShrinkLight), new Color32(255, 255, 255, 32));
            RB.DrawEllipseFill(landingCenter, new Vector2i((RB.SpriteSize(0).width * 2 * 0.5f) - mShrinkLight, (RB.SpriteSize(0).height * 0.5f) - mShrinkLight), new Color32(255, 255, 255, 32));

            var renderPos = Ease.Interpolate(Ease.Func.QuarticIn, mStartPos, mLandingPos, mFallProgress > 1.0f ? 1.0f : mFallProgress);

            if (mStage < 4)
            {
                RB.DrawSprite(mStage == 3 ? S.HERO_RECOVERING : S.HERO_FALLING, renderPos);
            }
        }
Esempio n. 15
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));
        }
Esempio n. 16
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();
        }
Esempio n. 17
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();
        }
Esempio n. 18
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();
        }