From fb19531e7cd7a73ff705db7824e443aac4695ac7 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sat, 18 Jun 2016 20:50:35 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B8=D0=B7=D0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Applications.txt | 4 ++-- lib/image.lua | 10 +++++----- lib/rayEngine.lua | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Applications.txt b/Applications.txt index b78e360f..4cb97024 100644 --- a/Applications.txt +++ b/Applications.txt @@ -261,7 +261,7 @@ name="lib/image.lua", url="IgorTimofeev/OpenComputers/master/lib/image.lua", type="Library", - version=1.21, + version=1.22, }, { name="lib/colorlib.lua", @@ -273,7 +273,7 @@ name="lib/rayEngine.lua", url="IgorTimofeev/OpenComputers/master/lib/rayEngine.lua", type="Library", - version=1.25, + version=1.26, }, { name="lib/doubleHeight.lua", diff --git a/lib/image.lua b/lib/image.lua index 4127a703..08a38a80 100644 --- a/lib/image.lua +++ b/lib/image.lua @@ -812,7 +812,7 @@ end --Получение ряда пикселей function image.getRow(picture, y) - local row, background, foreground, alpha, symbol = {} + local row, background, foreground, alpha, symbol = {width = picture.width, height = 1} for x = 1, picture.width do background, foreground, alpha, symbol = image.get(picture, x, y) table.insert(row, background) @@ -825,7 +825,7 @@ end --Получение колонки пикселей function image.getColumn(picture, x) - local column, background, foreground, alpha, symbol = {} + local column, background, foreground, alpha, symbol = {width = 1, height = picture.height} for y = 1, picture.height do background, foreground, alpha, symbol = image.get(picture, x, y) table.insert(column, background) @@ -844,13 +844,13 @@ function image.duplicate(picture) end --Аналог свободного трансформирования из фотошопа -function image.transform(picture, widthScale, heightScale) +function image.transform(picture, newWidth, newHeight) local newPicture = image.duplicate(picture) - local newWidth, newHeight = math.floor(picture.width * widthScale), math.floor(picture.height * heightScale) + local widthScale, heightScale = newWidth / picture.width, newHeight / picture.height local deltaWidth, deltaHeight = math.abs(newWidth - picture.width), math.abs(newHeight - picture.height) local widthIteration, heightIteration = widthScale > 1 and newWidth / deltaWidth or picture.width / deltaWidth, heightScale > 1 and newHeight / deltaHeight or picture.height / deltaHeight - ecs.error(widthIteration, heightIteration, deltaWidth, picture.width, newWidth) + -- ecs.error(widthIteration, heightIteration, deltaWidth, picture.width, newWidth) --Сжимаем шакалов по ширине if widthScale > 1 then diff --git a/lib/rayEngine.lua b/lib/rayEngine.lua index 77f18ad8..84339ee6 100644 --- a/lib/rayEngine.lua +++ b/lib/rayEngine.lua @@ -116,6 +116,9 @@ function rayEngine.loadWorld(pathToWorldFolder) rayEngine.distanceToProjectionPlane = (buffer.screen.width / 2) / math.tan(math.rad((rayEngine.player.fieldOfView / 2))) --Шаг, с которым будет изменяться угол рейкаста rayEngine.properties.raycastStep = rayEngine.player.fieldOfView / buffer.screen.width + + -- rayEngine.wallsTexture = image.load("/heart.pic") + -- rayEngine.wallsTexture = image.transform(rayEngine.wallsTexture, rayEngine.properties.tileWidth, rayEngine.properties.tileWidth / 2) end ---------------------------------------------------- Функции, связанные с игроком ------------------------------------------------------------------ @@ -338,10 +341,18 @@ function rayEngine.commandLine(transparency) addItemToChatHistory("Текущее время: " .. rayEngine.world.dayNightCycle.currentTime, 0xFFDB40) addItemToChatHistory("Длина суток: " .. rayEngine.world.dayNightCycle.length, 0xFFDB40) end + elseif words[1] == "setrenderquality" and tonumber(words[2]) then + rayEngine.properties.raycastQuality = rayEngine.properties.tileWidth * tonumber(words[2]) + addItemToChatHistory("Качество рендера изменено на: " .. tonumber(words[2]), 0xFFDB40) + elseif words[1] == "setdrawdistance" and tonumber(words[2]) then + rayEngine.properties.drawDistance = tonumber(words[2]) + addItemToChatHistory("Дистанция прорисовки изменена на: " .. tonumber(words[2]), 0xFFDB40) elseif words[1] == "help" then addItemToChatHistory("Доступные команды:", 0xFFDB40) addItemToChatHistory("/time get", 0xFFFFBF) addItemToChatHistory("/time set ", 0xFFFFBF) + addItemToChatHistory("/setrenderquality ", 0xFFFFBF) + addItemToChatHistory("/setdrawdistance ", 0xFFFFBF) else addItemToChatHistory("Неизвестная команда. Введите /help для получения списка команд", 0xFF8888) end @@ -404,8 +415,16 @@ function rayEngine.drawWorld() height = rayEngine.properties.tileWidth / distanceToTile * rayEngine.distanceToProjectionPlane startY = rayEngine.horizonPosition - height / 2 + 1 - tileColor = height > distanceLimit and rayEngine.world.colors.tile.byTime[#rayEngine.world.colors.tile.byTime] or rayEngine.world.colors.tile.byTime[math.floor(#rayEngine.world.colors.tile.byTime * height / distanceLimit)] + --ТИКСТУРКА)))00 + -- local xTexture = startX % rayEngine.properties.tileWidth + 1 + -- if xTexture >= 1 and xTexture <= buffer.screen.width then + -- local column = image.getColumn(rayEngine.wallsTexture, xTexture) + -- column = image.transform(column, 1, height) + -- buffer.image(math.floor(startX), math.floor(startY), column) + -- end + --Кусочек стенки + tileColor = height > distanceLimit and rayEngine.world.colors.tile.byTime[#rayEngine.world.colors.tile.byTime] or rayEngine.world.colors.tile.byTime[math.floor(#rayEngine.world.colors.tile.byTime * height / distanceLimit)] buffer.square(math.floor(startX), math.floor(startY), 1, math.floor(height), tileColor, 0x000000, " ") end startX = startX + 1