/// <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!"); }
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)); }
/// <summary> /// Render /// </summary> public void Render() { RB.Clear(Color.black); RB.Print(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), Color.white, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, "@w3Old Days"); RB.Print(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), Color.white, 0, "@w3Older Days"); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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 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)); }
/// <summary> /// Render, your drawing code should go here. /// </summary> public void Render() { RB.Clear(new Color32(24, 17, 7, 255)); if (mState == GameState.MAIN_MENU) { mMainMenu.Render(); } else if (mState == GameState.LEVEL) { mLevel.Render(); } }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); int x = 4; int y = 12; DrawCode(x, y); DrawFire(); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(0)); int x = 4; int y = 12; DrawAlign(x, y); x += 335; DrawClip(x, y); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); if (mBadSpritepack) { DrawBadSpritepack(4, 4); return; } DrawSpritePacking(4, 4); DrawTMX(310, 4); }
private void StartExecAD() { btnClear.Enabled = false; lblError.Text = "0"; RB.Clear(); //获取数据库名称 string dbName = cmbDB.Text; string dbPath = txtPath.Text + "\\" + dbName; if (!Directory.Exists(dbPath)) { MessageBox.Show("没有需要处理得数据"); return; } DirectoryInfo TheFolder = new DirectoryInfo(dbPath); Thread.Sleep(100); System.Windows.Forms.Application.DoEvents(); RB.AppendText("【" + DateTime.Now.ToString() + "】扫描中..." + "\n"); foreach (var item in TheFolder.GetDirectories()) { Thread.Sleep(100); System.Windows.Forms.Application.DoEvents(); string fileid = item.Name; getFileID(item); } lblFileCount.Text = fileList.Count.ToString(); RB.AppendText("【" + DateTime.Now.ToString() + "】扫描完毕,开始整理垃圾数据...,这可能需要几分钟,请耐心等待..." + "\n"); foreach (var item in fileList) { Thread.Sleep(100); System.Windows.Forms.Application.DoEvents(); string path = Path.GetDirectoryName(item); string id = path.Substring(path.LastIndexOf(cmbDB.Text) + cmbDB.Text.Length).Replace("\\", ""); Item fileItem = inn.getItemById("File", id); if (fileItem.getItemCount() != 1) { ErrorfileIdList.Add(item); lblError.Text = ErrorfileIdList.Count.ToString(); RB.AppendText("【" + DateTime.Now.ToString() + "】无效文件" + item + "\n"); } fileIdList.Add(id); } RB.AppendText("【" + DateTime.Now.ToString() + "】整理完毕" + "\n"); btnClear.Enabled = true; }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); DrawNoisePad(4, 4); DrawPiano(4, 200); DrawMusicPlayer(350, 4); mNextButton.Render(); mPrevButton.Render(); if (RB.PointerPosValid()) { RB.DrawSprite(4, RB.PointerPos()); } }
/// <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> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(0)); DrawDesc(4, 4); DrawCode(4, 77); DrawOutput(350, 77); int color = 3; if ((RB.Ticks % 200 > 170 && RB.Ticks % 200 < 180) || (RB.Ticks % 200) > 190) { color = 5; } RB.Print(new Vector2i(390, 300), DemoUtil.IndexToRGB(color), "LEFT CLICK or TOUCH the screen to move to\nthe next screen, RIGHT CLICK or TOUCH with\nTWO fingers to move to previous screen."); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); if (spriteSheet1.status == RB.AssetStatus.Failed) { DrawBadSpritepack(4, 4); return; } if (!mSpritePackPostLoadDone) { return; } DrawSpritePacking(4, 4); DrawTMX(310, 4); }
public void Render() { RB.EffectApplyNow(); RB.EffectSet(RB.Effect.Noise, .2F); RB.Clear(background); RB.EffectSet(RB.Effect.Noise, 0F); if (currentScreen != null) { currentScreen.Render(); } if (message.Length > 0) { RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.x, RB.DisplaySize.y), Color.Lerp(Color.black, Color.clear, 0.5F)); Vector2i msgSize = RB.PrintMeasure(message); Rect2i msgRect = new Rect2i(RB.DisplaySize.x / 2 - msgSize.x / 2, RB.DisplaySize.y / 2 - msgSize.y / 2, msgSize.x, msgSize.y).Expand(2); RB.DrawRectFill(msgRect, Color.white); RB.DrawRect(msgRect, Color.black); RB.Print(msgRect, Color.black, RB.ALIGN_H_CENTER | RB.ALIGN_V_CENTER, message); } }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); int x = 4; int y = 4; DrawCode(x, y); x += 76; y += 200; DrawSpriteSheet(x, y); y += mSpriteSheet.sheetSize.height + 16; DrawSound(x, y); }
/// <summary> /// Render /// </summary> public override void Render() { RB.Clear(Color.black); StressTest(); Overlay(); if (RB.DisplaySize.width < 600) { return; } for (int i = 0; i < mButtons.Count; i++) { mButtons[i].Render(); } mFrameDelta = Time.time - mPreviousFrame; mPreviousFrame = Time.time; if (mFrameDelta > 0) { mFPSSlots[mFPSSlot] = 1.0f / mFrameDelta; mFPSSlot++; if (mFPSSlot >= mFPSSlots.Length) { mFPSSlot = 0; float fpsTotal = 0; for (int i = 0; i < mFPSSlots.Length; i++) { fpsTotal += mFPSSlots[i]; } mFPS = fpsTotal / mFPSSlots.Length; } } }
/// <summary> /// Render, your drawing code should go here. /// </summary> public void Render() { RB.Clear(new Color32(127, 213, 221, 255)); Camera.placeCamera(mainCharacter, curMap); curMap.drawMap(new Vector2i(0, 0)); // 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)); mainCharacter.draw(); // 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!"); **/ }
private void DrawMusicPlayer(int x, int y) { var demo = (DemoReel)RB.Game; RB.Offscreen(mSpriteSheet2); RB.Clear(new Color32(0, 0, 0, 0)); int spinnerSize = 32; RB.DrawRectFill(new Rect2i(spinnerSize / 4, spinnerSize - 2, (spinnerSize / 2) - 2, 5), DemoUtil.IndexToRGB(1)); RB.DrawRectFill(new Rect2i(spinnerSize + (spinnerSize / 4) + 3, spinnerSize - 2, (spinnerSize / 2) - 2, 5), DemoUtil.IndexToRGB(1)); RB.DrawRectFill(new Rect2i(spinnerSize - 2, spinnerSize / 4, 5, (spinnerSize / 2) - 2), DemoUtil.IndexToRGB(1)); RB.DrawRectFill(new Rect2i(spinnerSize - 2, spinnerSize + (spinnerSize / 4) + 3, 5, (spinnerSize / 2) - 2), DemoUtil.IndexToRGB(1)); RB.Onscreen(); RB.CameraSet(new Vector2i(-x, -y)); mFormatStr.Set("@C// Load music and play it\n"); mFormatStr.Append("@NdemoMusic.Load(@S\"Demos/Demo/Music\"@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@Kif@N (@[email protected](@[email protected]) {\n"); mFormatStr.Append(" @[email protected](demoMusic);\n"); mFormatStr.Append("} @Kelse if@N (@[email protected](@[email protected]) {\n"); mFormatStr.Append(" @[email protected]();\n"); mFormatStr.Append("}"); RB.Print(new Vector2i(0, 0), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); RB.CameraSet(new Vector2i(-x, -y - 80)); int cornerSize = 8; var deckRect = new Rect2i(20, 40, 145, 100); RB.DrawEllipseFill(new Vector2i(deckRect.x + cornerSize, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(deckRect.x + cornerSize, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(deckRect.x + cornerSize, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(deckRect.x + cornerSize, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawEllipseFill(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(3)); RB.DrawEllipse(new Vector2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + deckRect.height - cornerSize - 1), new Vector2i(cornerSize, cornerSize), DemoUtil.IndexToRGB(2)); RB.DrawRect(new Rect2i(deckRect.x + cornerSize, deckRect.y, deckRect.width - (cornerSize * 2), deckRect.height), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(deckRect.x + cornerSize, deckRect.y + 1, deckRect.width - (cornerSize * 2), deckRect.height - 2), DemoUtil.IndexToRGB(3)); RB.DrawRect(new Rect2i(deckRect.x, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(deckRect.x + 1, deckRect.y + cornerSize, cornerSize - 1, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3)); RB.DrawRect(new Rect2i(deckRect.x + deckRect.width - cornerSize, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(2)); RB.DrawRectFill(new Rect2i(deckRect.x + deckRect.width - cornerSize - 1, deckRect.y + cornerSize, cornerSize, deckRect.height - (cornerSize * 2)), DemoUtil.IndexToRGB(3)); DrawSpinner(0, 0, spinnerSize); DrawSpinner(120, 0, spinnerSize); mMusicPlayButton.Render(); RB.CameraReset(); }
/// <summary> /// Render /// </summary> public override void Render() { RB.Clear(new Color32(127, 213, 221, 255)); var game = (SuperFlagRun)RB.Game; if (game.GameMap == null) { RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load game TMX map.\nPlease try re-importing the map Demos/SuperFlagRun/GameMap.tmx in Unity"); return; } // Draw Player One view RB.CameraReset(); Vector2i cameraOffset; if (!game.SinglePlayer) { RB.ClipSet(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height / 2)); cameraOffset = GetCameraOffset(mPlayerOne); } else { cameraOffset = GetCameraOffset(mPlayerOne); cameraOffset.y -= RB.DisplaySize.height / 2; } RB.CameraSet(new Vector2i((int)cameraOffset.x, (int)cameraOffset.y)); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_SKY); DrawScrollingClouds((int)cameraOffset.x, (int)cameraOffset.y); RB.CameraSet(new Vector2i((int)cameraOffset.x, (int)cameraOffset.y)); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_BACKGROUND); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_TERRAIN); if (mWinningPlayer == 0) { mFlagOneSlot.Render(); } mFlagOne.Render(); mFlagTwo.Render(); mPlayerTwo.Render(); mPlayerOne.Render(); // Draw Castles RB.DrawCopy(new Rect2i(0, 64, 48, 64), new Vector2i(16, RB.SpriteSheetGet().grid.cellSize.height * 26)); RB.DrawCopy(new Rect2i(80, 64, 48, 64), new Vector2i((RB.SpriteSheetGet().grid.cellSize.width *LEVEL_WIDTH) - 64, RB.SpriteSheetGet().grid.cellSize.height * 26), 0); if (!game.SinglePlayer) { // Draw Player Two view RB.ClipSet(new Rect2i(0, RB.DisplaySize.height / 2, RB.DisplaySize.width, RB.DisplaySize.height / 2)); cameraOffset = GetCameraOffset(mPlayerTwo); RB.CameraSet(new Vector2i((int)cameraOffset.x, (int)cameraOffset.y - (RB.DisplaySize.height / 2))); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_SKY); DrawScrollingClouds((int)cameraOffset.x, (int)cameraOffset.y - (RB.DisplaySize.height / 2)); cameraOffset = GetCameraOffset(mPlayerTwo); RB.CameraSet(new Vector2i((int)cameraOffset.x, (int)cameraOffset.y - (RB.DisplaySize.height / 2))); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_BACKGROUND); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_TERRAIN); if (mWinningPlayer == 0) { mFlagTwoSlot.Render(); } mFlagOne.Render(); mFlagTwo.Render(); mPlayerOne.Render(); mPlayerTwo.Render(); // Draw Castles RB.DrawCopy(new Rect2i(0, 64, 48, 64), new Vector2i(16, RB.SpriteSheetGet().grid.cellSize.height * 26)); RB.DrawCopy(new Rect2i(80, 64, 48, 64), new Vector2i((RB.SpriteSheetGet().grid.cellSize.width *LEVEL_WIDTH) - 64, RB.SpriteSheetGet().grid.cellSize.height * 26), 0); RB.ClipReset(); RB.CameraReset(); // Draw divider for (int x = 0; x < RB.DisplaySize.width; x += 16) { RB.DrawSprite(RB.SpriteIndex(0, 0), new Vector2i(x, (RB.DisplaySize.height / 2) - 4)); } } RB.ClipReset(); RB.CameraReset(); if (mWinningPlayer != 0) { string playerOneStr = "LOSER"; string playerTwoStr = "WINNER"; if (mWinningPlayer == RB.PLAYER_ONE) { playerOneStr = "WINNER"; playerTwoStr = "LOSER"; } int textOffsetX = (int)(Mathf.Cos(Time.time * 6.0f) * 8); int textOffsetY = (int)(Mathf.Sin(Time.time * 6.0f) * 5); Vector2i textSize; string text = playerOneStr; textSize = RB.PrintMeasure(game.assets.gameFont, text); RB.Print(game.assets.gameFont, new Vector2i((RB.DisplaySize.width / 2) - (textSize.width / 2) + textOffsetX, (RB.DisplaySize.height / 4) - (textSize.height / 2) + textOffsetY), Color.white, text); text = playerTwoStr; textSize = RB.PrintMeasure(game.assets.gameFont, text); RB.Print(game.assets.gameFont, new Vector2i((RB.DisplaySize.width / 2) - (textSize.width / 2) + textOffsetX, (RB.DisplaySize.height / 4 * 3) - (textSize.height / 2) + textOffsetY), Color.white, text); } // Let base render last so it can overlay the scene base.Render(); }
/// <summary> /// Render /// </summary> public override void Render() { RB.Clear(new Color32(127, 213, 221, 255)); RB.CameraReset(); SuperFlagRun game = (SuperFlagRun)RB.Game; if (game.TitleMap == null) { RB.Print(new Vector2i(2, 2), DemoUtil.IndexToRGB(14), "Failed to load title TMX map.\nPlease try re-importing the map Demos/SuperFlagRun/TitleMap.tmx in Unity"); return; } RB.CameraSet(new Vector2i(RB.SpriteSize().width, 0)); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_TITLE_SKY); DrawScrollingClouds(); RB.CameraSet(new Vector2i(RB.SpriteSize().width, RB.SpriteSize().height * 12)); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_TITLE_DECO); RB.DrawMapLayer(SuperFlagRun.MAP_LAYER_TITLE_TERRAIN); RB.CameraSet(new Vector2i(RB.SpriteSize().width, -RB.SpriteSize().height * 7)); // Draw Flags mFlagOne.Render(); mFlagTwo.Render(); // Draw Players int x = (RB.SpriteSize().width * 3) + 8; int y = RB.SpriteSize().height * 3; RB.DrawSprite(RB.SpriteIndex(0, 2), new Vector2i(x, y), 0); RB.DrawSprite(RB.SpriteIndex(0, 3), new Vector2i(x, y + RB.SpriteSize().height), 0); x = RB.DisplaySize.width - (RB.SpriteSize().width * 2) - 8; RB.DrawSprite(RB.SpriteIndex(5, 2), new Vector2i(x, y), RB.FLIP_H); RB.DrawSprite(RB.SpriteIndex(5, 3), new Vector2i(x, y + RB.SpriteSize().height), RB.FLIP_H); // Draw Castles RB.DrawCopy(new Rect2i(0, 64, 48, 64), new Vector2i(RB.SpriteSize().width * 2, RB.SpriteSize().height * 4)); RB.DrawCopy(new Rect2i(80, 64, 48, 64), new Vector2i(RB.DisplaySize.width - (RB.SpriteSize().width * 3), RB.SpriteSize().height * 4), 0); // Draw Title RB.CameraReset(); RB.SpriteSheetSet(SuperFlagRun.SPRITESHEET_TITLE); byte tint = (byte)((Mathf.Sin(Time.time * 2) * 60) + 196); RB.TintColorSet(new Color32(tint, tint, tint, 255)); RB.DrawCopy(new Rect2i(0, 0, 323, 103), new Vector2i((RB.DisplaySize.width / 2) - (323 / 2), (int)(Mathf.Sin(Time.time * 2) * 6) + 15)); RB.TintColorSet(Color.white); RB.SpriteSheetSet(SuperFlagRun.SPRITESHEET_SPRITES); // Draw Press Any Button string str = "PRESS ANY BUTTON"; Vector2i textSize = RB.PrintMeasure(SuperFlagRun.GAME_FONT, str); RB.Print(SuperFlagRun.GAME_FONT, new Vector2i((RB.DisplaySize.width / 2) - (textSize.width / 2), (int)(RB.DisplaySize.height * 0.55f)), Color.white, str); RB.Print(new Vector2i(2, RB.DisplaySize.height - 9), Color.black, "RetroBlit technical demo game"); // Let base render last so it can overlay the scene base.Render(); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; if (mMap != null) { RB.Clear(DemoUtil.IndexToRGB(22)); RB.DrawMapLayer(0); RB.DrawMapLayer(1); } else { RB.Print(new Vector2i(2, 210), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity"); } RB.EffectShader(0); RB.ShaderFloatSet(0, "Wave", RB.Ticks / 25.0f); RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, 200), DemoUtil.IndexToRGB(1)); string shaderName = "PresentRippleShader"; mFormatStr.Set("@C// Custom post-processing shader\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"Demos/DemoReel/").Append(shaderName).Append("\"@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"Wave\"@N, @L").Append(RB.Ticks / 25.0f, 2).Append("f@N);\n"); mFormatStr.Append("@[email protected](@MRB@N.@[email protected]);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected]();\n"); DemoUtil.HighlightCode(mFormatStr, mCodeStr); mFormatStr.Set("@C// This shader multiplies in a mask and applies a wavy effect!\n"); mFormatStr.Append("@KShader@N \"Unlit/").Append(shaderName).Append("\" {\n"); mFormatStr.Append(" @KSubShader@N {\n"); mFormatStr.Append(" @C...\n"); mFormatStr.Append(" @KPass@N {\n"); mFormatStr.Append(" @C...\n"); mFormatStr.Append(" @C/*** Insert custom shader variables here ***/\n"); mFormatStr.Append(" @Kfloat@N Wave;\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @Nfrag_in vert(appdata v) {\n"); mFormatStr.Append(" @C...@N\n"); mFormatStr.Append(" }\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @Kfloat4@N frag(v2f i) : @MSV_Target@N {\n"); mFormatStr.Append(" @C/*** Insert custom fragment shader code here ***/@N\n"); mFormatStr.Append(" @Kfloat2@N centerOffset = @L-1.0@N + @L2.0@N * i.uv.xy;\n"); mFormatStr.Append(" @Kfloat@N len = @Klength@N(centerOffset);\n"); mFormatStr.Append(" i.uv.xy += (centerOffset / len) * cos(len * @L10.0@N - Wave) * @L0.005@N;\n"); mFormatStr.Append(" @C...@N\n"); mFormatStr.Append(" @Kreturn@N color;\n"); mFormatStr.Append(" }\n"); mFormatStr.Append(" }\n"); mFormatStr.Append(" }\n"); mFormatStr.Append("}\n"); DemoUtil.HighlightCode(mFormatStr, mShaderStr); RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(0), mCodeStr); RB.Print(new Vector2i(304, 4), DemoUtil.IndexToRGB(0), mShaderStr); }
/// <summary> /// Render /// </summary> public override void Render() { var demo = (DemoReel)RB.Game; RB.Clear(DemoUtil.IndexToRGB(1)); mFormatStr.Set("@C// Test gamepad input for two players\n"); mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_A, @[email protected]_ONE) {\n"); mFormatStr.Append(" @C// Handle button A down for player one\n@N"); mFormatStr.Append("}\n"); mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_LEFT, @[email protected]_TWO) {\n"); mFormatStr.Append(" @C// Handle button LEFT transitioning from \"up\" to \"down\"\n@N"); mFormatStr.Append("}\n"); mFormatStr.Append("@Kif @N(@[email protected](@MRetroBlit.@NBTN_MENU, @[email protected]_ANY) {\n"); mFormatStr.Append(" @C// Handle button MENU transitioning from \"down\" to \"up\"\n@N"); mFormatStr.Append("}"); RB.Print(new Vector2i(4, 4), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); DrawGamepad(260, 15, RB.PLAYER_ONE); DrawGamepad(400, 15, RB.PLAYER_TWO); DrawMouse(540, 8); RB.DrawLine(new Vector2i(16, 85), new Vector2i(RB.DisplaySize.width - 16, 85), DemoUtil.IndexToRGB(2)); mFormatStr.Set("@C// Test keyboard input\n"); mFormatStr.Append("@Kif @N(@[email protected](@[email protected])) {\n"); mFormatStr.Append(" @C// Handle Left Shift down\n@N"); mFormatStr.Append("}\n\n"); mFormatStr.Append("@C// Retrieve the string of characters typed since last update\n"); mFormatStr.Append("@Kstring@n userInput += @[email protected]();"); RB.Print(new Vector2i(50, 92), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); mFormatStr.Set("@C// Get pointer position (mouse or touch)\n"); mFormatStr.Append("@[email protected](@L4@N, @[email protected]());\n\n"); mFormatStr.Append("@C// Test pointer button input\n"); mFormatStr.Append("@Kif @N(@[email protected](@[email protected]_POINTER_A)) {\n"); mFormatStr.Append(" @C// Handle Pointer Button A down\n@N"); mFormatStr.Append("}\n"); RB.Print(new Vector2i(350, 92), DemoUtil.IndexToRGB(5), DemoUtil.HighlightCode(mFormatStr, mFinalStr)); DrawKeyboard(mKeyboardOffset.x, mKeyboardOffset.y); DrawInputString(14, 155); mNextButton.Render(); mPrevButton.Render(); if (RB.PointerPosValid()) { RB.DrawSprite(4, RB.PointerPos()); } if (!UnityEngine.Input.mousePresent) { for (int i = 0; i < 4; i++) { if (RB.PointerPosValid(i)) { RB.DrawEllipse(RB.PointerPos(i), new Vector2i(64, 64), mTouchColor[i]); } } } }
private void DrawTMX(int x, int y) { var demo = (DemoReel)RB.Game; if (mMap != null) { RB.Offscreen(2); RB.DrawRectFill(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), DemoUtil.IndexToRGB(22)); RB.DrawMapLayer(0); RB.DrawMapLayer(1); RB.Offscreen(3); RB.Clear(new Color32(0, 0, 0, 0)); RB.SpriteSheetSet(1); RB.DrawSprite(0, new Vector2i((int)mBouncePos.x, (int)mBouncePos.y), mVelocity.x > 0 ? RB.FLIP_H : 0); RB.Onscreen(); RB.ShaderSet(0); RB.ShaderSpriteSheetTextureSet(0, "Mask", 3); RB.ShaderFloatSet(0, "Wave", RB.Ticks / 10.0f); RB.ShaderSpriteSheetFilterSet(0, 3, RB.Filter.Linear); RB.SpriteSheetSet(2); RB.DrawCopy(new Rect2i(0, 0, RB.DisplaySize.width, RB.DisplaySize.height), Vector2i.zero); RB.ShaderReset(); RB.SpriteSheetSet(0); } else { RB.Print(new Vector2i(x, y + 250), DemoUtil.IndexToRGB(14), "Failed to load TMX map.\nPlease try re-importing the map Demos/DemoReel/Tilemap.tmx in Unity"); } string shaderName = "WavyMaskShader"; mFormatStr.Set("@C// Custom shaders can be used for many things, like masking!\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"Demos/DemoReel/").Append(shaderName).Append("\"@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Draw a tilemap to one offscreen surface\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L0@N, @L0@N,\n"); mFormatStr.Append(" @[email protected], @[email protected]),\n"); mFormatStr.Append(" @I22@N);\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Draw a mask to the other offscreen surface\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("@[email protected](@Knew @MColor32@N(@L0@N, @L0@N, @L0@N, @L0@N));\n"); mFormatStr.Append("@[email protected](@L1@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @Knew @MVector2i@N(@L").Append((int)mBouncePos.x).Append("@N, @L").Append((int)mBouncePos.y).Append("@N)").Append(mVelocity.x > 0 ? ", RB.FLIP_H" : string.Empty).Append(");\n"); mFormatStr.Append("\n"); mFormatStr.Append("@C// Use a custom shader to combine the two!\n"); mFormatStr.Append("@[email protected]();\n"); mFormatStr.Append("@[email protected](@L0@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"Mask\"@N, @L1@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @S\"Wave\"@N, @L").Append(RB.Ticks / 10.0f, 2).Append("f@N);\n"); mFormatStr.Append("@[email protected](@L0@N, @L3@N, @MRB@N.@[email protected]);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected](@Knew @MRect2i@N(@L0@N, @L0@N,\n @[email protected], @[email protected]),\n @[email protected]);\n"); mFormatStr.Append("\n"); mFormatStr.Append("@[email protected]();\n"); DemoUtil.HighlightCode(mFormatStr, mCodeStr); mFormatStr.Set("@C// This shader multiplies in a mask and applies a wavy effect!\n"); mFormatStr.Append("@KShader@N \"Unlit/").Append(shaderName).Append("\" {\n"); mFormatStr.Append(" @KSubShader@N {\n"); mFormatStr.Append(" @C...\n"); mFormatStr.Append(" @KPass@N {\n"); mFormatStr.Append(" @C...\n"); mFormatStr.Append(" @C/*** Insert custom shader variables here ***/\n"); mFormatStr.Append(" @Ksampler2D@N Mask;\n"); mFormatStr.Append(" @Kfloat@N Wave;\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @Nfrag_in vert(vert_in v, @Kout float4@N screen_pos : @MSV_POSITION@N) {\n"); mFormatStr.Append(" @C...@N\n"); mFormatStr.Append(" }\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @Kfloat4@N frag(frag_in i, @MUNITY_VPOS_TYPE@N screen_pos : @MVPOS@N) : @MSV_Target@N {\n"); mFormatStr.Append(" @C...\n"); mFormatStr.Append(" @C/*** Insert custom fragment shader code here ***/@N\n"); mFormatStr.Append(" @C// Sample the mask texture@N\n"); mFormatStr.Append(" i.uv.x += sin(Wave + i.uv.y * @L8@N) * @L0.025@N;\n"); mFormatStr.Append(" i.uv.y += cos(Wave - i.uv.x * @L8@N) * @L0.015@N;\n"); mFormatStr.Append(" @Kfloat4@N mask_color = @Mtex2D@N(Mask, i.uv).rgba;\n"); mFormatStr.Append("\n"); mFormatStr.Append(" @C// Multiply the sprite pixel by mask color@N\n"); mFormatStr.Append(" @Kreturn@N sprite_pixel_color * mask_color;\n"); mFormatStr.Append(" }\n"); mFormatStr.Append(" }\n"); mFormatStr.Append(" }\n"); mFormatStr.Append("}\n"); DemoUtil.HighlightCode(mFormatStr, mShaderStr); RB.Print(new Vector2i(x, y), DemoUtil.IndexToRGB(5), mCodeStr); RB.Print(new Vector2i(x + 300, y), DemoUtil.IndexToRGB(5), mShaderStr); }