コード例 #1
0
        public override void Render(Batch2D batch)
        {
            Color color = Color.Red;

            batch.PushMatrix(Matrix3x2.CreateTranslation(Entity.Position));

            if (shape == ShapeType.Rect)
            {
                batch.HollowRect(rect, 1, color);
            }
            else if (shape == ShapeType.Grid)
            {
                for (int x = 0; x < grid.Columns; x++)
                {
                    for (int y = 0; y < grid.Rows; y++)
                    {
                        if (!grid.cells[x + y * grid.Columns])
                        {
                            continue;
                        }

                        batch.HollowRect(
                            new Rect(x * grid.TileSize, y * grid.TileSize, grid.TileSize, grid.TileSize),
                            1, color
                            );
                    }
                }
            }

            batch.PopMatrix();
        }
コード例 #2
0
 public void Update(Batch2D batch2D)
 {
     ctx = batch2D;
     Draw();
     x = x + velocity.x;
     y = y + velocity.y;
 }
コード例 #3
0
ファイル: Enemy.cs プロジェクト: bernardphua/BlazorGames
 public void Update(Batch2D CanvasContext)
 {
     ctx = CanvasContext;
     Draw();
     x = x + velocity.x;
     y = y + velocity.y;
 }
コード例 #4
0
        public async Task <SKCanvas2DContext> InitializeAsync()
        {
            _context = await Component.CreateCanvas2DAsync();

            _batch = await _context.CreateBatchAsync();

            await _batch.LineCapAsync(LineCap.Round);

            return(this);
        }
コード例 #5
0
 public void Update(Batch2D CanvasContext)
 {
     ctx = CanvasContext;
     Draw();
     x           = x + velocity.x;
     y           = y + velocity.y;
     alpha      -= 0.01;
     velocity.x *= FRACTION;
     velocity.y *= FRACTION;
 }
コード例 #6
0
ファイル: FontRenderer.cs プロジェクト: whztt07/DeltaEngine
		private void AddIndicesAndVerticesForGlyph(Batch2D batch, GlyphDrawData glyph)
		{
			batch.AddIndices();
			batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
				position + glyph.DrawArea.TopLeft, color, glyph.UV.TopLeft);
			batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
				position + glyph.DrawArea.BottomLeft, color, glyph.UV.BottomLeft);
			batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
				position + glyph.DrawArea.BottomRight, color, glyph.UV.BottomRight);
			batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
				position + glyph.DrawArea.TopRight, color, glyph.UV.TopRight);
		}
コード例 #7
0
 private void AddIndicesAndVerticesForGlyph(Batch2D batch, GlyphDrawData glyph)
 {
     batch.AddIndices();
     batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
         position + glyph.DrawArea.TopLeft, color, glyph.UV.TopLeft);
     batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
         position + glyph.DrawArea.BottomLeft, color, glyph.UV.BottomLeft);
     batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
         position + glyph.DrawArea.BottomRight, color, glyph.UV.BottomRight);
     batch.verticesColorUV[batch.verticesIndex++] = new VertexPosition2DColorUV(
         position + glyph.DrawArea.TopRight, color, glyph.UV.TopRight);
 }
コード例 #8
0
ファイル: SpineRenderer.cs プロジェクト: whztt07/DeltaEngine
		private void DrawSlot(Skeleton skeleton, RegionAttachment attachment, Slot slot)
		{
			var region = (AtlasRegion)attachment.RendererObject;
			var thisMaterial = (Material)region.page.rendererObject;
			var thisBlendMode = slot.Data.AdditiveBlending ? BlendMode.Additive : BlendMode.Normal;
			var thisBatch = (Batch2D)renderer.FindOrCreateBatch(thisMaterial, thisBlendMode);
			if (currentBatch != null && currentBatch != thisBatch)
				renderer.FlushDrawBuffer(currentBatch);
			currentBatch = thisBatch;
			attachment.ComputeWorldVertices(skeleton.X, skeleton.Y, slot.Bone, vertices);
			currentColor = new Color(color.RedValue * slot.R, color.GreenValue * slot.G,
				color.BlueValue * slot.B, color.AlphaValue * slot.A);
			AddSlotIndicesAndVertices(attachment.UVs);
		}
コード例 #9
0
ファイル: World.cs プロジェクト: Colbydude/FosterPlatformer
        /// <summary>
        ///
        /// </summary>
        /// <param name="batch"></param>
        public void Render(Batch2D batch)
        {
            // Notes:
            // In general this isn't a great way to render objects.
            // Every frame it has to rebuild the list and sort it.
            // A more ideal way would be to cache the visible list
            // and insert / remove objects as they update or change
            // their depth

            // However, given the scope of this project, this is fine.

            // Assemble list.
            for (int i = 0; i < Component.Types.Count(); i++)
            {
                var component = componentsAlive[i]?.First;

                while (component != null)
                {
                    if (component.Visible && component.Entity.Visible)
                    {
                        visible.Add(component);
                    }

                    component = (Component)component.Next;
                }
            }

            // Sort by depth.
            visible.Sort((Component a, Component b) => {
                if (a.Depth > b.Depth)
                {
                    return(-1);
                }
                else if (a.Depth < b.Depth)
                {
                    return(1);
                }
                return(0);
            });

            // Render them.
            foreach (var it in visible)
            {
                it.Render(batch);
            }

            // Clear list for the next time around.
            visible.Clear();
        }
コード例 #10
0
        private void AddIndicesAndVerticesForTrackPart(Batch2D batch, int index)
        {
            batch.AddIndices();
            float uvStep = (index % UVLength) / (float)UVLength;

            batch.verticesUV[batch.verticesIndex++] = new VertexPosition2DUV(
                screen.ToPixelSpace(outerBounds[index]), new Vector2D(0, uvStep));
            batch.verticesUV[batch.verticesIndex++] = new VertexPosition2DUV(
                screen.ToPixelSpace(innerBounds[index]), new Vector2D(1, uvStep));
            uvStep = ((index % UVLength) + 1) / (float)UVLength;
            batch.verticesUV[batch.verticesIndex++] = new VertexPosition2DUV(
                screen.ToPixelSpace(innerBounds[(index + 1) % innerBounds.Length]), new Vector2D(1, uvStep));
            batch.verticesUV[batch.verticesIndex++] = new VertexPosition2DUV(
                screen.ToPixelSpace(outerBounds[(index + 1) % outerBounds.Length]), new Vector2D(0, uvStep));
        }
コード例 #11
0
        public override void Render(Batch2D batch)
        {
            if (inValidState())
            {
                batch.PushMatrix(
                    Mat3x2Ext.CreateTransform(Entity.Position + Offset, sprite.Origin, Scale, 0)
                    );

                var anim  = sprite.Animations[animationIndex];
                var frame = anim.Frames[frameIndex];
                batch.Image(frame.Image, Vector2.Zero, Color.White);

                batch.PopMatrix();
            }
        }
コード例 #12
0
        private void DrawSlot(Skeleton skeleton, RegionAttachment attachment, Slot slot)
        {
            var region        = (AtlasRegion)attachment.RendererObject;
            var thisMaterial  = (Material)region.page.rendererObject;
            var thisBlendMode = slot.Data.AdditiveBlending ? BlendMode.Additive : BlendMode.Normal;
            var thisBatch     = (Batch2D)renderer.FindOrCreateBatch(thisMaterial, thisBlendMode);

            if (currentBatch != null && currentBatch != thisBatch)
            {
                renderer.FlushDrawBuffer(currentBatch);
            }
            currentBatch = thisBatch;
            attachment.ComputeWorldVertices(skeleton.X, skeleton.Y, slot.Bone, vertices);
            currentColor = new Color(color.RedValue * slot.R, color.GreenValue * slot.G,
                                     color.BlueValue * slot.B, color.AlphaValue * slot.A);
            AddSlotIndicesAndVertices(attachment.UVs);
        }
コード例 #13
0
ファイル: Tilemap.cs プロジェクト: Colbydude/FosterPlatformer
        public override void Render(Batch2D batch)
        {
            batch.PushMatrix(Matrix3x2.CreateTranslation(Entity.Position));

            for (int x = 0; x < columns; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    if (grid[x + y * columns] != null && grid[x + y * columns].Texture != null)
                    {
                        batch.Image(grid[x + y * columns], new Vector2(x * tileWidth, y * tileHeight), Color.White);
                    }
                }
            }

            batch.PopMatrix();
        }
コード例 #14
0
        public async Task FlushAsync()
        {
            await _batch.DisposeAsync();

            _batch = await _context.CreateBatchAsync();
        }
コード例 #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="batch"></param>
 public virtual void Render(Batch2D batch)
 {
 }