mirror of
https://github.com/IgorTimofeev/MineOS.git
synced 2025-12-20 19:19:21 +01:00
Добавил параметр яркости, выпилил скорость, которая выглядела всрато на любых значениях > 100
This commit is contained in:
parent
d6f4bbeb0e
commit
bcffc94d41
@ -9,12 +9,12 @@ local color = require("Color")
|
|||||||
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
local configPath = filesystem.path(system.getCurrentScript()) .. "Config.cfg"
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
starAmount = 100,
|
|
||||||
backgroundColor = 0x0F0F0F,
|
backgroundColor = 0x0F0F0F,
|
||||||
|
|
||||||
|
starAmount = 100,
|
||||||
starColor = 0xF0F0F0,
|
starColor = 0xF0F0F0,
|
||||||
delay = 0.05,
|
starBrightness = 1.5,
|
||||||
offset = 0.01,
|
starOffset = 0.01
|
||||||
speed = 100
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if filesystem.exists(configPath) then
|
if filesystem.exists(configPath) then
|
||||||
@ -31,9 +31,12 @@ end
|
|||||||
|
|
||||||
-- Faster access without tables indexing
|
-- Faster access without tables indexing
|
||||||
local computerUptime, tableRemove, mathSin, mathCos, mathRandom, screenUpdate = computer.uptime, table.remove, math.sin, math.cos, math.random
|
local computerUptime, tableRemove, mathSin, mathCos, mathRandom, screenUpdate = computer.uptime, table.remove, math.sin, math.cos, math.random
|
||||||
|
-- Braille symbols that belongs to stars at specific positions
|
||||||
local braille1, braille2, braille3, braille4, braille5, braille6, braille7, braille8, braille9, braille10 = "⠁", "⠈", "⠂", "⠐", "⠄", "⠠", "⡀", "⢀", "⠛", "⣤"
|
local braille1, braille2, braille3, braille4, braille5, braille6, braille7, braille8, braille9, braille10 = "⠁", "⠈", "⠂", "⠐", "⠄", "⠠", "⡀", "⢀", "⠛", "⣤"
|
||||||
local stars, deadline, colors
|
|
||||||
|
local stars = {}
|
||||||
|
local deadline = 0
|
||||||
|
local colors
|
||||||
|
|
||||||
local function resetColors()
|
local function resetColors()
|
||||||
-- This case uses default OC palette, which is based & redpilled
|
-- This case uses default OC palette, which is based & redpilled
|
||||||
@ -67,13 +70,7 @@ local function resetColors()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function resetStars()
|
|
||||||
stars = {}
|
|
||||||
deadline = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
resetColors()
|
resetColors()
|
||||||
resetStars()
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -81,46 +78,54 @@ return {
|
|||||||
draw = function(object)
|
draw = function(object)
|
||||||
local hitsDeadline = computerUptime() >= deadline
|
local hitsDeadline = computerUptime() >= deadline
|
||||||
|
|
||||||
-- Spawning stars
|
-- Drawing background
|
||||||
while #stars < config.starAmount do
|
screen.drawRectangle(object.x, object.y, object.width, object.height, config.backgroundColor, 0, " ")
|
||||||
local rotationAngle = mathRandom(6265) / 1000
|
|
||||||
|
|
||||||
local targetX = mathCos(rotationAngle) * object.width * 0.75 + object.width / 2
|
-- Spawning missing stars
|
||||||
local targetY = mathSin(rotationAngle) * object.width * 0.375 + object.height / 2
|
local rotationAngle, targetX, targetY
|
||||||
|
|
||||||
|
while #stars < config.starAmount do
|
||||||
|
rotationAngle = mathRandom(6265) / 1000
|
||||||
|
targetX = mathCos(rotationAngle) * object.width * 0.75 + object.width / 2
|
||||||
|
targetY = mathSin(rotationAngle) * object.width * 0.375 + object.height / 2
|
||||||
|
|
||||||
table.insert(stars, {
|
table.insert(stars, {
|
||||||
targetX = targetX,
|
targetX = targetX,
|
||||||
targetY = targetY,
|
targetY = targetY,
|
||||||
startX = (targetX - object.width / 2) * config.offset + object.width / 2,
|
startX = (targetX - object.width / 2) * config.starOffset + object.width / 2,
|
||||||
startY = (targetY - object.height / 2) * config.offset + object.height / 2,
|
startY = (targetY - object.height / 2) * config.starOffset + object.height / 2,
|
||||||
way = 0.01,
|
speed = mathRandom(25, 75) / 1000 + 1,
|
||||||
speed = (mathRandom(25, 75) / 1000 + 1) * (config.speed / 100)
|
|
||||||
|
-- Defines the star lifetime in range (0.0; 1.0]
|
||||||
|
-- Shouldn't be zero, because it will be mutiplied to
|
||||||
|
-- simulate "speed up" effect on sides of screen
|
||||||
|
age = 0.01
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clear background
|
|
||||||
screen.drawRectangle(object.x, object.y, object.width, object.height, config.backgroundColor, 0, " ")
|
|
||||||
|
|
||||||
-- Drawing stars
|
-- Drawing stars
|
||||||
|
local star, x, y, xmod, ymod, color
|
||||||
|
|
||||||
local i = 1
|
local i = 1
|
||||||
while i <= #stars do
|
while i <= #stars do
|
||||||
local star = stars[i]
|
star = stars[i]
|
||||||
|
|
||||||
local x = star.startX + (star.targetX - star.startX) * star.way
|
x = star.startX + (star.targetX - star.startX) * star.age
|
||||||
local y = star.startY + (star.targetY - star.startY) * star.way
|
y = star.startY + (star.targetY - star.startY) * star.age
|
||||||
|
|
||||||
if x > object.width + 1 or x < 1 or y > object.height + 1 or y < 1 then
|
if x > object.width + 1 or x < 1 or y > object.height + 1 or y < 1 then
|
||||||
tableRemove(stars, i)
|
tableRemove(stars, i)
|
||||||
else
|
else
|
||||||
local xmod = x * 2;
|
xmod = x * 2;
|
||||||
xmod = (xmod - xmod % 1) % 2
|
xmod = (xmod - xmod % 1) % 2
|
||||||
|
|
||||||
local ymod = y * 4; ymod = (ymod - ymod % 1) % 4
|
ymod = y * 4; ymod = (ymod - ymod % 1) % 4
|
||||||
|
|
||||||
local color = star.way * 4.0156862745098 * #colors
|
color = star.age * #colors * config.starBrightness
|
||||||
color = colors[color - color % 1 + 1] or colors[#colors]
|
color = colors[color - color % 1 + 1] or colors[#colors]
|
||||||
|
|
||||||
if star.way < 0.3 then
|
-- Small stars
|
||||||
|
if star.age < 0.3 then
|
||||||
if xmod == 0 then
|
if xmod == 0 then
|
||||||
if ymod == 0 then char = braille1
|
if ymod == 0 then char = braille1
|
||||||
elseif ymod == 1 then char = braille3
|
elseif ymod == 1 then char = braille3
|
||||||
@ -134,6 +139,7 @@ return {
|
|||||||
else char = braille8
|
else char = braille8
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
-- Big stars
|
||||||
else
|
else
|
||||||
if ymod < 2 then
|
if ymod < 2 then
|
||||||
char = braille9
|
char = braille9
|
||||||
@ -146,13 +152,13 @@ return {
|
|||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
if hitsDeadline then
|
if hitsDeadline then
|
||||||
star.way = star.way * star.speed
|
star.age = star.age * star.speed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if hitsDeadline then
|
if hitsDeadline then
|
||||||
deadline = computerUptime() + config.delay
|
deadline = computerUptime() + 0.05
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
@ -169,7 +175,7 @@ return {
|
|||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
local amountSlider = layout:addChild(
|
local starAmountSlider = layout:addChild(
|
||||||
GUI.slider(
|
GUI.slider(
|
||||||
1, 1,
|
1, 1,
|
||||||
36,
|
36,
|
||||||
@ -177,37 +183,38 @@ return {
|
|||||||
0xE1E1E1,
|
0xE1E1E1,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xA5A5A5,
|
0xA5A5A5,
|
||||||
10, 200,
|
10, 500,
|
||||||
config.starAmount,
|
config.starAmount,
|
||||||
false,
|
false,
|
||||||
"Star amount: "
|
"Star amount: "
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
amountSlider.roundValues = true
|
starAmountSlider.roundValues = true
|
||||||
amountSlider.onValueChanged = function()
|
starAmountSlider.onValueChanged = function()
|
||||||
config.starAmount = math.floor(amountSlider.value)
|
config.starAmount = math.floor(starAmountSlider.value)
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
local speedSlider = layout:addChild(GUI.slider(
|
local starBrightnessSlider = layout:addChild(
|
||||||
|
GUI.slider(
|
||||||
1, 1,
|
1, 1,
|
||||||
36,
|
36,
|
||||||
0x66DB80,
|
0x66DB80,
|
||||||
0xE1E1E1,
|
0xE1E1E1,
|
||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xA5A5A5,
|
0xA5A5A5,
|
||||||
100, 200,
|
50, 300,
|
||||||
config.speed,
|
config.starBrightness * 100,
|
||||||
false,
|
false,
|
||||||
"Speed: ",
|
"Star brightness: ",
|
||||||
"%"
|
"%"
|
||||||
))
|
)
|
||||||
|
)
|
||||||
|
|
||||||
speedSlider.roundValues = true
|
starBrightnessSlider.roundValues = true
|
||||||
speedSlider.onValueChanged = function()
|
starBrightnessSlider.onValueChanged = function()
|
||||||
config.speed = speedSlider.value
|
config.starBrightness = starBrightnessSlider.value / 100
|
||||||
resetStars()
|
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -219,7 +226,7 @@ return {
|
|||||||
0xFFFFFF,
|
0xFFFFFF,
|
||||||
0xA5A5A5,
|
0xA5A5A5,
|
||||||
0, 100,
|
0, 100,
|
||||||
config.offset * 100,
|
config.starOffset * 100,
|
||||||
false,
|
false,
|
||||||
"Offset: ",
|
"Offset: ",
|
||||||
"%"
|
"%"
|
||||||
@ -227,8 +234,7 @@ return {
|
|||||||
|
|
||||||
offsetSlider.roundValues = true
|
offsetSlider.roundValues = true
|
||||||
offsetSlider.onValueChanged = function()
|
offsetSlider.onValueChanged = function()
|
||||||
config.offset = offsetSlider.value / 100
|
config.starOffset = offsetSlider.value / 100
|
||||||
resetStars()
|
|
||||||
saveConfig()
|
saveConfig()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user