mirror of
https://github.com/LDDestroier/CC/
synced 2025-04-29 05:53:09 +00:00
Update dvdlogo.lua
This commit is contained in:
parent
5092d45b25
commit
82d3e236a1
135
dvdlogo.lua
135
dvdlogo.lua
@ -4,11 +4,22 @@ if mon then
|
|||||||
term.redirect(mon)
|
term.redirect(mon)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- adjusts walls of screen so that it will bounce further/closer to the boundries of the screen
|
||||||
|
local xMargin, yMargin = 0, 0
|
||||||
|
|
||||||
|
local redrawDelay = nil
|
||||||
|
|
||||||
local scr_x, scr_y = term.getSize()
|
local scr_x, scr_y = term.getSize()
|
||||||
local max, min = math.max, math.min
|
local max, min = math.max, math.min
|
||||||
local floor, ceil = math.floor, math.ceil
|
local floor, ceil = math.floor, math.ceil
|
||||||
|
|
||||||
getSize = function(image)
|
if scr_x >= 60 and scr_y >= 25 then
|
||||||
|
redrawDelay = redrawDelay or 0.05
|
||||||
|
else
|
||||||
|
redrawDelay = redrawDelay or 0.1
|
||||||
|
end
|
||||||
|
|
||||||
|
local getSize = function(image)
|
||||||
local x, y = 0, #image[1]
|
local x, y = 0, #image[1]
|
||||||
for y = 1, #image[1] do
|
for y = 1, #image[1] do
|
||||||
x = max(x, #image[1][y])
|
x = max(x, #image[1][y])
|
||||||
@ -34,6 +45,16 @@ local drawImage = function(image, x, y, terminal)
|
|||||||
terminal.setCursorPos(cx,cy)
|
terminal.setCursorPos(cx,cy)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local colorSwap = function(image, text, back)
|
||||||
|
local output = {{},{},{}}
|
||||||
|
for y = 1, #image[1] do
|
||||||
|
output[1][y] = image[1][y]
|
||||||
|
output[2][y] = image[2][y]:gsub(".", text)
|
||||||
|
output[3][y] = image[3][y]:gsub(".", back or text)
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
local logo = {
|
local logo = {
|
||||||
xvel = (math.random(0, 1) * 2) - 1,
|
xvel = (math.random(0, 1) * 2) - 1,
|
||||||
yvel = (math.random(0, 1) * 2) - 1,
|
yvel = (math.random(0, 1) * 2) - 1,
|
||||||
@ -41,41 +62,41 @@ local logo = {
|
|||||||
y = floor(scr_y / 2),
|
y = floor(scr_y / 2),
|
||||||
img = {
|
img = {
|
||||||
{
|
{
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
"
",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
" ",
|
" ",
|
||||||
}, {
|
}, {
|
||||||
" 00000000000 ff000000ff ",
|
"00ffffffffff000000fffffffffff",
|
||||||
" ff0 0f00 f0f f000fff 00f",
|
"000000f0f00000000f000000000f0",
|
||||||
" 00 f00 000ff000 f00 00",
|
"0f00fff0000f000ff000ff0000f00",
|
||||||
"f00 ff00 f0f000 00 ff00",
|
"0f00fff0000000f00000f0000ff00",
|
||||||
" 0000 f0000000 ",
|
"f00ff0000000f0000000f0fff0000",
|
||||||
" f0 ",
|
"00000000000000000000000000000",
|
||||||
" fffffff000000fffffff ",
|
"000000fffffffffffffff00000000",
|
||||||
"ff000000000000000f000000ff ",
|
"0fff0000000000000000000fff000",
|
||||||
"f000000fff ffff0000000 ",
|
"f000000f0ffffffffff0000000000",
|
||||||
" 0000f0000000000000000000 ",
|
"000f000000ffffff0000000000000",
|
||||||
" 00000000 ",
|
"00000000000000000000000000000",
|
||||||
}, {
|
}, {
|
||||||
" 0000000000f 0000000000 ",
|
"ff0000000000ffffff000000000ff",
|
||||||
" 00f f00f 000 000ff00 f00",
|
"ffffff000ff00ffff000ffffff00f",
|
||||||
" 00 00f 00f000ff 00f 00",
|
"f00ffff00ff00ff000fff00fff00f",
|
||||||
"00f 000f 00000f 00 000f",
|
"f00fff00ffff00000fff00fff000f",
|
||||||
"00000ff 00ff 000000ff ",
|
"0000000fffff000fffff000000fff",
|
||||||
" 0f ",
|
"fffffffffffff0fffffffffffffff",
|
||||||
" 00000000000000000000 ",
|
"ffffff000000000000000ffffffff",
|
||||||
"00000000fffffffff000000000 ",
|
"f000000000ffffff0000000000fff",
|
||||||
"0000000000 0000000000f ",
|
"00000000ffffffffff00000000fff",
|
||||||
" ffff000000000000000fffff ",
|
"fff00000000000000000000ffffff",
|
||||||
" ffffffff ",
|
"fffffffffffffffffffffffffffff",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,21 +104,33 @@ local logo = {
|
|||||||
local imgXsize, imgYsize = getSize(logo.img)
|
local imgXsize, imgYsize = getSize(logo.img)
|
||||||
local xWall, yWall
|
local xWall, yWall
|
||||||
|
|
||||||
local render = function()
|
local render = function(colorReplace)
|
||||||
drawImage(logo.img, floor(logo.x), floor(logo.y))
|
if colorReplace then
|
||||||
|
drawImage(
|
||||||
|
colorSwap(logo.img, {["0"] = colorReplace}, {["0"] = colorReplace}),
|
||||||
|
floor(logo.x),
|
||||||
|
floor(logo.y)
|
||||||
|
)
|
||||||
|
else
|
||||||
|
drawImage(
|
||||||
|
logo.img,
|
||||||
|
floor(logo.x),
|
||||||
|
floor(logo.y)
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local tick = function()
|
local tick = function()
|
||||||
scr_x, scr_y = term.getSize()
|
scr_x, scr_y = term.getSize()
|
||||||
xWall = scr_x - imgXsize + 1
|
xWall = scr_x - imgXsize + 1 - xMargin
|
||||||
yWall = scr_y - imgYsize + 1
|
yWall = scr_y - imgYsize + 1 - yMargin
|
||||||
logo.x = min(max(logo.x + logo.xvel, 1), xWall)
|
logo.x = min(max(logo.x + logo.xvel, 1 + xMargin), xWall)
|
||||||
logo.y = min(max(logo.y + logo.yvel, 1), yWall)
|
logo.y = min(max(logo.y + logo.yvel, 1 + yMargin), yWall)
|
||||||
|
|
||||||
if floor(logo.x) == 1 or floor(logo.x) == xWall then
|
if floor(logo.x) == (1 + xMargin) or floor(logo.x) == xWall then
|
||||||
logo.xvel = -logo.xvel
|
logo.xvel = -logo.xvel
|
||||||
end
|
end
|
||||||
if floor(logo.y) == 1 or floor(logo.y) == yWall then
|
if floor(logo.y) == (1 + yMargin) or floor(logo.y) == yWall then
|
||||||
logo.yvel = -logo.yvel
|
logo.yvel = -logo.yvel
|
||||||
end
|
end
|
||||||
render()
|
render()
|
||||||
@ -106,7 +139,21 @@ end
|
|||||||
term.setBackgroundColor(colors.black)
|
term.setBackgroundColor(colors.black)
|
||||||
term.clear()
|
term.clear()
|
||||||
|
|
||||||
|
local evt
|
||||||
|
local tID = os.startTimer(redrawDelay)
|
||||||
while true do
|
while true do
|
||||||
tick()
|
evt = {os.pullEventRaw()}
|
||||||
sleep(0.05)
|
if evt[1] == "timer" and evt[2] == tID then
|
||||||
|
tick()
|
||||||
|
tID = os.startTimer(redrawDelay)
|
||||||
|
elseif evt[1] == "terminate" then
|
||||||
|
render("8")
|
||||||
|
sleep(0.05)
|
||||||
|
render("7")
|
||||||
|
sleep(0.05)
|
||||||
|
term.clear()
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user