void DrawFont(TRectF screen) { string txt; uint width, height; TColor4 c; txt = "I'm rotating... +_+"; pFontBold.GetTextDimensions(txt, out width, out height); c = TColor4.ColorWhite(); pFontBold.Draw2D(screen.x + screen.width - width - 10f, 200, txt, ref c, counter % 360); txt = "I'm just right aligned text. -_-"; pFontBold.GetTextDimensions(txt, out width, out height); pFontBold.Draw2D((int)(screen.x + screen.width - width), 10, txt, ref c); txt = "I have a shadow! ;-)"; pFontBold.GetTextDimensions(txt, out width, out height); c = TColor4.ColorBlack(); pFontBold.Draw2D((int)(screen.x + screen.width - width - 7f), 53, txt, ref c); c = TColor4.ColorWhite(); pFontBold.Draw2D((int)(screen.x + screen.width - width - 10f), 50, txt, ref c); txt = "Cool colored me! ^_^"; pFontBold.GetTextDimensions(txt, out width, out height); TColor4 c1 = TColor4.ColorRed(); TColor4 c2 = TColor4.ColorGreen(); pRender2D.SetVerticesColors(ref c1, ref c2, ref c1, ref c2); c = TColor4.ColorWhite(); pFontBold.Draw2D(screen.x + screen.width - width - 10f, 100f, txt, ref c, 0, true); txt = "I'm randomly colored... >_<"; pFont.Draw2D(screen.x + 5f, 10, txt, ref stRandomCol); txt = "I'm per vertex colored! -_0"; TColor4 c3 = TColor4.ColorAqua(); TColor4 c4 = TColor4.ColorOrange(); pRender2D.SetVerticesColors(ref c3, ref c3, ref c4, ref c4); c = TColor4.ColorWhite(); pFontBold.Draw2D(screen.x + 5f, 50f, txt, ref c, 0, true); txt = "А я могу говорить по-русски! [:-|"; c = TColor4.ColorRed(); pFont.Draw2D(screen.x + 5f, 100, txt, ref c); txt = "I'm scaling... o_O"; pFontBold.SetScale((float)Math.Abs(Math.Sin(counter / 50f)) * 2f); c = TColor4.ColorWhite(); pFontBold.Draw2D(screen.x + 5f, 200, txt, ref c); pFontBold.SetScale(1f); txt = "I am just very brutal..!"; pFontHard.GetTextDimensions(txt, out width, out height); c = TColor4.ColorOfficialOrange(); pFontHard.Draw2D((int)(screen.x + (screen.width - width) / 2f), 300f, txt, ref c); }
public override void Draw() { string res = _uiScore.ToString(); uint w, h; _pFnt.SetScale(_fSize); _pFnt.GetTextDimensions(res, out w, out h); _pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL); TColor4 c = TColor4.ColorWhite((byte)(255 - _uiCounter * 5)); _pFnt.Draw2D(_stPos.x - w / 2f, _stPos.y - h / 2f, res, ref c); }
void Render(IntPtr pParam) { if (pRender2D == null) { return; } pRender2D.Begin2D(); // Draw sky TPoint2 ps = new TPoint2(); TPoint2 pt = new TPoint2(GAME_VP_WIDTH, GAME_VP_HEIGHT); pRender2D.DrawTexture(pSky, ref ps, ref pt, 0, E_EFFECT2D_FLAGS.EF_NONE); // Draw background ps = new TPoint2(cameraPosition.x / 1.5f, cameraPosition.y / 1.5f); pt = new TPoint2(cameraScale, cameraScale); pRender2D.SetCamera(ref ps, cameraAngle, ref pt); pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL); ps = new TPoint2(-200f, 150f); pt = new TPoint2(1399f, 517f); TRectF rect = new TRectF(0f, 905f, 1399f, 517f); pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0.0f, E_EFFECT2D_FLAGS.EF_BLEND); // Draw moving fog on background ps = new TPoint2(cameraPosition.x / 1.2f, cameraPosition.y / 1.2f); pt = new TPoint2(cameraScale, cameraScale); pRender2D.SetCamera(ref ps, cameraAngle, ref pt); pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD); // Sometimes it's better to batch a lot of similar objects. pRender2D.BeginBatch(); TColor4 col = new TColor4(255, 255, 255, 64); pRender2D.SetColorMix(ref col); for (uint i = 0; i < 22; ++i) { for (uint j = 0; j < 2; ++j) { ps = new TPoint2((float)(500f + Math.Sin((float)i) * 600f - Math.Cos((float)counter / 50f) * 10f * (i % 4)), (float)(475f + Math.Sin((float)j * 2.5f) * 150f - Math.Sin((float)counter / 50f) * 20f * (i % 3))); pt = new TPoint2(250f, 150f); pRender2D.DrawTexture(pFog, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX)); } } pRender2D.EndBatch(); // Draw foreground scene // Setup camera and blending pt = new TPoint2(cameraScale, cameraScale); pRender2D.SetCamera(ref cameraPosition, cameraAngle, ref pt); pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL); // Owl col = new TColor4(150, 150, 150, 255); pRender2D.SetColorMix(ref col); // make sprite little darker ps = new TPoint2(owlX, 425f); pt = new TPoint2(48f, 128f); E_EFFECT2D_FLAGS EEF = (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX | (owlGoLeft ? E_EFFECT2D_FLAGS.EF_FLIP_HORIZONTALLY : E_EFFECT2D_FLAGS.EF_DEFAULT)); pRender2D.DrawTextureSprite(pOwl, ref ps, ref pt, (uint)(counter / 3) % 15, 0f, EEF); // Draw tree ps = new TPoint2(); pt = new TPoint2(1399f, 900f); rect = new TRectF(0f, 0f, 1399f, 900f); pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0f, E_EFFECT2D_FLAGS.EF_BLEND); // Glowing disc under moving light pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD); ps = new TPoint2(-100f, 0f); pt = new TPoint2(); pRender2D.SetVerticesOffsets(ref ps, ref ps, ref pt, ref pt); col = new TColor4(65, 59, 193, 255); pRender2D.SetColorMix(ref col); ps = new TPoint2(lights[0].x - 32f, lights[0].y + 64f); pt = new TPoint2(256f, 256f); pRender2D.DrawTexture(pLightRound, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX)); // Girl Shadow pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL); ps = new TPoint2(-150f + (float)Math.Cos((float)counter / 100f) * 100f, -55f); pt = new TPoint2(-50f + (float)Math.Cos((float)counter / 100f) * 100f, -55f); TPoint2 pp = new TPoint2(15f, 5f); pRender2D.SetVerticesOffsets(ref ps, ref pt, ref pp, ref pp); col = new TColor4(0, 0, 0, 128); pRender2D.SetColorMix(ref col); ps = new TPoint2(550f, 725f); pt = new TPoint2(60f, 120f); pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX)); // Girl Sprite pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND); // Lights pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD); for (uint i = 0; i < 5; ++i) { ps = new TPoint2(lights[i].x, lights[i].y); pt = new TPoint2(64f, 128f); pRender2D.DrawTextureSprite(pLight, ref ps, ref pt, (uint)(counter / 2) % 14, 0f, E_EFFECT2D_FLAGS.EF_BLEND); } pRender2D.ResetCamera(); // We must calculate correct coordinates in game space because game resolution and screen resolution can be different. TPoint2 pos; pRender2D.AbsoluteToResolutionCorrect(ref stMousePos, out pos); ps = new TPoint2(pos.x - 37, pos.y - 37); pt = new TPoint2(75f, 75f); pRender2D.DrawTextureSprite(pVox, ref ps, ref pt, (uint)(counter / 2) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND); uint tw, th; pFont.GetTextDimensions(HELP_TEXT, out tw, out th); col = TColor4.White; pFont.Draw2D((float)((GAME_VP_WIDTH - tw) / 2), (float)(GAME_VP_HEIGHT - th), HELP_TEXT, ref col); pRender2D.End2D(); }