This commit is contained in:
Igor Timofeev 2016-06-18 20:50:35 +03:00
parent 596b58d342
commit fb19531e7c
3 changed files with 27 additions and 8 deletions

View File

@ -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",

View File

@ -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

View File

@ -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 <value>", 0xFFFFBF)
addItemToChatHistory("/setrenderquality <value>", 0xFFFFBF)
addItemToChatHistory("/setdrawdistance <value>", 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