-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfancy-printing.lua
31 lines (24 loc) · 965 Bytes
/
fancy-printing.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-->8
-- fancy printing
function print_in_box(message, x, y)
local pico8_letter_width = 4
local message_width_px = #message * pico8_letter_width
local box_left = x - message_width_px / 2 - pico8_letter_width
local box_right = x + message_width_px / 2 + 2
local box_top = y - pico8_letter_width
local box_bottom = y + pico8_letter_width * 2
local box_color = 6
rectfill(box_left + 1, box_top + 1, box_right - 1, box_bottom - 1, box_color)
rectfill(box_left, box_top + 2, box_right, box_bottom - 2, box_color)
print(message, x - message_width_px / 2, y, 1)
end
function centered_print(text, x, y, col, outline_col)
outlined_print(text, x - #text * 2, y, col, outline_col)
end
function outlined_print(text, x, y, col, outline_col)
print(text, x - 1, y, outline_col)
print(text, x + 1, y, outline_col)
print(text, x, y - 1, outline_col)
print(text, x, y + 1, outline_col)
print(text, x, y, col)
end