View difference between Paste ID: 2rxRapK4 and v2HPu3C7
SHOW: | | - or go back to the newest paste.
1-
local nfte = require "nfte"
1+
2
if mon then
3
	mon.setTextScale(0.5)
4
	term.redirect(mon)
5-
    mon.setTextScale(0.5)
5+
6-
    term.redirect(mon)
6+
7
-- adjusts walls of screen so that it will bounce further/closer to the boundries of the screen
8
local xMargin, yMargin = 0, 0
9
10
local redrawDelay = nil
11
local changeColors = true
12-
    xvel = 1, --math.random(0, 3) - 1.5,
12+
13-
    yvel = 1, --math.random(0, 3) - 1.5,
13+
14-
    x = scr_x / 2,
14+
15-
    y = scr_y / 2,
15+
local floor, ceil = math.floor, math.ceil
16-
    img = nfte.loadImage("dvdlogo.nft")
16+
17
if scr_x >= 60 and scr_y >= 25 then
18
	redrawDelay = redrawDelay or 0.05
19-
local render = function()
19+
else
20-
    term.clear()
20+
	redrawDelay = redrawDelay or 0.1
21-
    nfte.drawImage(logo.img, math.floor(logo.x), math.floor(logo.y))
21+
22
23
local getSize = function(image)
24
	local x, y = 0, #image[1]
25
	for y = 1, #image[1] do
26
		x = max(x, #image[1][y])
27-
    local imgXsize, imgYsize = nfte.getSize(logo.img)
27+
	end
28-
    local xWall = scr_x - imgXsize + 1
28+
	return x, y
29-
    local yWall = scr_y - imgYsize + 1
29+
30-
    logo.x = min(max(logo.x + logo.xvel, 1), xWall)
30+
31-
    logo.y = min(max(logo.y + logo.yvel, 1), yWall)
31+
local drawImage = function(image, x, y, terminal)
32-
    
32+
	terminal = terminal or term.current()
33-
    if math.floor(logo.x) == 1 or math.floor(logo.x) == xWall then
33+
	local cx, cy = terminal.getCursorPos()
34-
        logo.xvel = -logo.xvel
34+
	for iy = 0, #image[1] + 1 do
35-
    end
35+
		terminal.setCursorPos(x - 1, y + (iy - 1))
36-
    if math.floor(logo.y) == 1 or math.floor(logo.y) == yWall then
36+
		if image[1][iy] then
37-
        logo.yvel = -logo.yvel
37+
			terminal.blit(
38-
    end
38+
				" " .. image[1][iy] .. " ",
39-
    render()
39+
				"f" .. image[2][iy] .. "f",
40
				"f" .. image[3][iy] .. "f"
41
			)
42
		else
43-
    tick()
43+
			terminal.clearLine()
44-
    sleep(0.05)
44+
		end
45-
end
45+
	end
46
	terminal.setCursorPos(cx,cy)
47
end
48
49
local colorSwap = function(image, text, back)
50
	local output = {{},{},{}}
51
	for y = 1, #image[1] do
52
		output[1][y] = image[1][y]
53
		output[2][y] = image[2][y]:gsub(".", text)
54
		output[3][y] = image[3][y]:gsub(".", back or text)
55
	end
56
	return output
57
end
58
59
local logo = {
60
	xvel = (math.random(0, 1) * 2) - 1,
61
	yvel = (math.random(0, 1) * 2) - 1,
62
	x = floor(scr_x / 2),
63
	y = floor(scr_y / 2),
64
	img = {
65
		{
66
			"  —ƒƒƒƒƒƒƒƒƒ”     Ÿƒƒƒƒƒƒƒ€€",
67
			"  ‚ƒƒƒ€ˆƒƒ€€    ‡€€‡ƒƒƒƒ‹€‚",
68
			" —€—€€€€€  ”€• Ÿ€Ÿ€€  •€•",
69
			" €€€‡€—  ‚€€‡€€‡  —€—  Ÿ€",
70
			"—€€ƒƒ€€‡    ”€€Ÿ   €‚ƒ€Ÿ ",
71
			"‚ƒƒƒƒƒ      ‚€‡     ƒƒƒƒƒ   ",
72
			"      ƒƒƒ‚ƒƒƒ        ",
73
			" ƒ€€€€€€Ÿ€€€€€€€‚ƒ   ",
74
			"•€€€€€€ˆ‘€€€€€€€€€Œ€€€€€€€•  ",
75
			" ƒ€€€€€€‚ƒƒƒƒƒ€€€€€€€Ÿƒ   ",
76
			"      ƒƒƒƒƒƒƒƒ        ",
77
		}, {
78
			"00ffffffffff000000fffffffffff",
79
			"000000f0f00000000f000000000f0",
80
			"0f00fff0000f000ff000ff0000f00",
81
			"0f00fff0000000f00000f0000ff00",
82
			"f00ff0000000f0000000f0fff0000",
83
			"00000000000000000000000000000",
84
			"000000fffffffffffffff00000000",
85
			"0fff0000000000000000000fff000",
86
			"f000000f0ffffffffff0000000000",
87
			"000f000000ffffff0000000000000",
88
			"00000000000000000000000000000",
89
		}, {
90
			"ff0000000000ffffff000000000ff",
91
			"ffffff000ff00ffff000ffffff00f",
92
			"f00ffff00ff00ff000fff00fff00f",
93
			"f00fff00ffff00000fff00fff000f",
94
			"0000000fffff000fffff000000fff",
95
			"fffffffffffff0fffffffffffffff",
96
			"ffffff000000000000000ffffffff",
97
			"f000000000ffffff0000000000fff",
98
			"00000000ffffffffff00000000fff",
99
			"fff00000000000000000000ffffff",
100
			"fffffffffffffffffffffffffffff",
101
		}
102
	}
103
}
104
105
local imgXsize, imgYsize = getSize(logo.img)
106
local xWall, yWall
107
108
local render = function(colorReplace)
109
	if colorReplace then
110
		drawImage(
111
			colorSwap(logo.img, {["0"] = colorReplace}, {["0"] = colorReplace}),
112
			floor(logo.x),
113
			floor(logo.y)
114
		)
115
	else
116
		drawImage(
117
			logo.img,
118
			floor(logo.x),
119
			floor(logo.y)
120
		)
121
	end
122
end
123
124
local color = math.random(1, 15)
125
126
local tick = function()
127
	scr_x, scr_y = term.getSize()
128
	xWall = scr_x - imgXsize + 1 - xMargin
129
	yWall = scr_y - imgYsize + 1 - yMargin
130
	logo.x = min(max(logo.x + logo.xvel, 1 + xMargin), xWall)
131
	logo.y = min(max(logo.y + logo.yvel, 1 + yMargin), yWall)
132
133
	if floor(logo.x) == (1 + xMargin) or floor(logo.x) == xWall then
134
		logo.xvel = -logo.xvel
135
		color = math.random(1, 15)
136
	end
137
	if floor(logo.y) == (1 + yMargin) or floor(logo.y) == yWall then
138
		logo.yvel = -logo.yvel
139
		color = math.random(1, 15)
140
	end
141
	if changeColors then
142
		render(string.sub("0123456789abcdef", color, color))
143
	else
144
		render()
145
	end
146
end
147
148
term.setBackgroundColor(colors.black)
149
term.clear()
150
151
local evt
152
local tID = os.startTimer(redrawDelay)
153
while true do
154
	evt = {os.pullEventRaw()}
155
	if evt[1] == "timer" and evt[2] == tID then
156
		tick()
157
		tID = os.startTimer(redrawDelay)
158
	elseif evt[1] == "terminate" then
159
		render("8")
160
		sleep(0.05)
161
		render("7")
162
		sleep(0.05)
163
		term.clear()
164
		break
165
	end
166
end
167
168
return 0