private void PrepareCutoutVerts() { Engine.Graphics.GraphicsDevice.SetRenderTarget(Celeste.Celeste.WipeTarget); float sizeMultiplier = Ease.CubeIn(WipeIn ? Percent : 1 - Percent); int i = 0; int segmentIndex = 0; float segmentAngle = (float)Math.PI * 2.0f / circleSegments; while (i < cutoutVerts.Length) { cutoutVerts[i].Position = new Vector3(O, 0); cutoutVerts[i + 1].Position = new Vector3( O + new Vector2( (float)Math.Sin(segmentAngle * segmentIndex) * bigDiameter * sizeMultiplier, (float)Math.Cos(segmentAngle * segmentIndex) * bigDiameter * sizeMultiplier ), 0 ); cutoutVerts[i + 2].Position = new Vector3( O + new Vector2( (float)Math.Sin(segmentAngle * (segmentIndex + 1)) * bigDiameter * sizeMultiplier, (float)Math.Cos(segmentAngle * (segmentIndex + 1)) * bigDiameter * sizeMultiplier ), 0 ); i += 3; segmentIndex++; } GFX.DrawVertices(Matrix.Identity, cutoutVerts, cutoutVerts.Length); }
private void DrawGears() { _hasDrawn = true; Engine.Graphics.GraphicsDevice.SetRenderTarget(Celeste.Celeste.WipeTarget); Engine.Graphics.GraphicsDevice.Clear(WipeIn ? Color.White : Color.Black); if (Percent > 0.9f) { float num = Calc.Map(Percent, 0.9f, 1f) * 1082f; Draw.SpriteBatch.Begin(); Draw.Rect(-1f, (1080f - num) * 0.5f, 1922f, num, (!WipeIn) ? Color.White : Color.Black); Draw.SpriteBatch.End(); } float sizeMultiplier = Ease.CubeIn(Percent); float baseSize = 1000f; for (int i = 0; i < _gears.Length; i++) { int index = 0; for (int j = 0; j < Gear.ToothCount; j++) { for (int k = 0; k < _countPerTeeth; k++) { Gear gear = _gears[i]; float size = k >= 8 ? baseSize : 1.2f * baseSize; float angle = gear.Angle + (j * Calc.Circle / Gear.ToothCount) + k * Calc.Circle / Gear.ToothCount / _countPerTeeth; _verts[index++].Position = new Vector3(Calc.AngleToVector(angle, size * sizeMultiplier * gear.Scale) + new Vector2(gear.X, gear.Y), 0f); angle += Calc.Circle / Gear.ToothCount / _countPerTeeth; _verts[index++].Position = new Vector3(Calc.AngleToVector(angle, size * sizeMultiplier * gear.Scale) + new Vector2(gear.X, gear.Y), 0f); _verts[index++].Position = new Vector3(new Vector2(gear.X, gear.Y), 0f); } } GFX.DrawVertices(Matrix.Identity, _verts, _verts.Length); } }
private void PrepareClockworkVerts() { Engine.Graphics.GraphicsDevice.SetRenderTarget(Celeste.Celeste.WipeTarget); float sizeMultiplier = Ease.CubeIn(WipeIn ? Percent : 1 - Percent); float lengthMultiplier = 1.0f; if (Percent > 0.8f) { lengthMultiplier = 1.0f - Calc.Map(Percent, 0.8f, 1f); } int i = 0; Vector2[] minuteVerts = GetArmVerts(minuteWidth * sizeMultiplier, minuteLength * sizeMultiplier * lengthMultiplier, time.Minute * (float)Math.PI * 2.0f / 60.0f); for (int j = 0; j < minuteVerts.Length; j++) { clockworkVerts[i].Position = new Vector3(minuteVerts[j], 0); i++; } Vector2[] hourVerts = GetArmVerts(hourWidth * sizeMultiplier, hourLength * sizeMultiplier * lengthMultiplier, time.Hour * (float)Math.PI * 2.0f / 12.0f + time.Minute * (float)Math.PI * 2.0f / 60.0f / 12.0f, true); for (int j = 0; j < minuteVerts.Length; j++) { clockworkVerts[i].Position = new Vector3(hourVerts[j], 0); i++; } GFX.DrawVertices(Matrix.Identity, clockworkVerts, clockworkVerts.Length); }
private void BeforeRender() { if (BlockFill == null) { BlockFill = VirtualContent.CreateRenderTarget("block-fill", 320, 180, false, true, 0); } if (this.vertexCount <= 0) { return; } Engine.Graphics.GraphicsDevice.SetRenderTarget((RenderTarget2D)BlockFill); Engine.Graphics.GraphicsDevice.Clear(wipeColor); GFX.DrawVertices <VertexPositionColor>(Matrix.Identity, this.vertices, this.vertexCount, (Effect)null, (BlendState)null); }
public override void Render() { Vector2 beamOrigin = boss.BeamOrigin; Vector2 vector1 = Calc.AngleToVector(angle, beamSprite.Width); beamSprite.Rotation = angle; beamSprite.Color = Color.White * beamAlpha; beamStartSprite.Rotation = angle; beamStartSprite.Color = Color.White * beamAlpha; if (beamSprite.CurrentAnimationID == "shoot") { beamOrigin += Calc.AngleToVector(angle, 8f); } for (var index = 0; index < 15; ++index) { beamSprite.RenderPosition = beamOrigin; beamSprite.Render(); beamOrigin += vector1; } if (beamSprite.CurrentAnimationID == "shoot") { beamStartSprite.RenderPosition = boss.BeamOrigin; beamStartSprite.Render(); } GameplayRenderer.End(); Vector2 vector2 = vector1.SafeNormalize(); Vector2 vector2_1 = vector2.Perpendicular(); Color color = Color.Black * sideFadeAlpha * 0.35f; Color transparent = Color.Transparent; Vector2 vector2_2 = vector2 * 4000f; Vector2 vector2_3 = vector2_1 * 120f; var v = 0; Quad(ref v, beamOrigin, -vector2_2 + vector2_3 * 2f, vector2_2 + vector2_3 * 2f, vector2_2 + vector2_3, -vector2_2 + vector2_3, color, color); Quad(ref v, beamOrigin, -vector2_2 + vector2_3, vector2_2 + vector2_3, vector2_2, -vector2_2, color, transparent); Quad(ref v, beamOrigin, -vector2_2, vector2_2, vector2_2 - vector2_3, -vector2_2 - vector2_3, transparent, color); Quad(ref v, beamOrigin, -vector2_2 - vector2_3, vector2_2 - vector2_3, vector2_2 - vector2_3 * 2f, -vector2_2 - vector2_3 * 2f, color, color); GFX.DrawVertices((Scene as Level).Camera.Matrix, fade, fade.Length); GameplayRenderer.Begin(); }
public override void Render() { Vector2 beamOrigin = _beamOrigin; Vector2 vector = Calc.AngleToVector(_angle, _beamSprite.Width); _beamSprite.Rotation = _angle; _beamSprite.Color = Color.White * _beamAlpha; _beamStartSprite.Rotation = _angle; _beamStartSprite.Color = Color.White * _beamAlpha; if (_beamSprite.CurrentAnimationID == "shoot") { beamOrigin += Calc.AngleToVector(_angle, 8f); } for (int i = 0; i < 15; i++) { _beamSprite.RenderPosition = beamOrigin; _beamSprite.Render(); beamOrigin += vector; } if (_beamSprite.CurrentAnimationID == "shoot") { _beamStartSprite.RenderPosition = _beamOrigin; _beamStartSprite.Render(); } GameplayRenderer.End(); Vector2 vector2 = vector.SafeNormalize(); Vector2 vector3 = vector2.Perpendicular(); Color color = Color.Black * _sideFadeAlpha * 0.35f; Color transparent = Color.Transparent; vector2 *= 4000f; vector3 *= 120f; int v = 0; Quad(ref v, beamOrigin, -vector2 + vector3 * 2f, vector2 + vector3 * 2f, vector2 + vector3, -vector2 + vector3, color, color); Quad(ref v, beamOrigin, -vector2 + vector3, vector2 + vector3, vector2, -vector2, color, transparent); Quad(ref v, beamOrigin, -vector2, vector2, vector2 - vector3, -vector2 - vector3, transparent, color); Quad(ref v, beamOrigin, -vector2 - vector3, vector2 - vector3, vector2 - vector3 * 2f, -vector2 - vector3 * 2f, color, color); GFX.DrawVertices((base.Scene as Level).Camera.Matrix, fade, fade.Length); GameplayRenderer.Begin(); }
public override void BeforeRender(Scene scene) { hasDrawn = true; Engine.Graphics.GraphicsDevice.SetRenderTarget(Celeste.Celeste.WipeTarget); Engine.Graphics.GraphicsDevice.Clear(Color.White); if (Percent > 0.8f) { float rectPercent = Calc.Map(Percent, 0.8f, 1f); Draw.SpriteBatch.Begin(); Draw.Rect((1920f - rectPercent * 1922f) * 0.5f, (1080f - rectPercent * 1082f) * 0.5f, rectPercent * 1922f, rectPercent * 1082f, WipeIn ? Color.Black : Color.White); Draw.SpriteBatch.End(); } float sizeMultiplier = Ease.CubeIn(WipeIn ? Percent : 1 - Percent); for (int i = 0; i < verts.Length; i++) { verts[i].Position = new Vector3(refVerts[vertIndeces[i]] * finalSizeMultiplier * sizeMultiplier + center, 0f); } GFX.DrawVertices(Matrix.Identity, verts, verts.Length); }
public override void Render() { base.Render(); if (Activator.IsOn) { Camera camera = (Scene as Level).Camera; if (camera != null) { for (int i = 0; i < _electricityColorsLerped.Length; i++) { _electricityColorsLerped[i] = Color.Lerp(_electricityColors[i], Color.White, Fade); } int index = 0; DrawSimpleLightning(ref index, ref _edgeVerts, _edgeSeed, Position, _start, _end, _electricityColorsLerped[0], 1f + Fade * 1f); DrawSimpleLightning(ref index, ref _edgeVerts, _edgeSeed + 1, Position, _start, _end, _electricityColorsLerped[1], 1f + Fade * 1f); if (index > 0) { GameplayRenderer.End(); GFX.DrawVertices(camera.Matrix, _edgeVerts, index); GameplayRenderer.Begin(); } } } }
private void BeforeRender() { List <Entity> glassBlocks = Scene.Tracker.GetEntities <CustomizableGlassBlock>(); hasBlocks = (glassBlocks.Count > 0); if (!hasBlocks) { return; } Camera camera = (Scene as Level).Camera; int screenWidth = 320; int screenHeight = 180; // draw stars if (starsTarget == null) { starsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-surfaces", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(starsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity); Vector2 origin = new Vector2(8f, 8f); for (int i = 0; i < stars.Length; i++) { MTexture starTexture = stars[i].Texture; Color starColor = stars[i].Color * alpha; Vector2 starScroll = stars[i].Scroll; Vector2 starActualPosition = default; starActualPosition.X = Mod(stars[i].Position.X - camera.X * (1f - starScroll.X), screenWidth); starActualPosition.Y = Mod(stars[i].Position.Y - camera.Y * (1f - starScroll.Y), screenHeight); starTexture.Draw(starActualPosition, origin, starColor); if (starActualPosition.X < origin.X) { starTexture.Draw(starActualPosition + new Vector2(screenWidth, 0f), origin, starColor); } else if (starActualPosition.X > screenWidth - origin.X) { starTexture.Draw(starActualPosition - new Vector2(screenWidth, 0f), origin, starColor); } if (starActualPosition.Y < origin.Y) { starTexture.Draw(starActualPosition + new Vector2(0f, screenHeight), origin, starColor); } else if (starActualPosition.Y > screenHeight - origin.Y) { starTexture.Draw(starActualPosition - new Vector2(0f, screenHeight), origin, starColor); } } Draw.SpriteBatch.End(); // draw rays/beams int vertex = 0; for (int j = 0; j < rays.Length; j++) { Vector2 rayPosition = default; rayPosition.X = Mod(rays[j].Position.X - camera.X * 0.9f, screenWidth); rayPosition.Y = Mod(rays[j].Position.Y - camera.Y * 0.9f, screenHeight); DrawRay(rayPosition, ref vertex, ref rays[j]); if (rayPosition.X < 64f) { DrawRay(rayPosition + new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } else if (rayPosition.X > (screenWidth - 64)) { DrawRay(rayPosition - new Vector2(screenWidth, 0f), ref vertex, ref rays[j]); } if (rayPosition.Y < 64f) { DrawRay(rayPosition + new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } else if (rayPosition.Y > (screenHeight - 64)) { DrawRay(rayPosition - new Vector2(0f, screenHeight), ref vertex, ref rays[j]); } } if (beamsTarget == null) { beamsTarget = VirtualContent.CreateRenderTarget("customizable-glass-block-beams", screenWidth, screenHeight); } Engine.Graphics.GraphicsDevice.SetRenderTarget(beamsTarget); Engine.Graphics.GraphicsDevice.Clear(Color.Transparent); GFX.DrawVertices(Matrix.Identity, verts, vertex); // if fading in, update the alpha value to fade in in ~0.25 seconds. if (alpha != 1f) { alpha = Calc.Approach(alpha, 1f, Engine.DeltaTime * 4f); } }
public override void Render() { GameplayRenderer.End(); // render the edges of the lava rect. if (dirty) { Vector2 zero = Vector2.Zero; Vector2 topLeft = zero; Vector2 topRight = new Vector2(zero.X + Width, zero.Y); Vector2 bottomLeft = new Vector2(zero.X, zero.Y + Height); Vector2 bottomRight = zero + new Vector2(Width, Height); Vector2 fadeOffset = new Vector2(Math.Min(Fade, Width / 2f), Math.Min(Fade, Height / 2f)); vertCount = 0; if (OnlyMode == OnlyModes.OnlyLeft) { Edge(ref vertCount, topRight, bottomRight, fadeOffset.X); Quad(ref vertCount, topLeft, topRight - new Vector2(fadeOffset.X, 0f), bottomRight - new Vector2(fadeOffset.X, 0f), bottomLeft, CenterColor); } else if (OnlyMode == OnlyModes.OnlyRight) { Edge(ref vertCount, bottomLeft, topLeft, fadeOffset.X); Quad(ref vertCount, topLeft + new Vector2(fadeOffset.X, 0f), topRight, bottomRight, bottomLeft + new Vector2(fadeOffset.X, 0f), CenterColor); } dirty = false; } // render the vertices Camera camera = (Scene as Level).Camera; GFX.DrawVertices(Matrix.CreateTranslation(new Vector3(Entity.Position + Position, 0f)) * camera.Matrix, verts, vertCount); GameplayRenderer.Begin(); Vector2 rectPosition = Entity.Position + Position; // render bubbles MTexture bubbleTexture = GFX.Game["particles/bubble"]; for (int i = 0; i < bubbles.Length; i++) { bubbleTexture.DrawCentered(rectPosition + bubbles[i].Position, SurfaceColor * bubbles[i].Alpha); } // render surface bubbles for (int j = 0; j < surfaceBubbles.Length; j++) { if (surfaceBubbles[j].Y >= 0f) { MTexture surfaceBubbleTexture = surfaceBubbleAnimations[surfaceBubbles[j].Animation][(int)surfaceBubbles[j].Frame]; int bubbleOffset = (int)(surfaceBubbles[j].Y / SurfaceStep); float x; if (OnlyMode == OnlyModes.OnlyLeft) { x = Width + 7f + Wave(bubbleOffset, Height); } else { x = 1f - Wave(bubbleOffset, Height); } surfaceBubbleTexture.DrawJustified(rectPosition + new Vector2(x, OnlyMode == OnlyModes.OnlyRight ? Height - bubbleOffset * SurfaceStep : bubbleOffset * SurfaceStep), new Vector2(1f, 0.5f), SurfaceColor); } } }