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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
/// <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); }
private void DrawCode(int x, int y) { var demo = (DemoReel)RB.Game; mFormatStr.Set("@C// Load infinite TMX maps chunk by chunk to create maps of any size!@N\n"); mFormatStr.Append("@Kvar@N chunkPixelSize = @Knew@N @MVector2i@N(@[email protected] * @[email protected](@L0@N).width, @[email protected] * @[email protected](@L0@N).height);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Figure out which map chunk is in the top left corner of the camera view@N\n"); mFormatStr.Append("@Kvar@N newTopLeftChunk = @Knew@N @MVector2i@N(mCameraPos.x / chunkPixelSize.width, mCameraPos.y / chunkPixelSize.height);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Check if the camera moved enough so that the top left chunk has changed, if so then we need to shift the map and load a new chunk.@N\n"); mFormatStr.Append("@Kif@N (newTopLeftChunk != mTopLeftChunk) {\n"); mFormatStr.Append(" @[email protected](@L0@N, mTopLeftChunk - newTopLeftChunk);\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @C// After shifting loop through all potentially visible chunks and load any that are now empty.@N\n"); mFormatStr.Append(" @Kfor@N (@Kint@N cx = @L0@N; cx <= @[email protected] / chunkPixelSize.width + @L1@N; cx++) {\n"); mFormatStr.Append(" @Kvar@N chunkPos = @Knew@N @MVector2i@N(cx * RB.MapChunkSize.x, cy * RB.MapChunkSize.y);\n"); mFormatStr.Append(" @Kvar@N mapPos = @Knew@N @MVector2i@N(newTopLeftChunk.x * RB.MapChunkSize.x, newTopLeftChunk.y * RB.MapChunkSize.y) + chunkPos;\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @Kif@N (@[email protected](@L0@N, chunkPos)) {\n"); mFormatStr.Append(" @[email protected](mMap, @S\"Terrain\"@N, @L0@N, mapPos, chunkPos);\n"); mFormatStr.Append(" }\n"); mFormatStr.Append(" }\n"); mFormatStr.Append("\n"); mFormatStr.Append(" mTopLeftChunk = newTopLeftChunk;\n"); mFormatStr.Append("}\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@Knew@N @MVector2i@N(mCameraPos.x % chunkPixelSize.width, mCameraPos.y % chunkPixelSize.height));\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); int width = 96 + 13 - 32 + 21; int height = 48 + 16 - 16; int x = 8; int y = 48; int columns = 0; // Skip linear, boring for (int i = 1; i < mFuncNames.Length; i++) { DrawEase((Ease.Func)i, mFuncNames[i], x, y, width, height); x += width + 8; columns++; if (columns >= 6) { x = 6; y += height + 16; columns = 0; } } DrawCode(4, 4); }
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); }
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(); }
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(); }
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)); }
/// <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); }
private void DrawOffscreen(int x, int y) { var demo = (DemoReel)RB.Game; Vector2i textSize = RB.PrintMeasure(mText); RB.Offscreen(2); RB.Clear(new Color32(0, 0, 0, 0)); RB.DrawNineSlice(new Rect2i(0, 0, textSize.width + 12, textSize.height + 12), new Rect2i(80, 0, 8, 8), new Rect2i(88, 0, 8, 8), new Rect2i(96, 0, 16, 16)); RB.Print(new Vector2i(6, 6), DemoUtil.IndexToRGB(23), mText); RB.Onscreen(); RB.SpriteSheetSet(2); RB.DrawCopy(new Rect2i(0, 0, textSize.width + 12, textSize.height + 12), new Rect2i(x, y + 165, textSize.width + 12, textSize.height + 12), new Vector2i((textSize.width + 12) / 2, (textSize.height + 12) / 2), RB.Ticks); RB.SpriteSheetSet(0); mFormatStr.Set("@C// Draw to offscreen surface and copy to screen\n"); mFormatStr.Append("@MVector2i @Nsize = @[email protected](textStr);\n"); mFormatStr.Append("@[email protected](0);\n"); mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L0@N, @L0@N, size.width + @L12@N, size.height + @L12@N),\n"); mFormatStr.Append(" @Knew @MRect2i@N(@L80@N, @L0@N, @L8@N, @L8@N), @Knew @MRect2i@N(@L88@N, @L0@N, @L8@N, @L8@N),\n"); mFormatStr.Append(" @Knew @MRect2i@N(@L96@N, @L0@N, @L16@N, @L16@N));\n"); mFormatStr.Append("@[email protected](@Knew @MVector2i@N(@L4@N, @L4@N), @I22@N, textStr);\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected](0, \n"); mFormatStr.Append(" @Knew@M Rect2i@N(@L0@N, @L0@N, size.width + @L7@N, size.height + @L8@N),\n"); mFormatStr.Append(" @Knew@M Rect2i@N(@L").Append(x).Append("@N, @L").Append(y + 165).Append("@N, size.width + @L8@N, size.height + @L8@N),\n"); mFormatStr.Append(" @Knew@M Vector2i@N(size.width / @L2@N, size.height / @L2@N), @L").Append(RB.Ticks % 360).Append("@N);\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
private void DrawOutput(int x, int y) { var demo = (DemoReel)RB.Game; RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), "Output:"); DrawOutputScreen(x, y + 10); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); DrawTMX(4, 4); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); int spriteIndex = (RB.Ticks % 40) > 20 ? 1 : 0; int x = 4; int y = 4; DrawSprite(x, y, spriteIndex); y += 38; DrawScale(x, y, spriteIndex); y += 64; DrawCopy(x, y, spriteIndex); y += 40; DrawRotate(x, y, spriteIndex); y += 43; DrawTint(x, y, spriteIndex); y += 72; DrawAlpha(x, y, spriteIndex); y += 58; DrawSystemFont(x, y); x = 300; y = 4; DrawFontEffects(x, y); y += 42; DrawCustomFont(x, y); y += 60; DrawPixels(x, y); y += 59; DrawShapes(x, y); y += 100; DrawLines(x, y); }
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)); }
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)); }
private void DrawDesc(int x, int y) { var demo = (DemoReel)RB.Game; mFormatStr.Set(mDesc); DemoUtil.HighlightCode(mFormatStr, mFinalStr); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), mFinalStr); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(22)); int spriteFrame = ((int)RB.Ticks % 40) > 20 ? 1 : 0; if (mMap != null) { RB.DrawMapLayer(0); RB.DrawMapLayer(1); } RB.EffectSet(RB.Effect.Noise, 0.15f); RB.EffectSet(RB.Effect.Scanlines, 1.0f); RB.EffectSet(RB.Effect.Desaturation, (Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f); RB.EffectApplyNow(); RB.EffectReset(); if (mMap != null) { RB.DrawSprite(0 + spriteFrame, new Vector2i(13 * 16, 16 * 16)); } 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"); } mFormatStr.Set("@C// Specify when post-processing effects should be applied\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L0.15f@N);\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L1.0f@N);\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected], @L").Append((Mathf.Sin(RB.Ticks / 50.0f) * 0.5f) + 0.5f, 2).Append("f@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@L").Append(0 + spriteFrame).Append("@N, @Knew@N Vector2i(@L").Append(13 * 16).Append("@N, @L").Append(16 * 16).Append("@N));"); var size = RB.PrintMeasure(DemoUtil.HighlightCode(mFormatStr, mFinalStr)); size.x += 4; size.y += 4; var rect = new Rect2i((RB.DisplaySize.width / 2) - (size.x / 2), (RB.DisplaySize.height / 2) - (size.y / 2), size.x, size.y); rect.y -= 64; RB.DrawRectFill(rect, DemoUtil.IndexToRGB(1)); RB.DrawRect(rect, DemoUtil.IndexToRGB(4)); RB.Print(new Vector2i(rect.x + 2, rect.y + 2), DemoUtil.IndexToRGB(0), mFinalStr); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); DrawTilemap(4, 4); DrawCode(4, 4); DrawSpriteSheet(516, 12); }
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); }
private void DrawCode(int x, int y) { var demo = (DemoReel)RB.Game; mFormatStr.Set("@C// Interpolate between integers, floats, colors, vectors, and more using RetroBlit easing functions!\n"); mFormatStr.Append("@Kint@N num = @[email protected](@MEase@N.@[email protected], @L10@N, @L20@N, @L0.5f@N);\n"); mFormatStr.Append("@KColor@N color = @[email protected](@MEase@N.@[email protected], @[email protected], @[email protected], @L0.75f@N);\n"); mFormatStr.Append("@KVector2i@N vec = @[email protected](@MEase@N.@[email protected], @Knew@N @MVector2i@N(@L0@N, @L0@N), @Knew@N @MVector2i@N(@L-5@N, @L-8@N), @L0.33f@N);\n"); mFormatStr.Append("@KRect2i@N rect = @[email protected](@MEase@N.@[email protected], @Knew@N @MRect2i@N(@L5@N, @L5@N, @L10@N, @L10@N), @Knew@N @MRect2i@N(@L0@N, @L0@N, @L5@N, @L5@N), @L0.1f@N);\n"); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); }
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)); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); int x = 4; int y = 4; DrawClip(x, y); DrawOffscreen(x + 320, y); }
private void DrawCode(int x, int y) { var demo = (DemoReel)RB.Game; RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), "Source code:"); RB.DrawRectFill(new Rect2i(x, y + 10, 315, 270), DemoUtil.IndexToRGB(1)); mFormatStr.Set(mMarkedUpCode); DemoUtil.HighlightCode(mFormatStr, mFinalStr); RB.Print(new Vector2i(x + 4, y + 14), DemoUtil.IndexToRGB(5), mFinalStr); }
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(); }
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)); }