From c61e2c8fd26a552400ae55cbeadcecb1a85f43bf Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Tue, 27 Oct 2015 14:21:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BE=D1=85=D1=83=D0=B5=D0=BD=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BA=D0=B0=D1=80=D0=BE=D1=87=20by=20Krutoy?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/doubleBuffering.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/doubleBuffering.lua b/lib/doubleBuffering.lua index 64ab93d2..7f1bc7c8 100644 --- a/lib/doubleBuffering.lua +++ b/lib/doubleBuffering.lua @@ -305,6 +305,7 @@ end function buffer.draw() local currentBackground, currentForeground = -math.huge, -math.huge local index + local massiv for y = 1, buffer.screen.height do local x = 1 @@ -333,26 +334,31 @@ function buffer.draw() --Если были найдены какие-то отличия нового экрана от старого, то корректируем эти отличия через gpu.set() if backgroundIsChanged or foregroundIsChanged or symbolIsChanged then - --ecs.error("coordx = " .. x .. "x" .. y .. ", index = " ..index .. ", index1 = "..buffer.screen.current[index] .. ", index2 = "..buffer.screen.current[index + 1].. ", index3 = "..buffer.screen.current[index + 2] ) - - local countOfSameSymbols = 1 + massiv = { buffer.screen.current[index + 2] } + --Отрисовка линиями. Не трожь, сука! local iIndex for i = (x + 1), buffer.screen.width do iIndex = convertCoordsToIndex(i, y) - if buffer.screen.current[index] == buffer.screen.new[iIndex] and buffer.screen.current[index + 1] == buffer.screen.new[iIndex + 1] and buffer.screen.current[index + 2] == buffer.screen.new[iIndex + 2] then - countOfSameSymbols = countOfSameSymbols + 1 + if + buffer.screen.current[index] == buffer.screen.new[iIndex] and + ( + buffer.screen.new[iIndex + 2] == " " + or + buffer.screen.current[index + 1] == buffer.screen.new[iIndex + 1] + ) + then buffer.calculateDifference(i, y) + table.insert(massiv, buffer.screen.current[iIndex + 2]) else break end end - --ecs.error(countOfSameSymbols) - - gpu.set(x, y, string.rep(buffer.screen.current[index + 2], countOfSameSymbols)) + --os.sleep(0.2) + gpu.set(x, y, table.concat(massiv)) - x = x + countOfSameSymbols - 1 + x = x + #massiv - 1 countOfGPUOperations = countOfGPUOperations + 1 end