From 1a37f5e0ad08ff2c0fcf824b9b175f255454aac0 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Tue, 26 Oct 2021 06:16:13 -0700 Subject: [PATCH] 2d cels --- BeefLibs/Beefy2D/src/gfx/Image.bf | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/BeefLibs/Beefy2D/src/gfx/Image.bf b/BeefLibs/Beefy2D/src/gfx/Image.bf index 0835d251..48b84d7a 100644 --- a/BeefLibs/Beefy2D/src/gfx/Image.bf +++ b/BeefLibs/Beefy2D/src/gfx/Image.bf @@ -210,6 +210,25 @@ namespace Beefy.gfx } } } + + public Image[] CreateImageCels(int32 cols, int32 rows) + { + int32 celW = mSrcWidth / cols; + int32 celH = mSrcHeight / rows; + + Debug.Assert(celW * cols == mSrcWidth); + Debug.Assert(celH * rows == mSrcHeight); + + Image[] celImages = new .[cols * rows]; + for (int32 row = 0; row < rows; row++) + { + for (int32 col = 0; col < cols; col++) + { + celImages[row * cols + col] = CreateImageSegment(col * celW, row * celH, celW, celH); + } + } + return celImages; + } } #else public class Image : IDrawable