-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
50 lines (44 loc) · 1.48 KB
/
main.lua
File metadata and controls
50 lines (44 loc) · 1.48 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
local loveterm = require "loveterm"
local codes = require "extra/cp437"
local color = require "extra/color"
local palette = color.c64
function love.load()
-- Create a new screen object
screen = loveterm.create(
"tilesets/CGA8x8thick.png",
math.floor(love.graphics.getWidth()/8),
math.floor(love.graphics.getHeight()/8))
-- Print a wrapped string to our screen at the coordinates 5, 5
screen:printf(
"LoveTerm is a small library for drawing 1-bit tiled " ..
"graphics, such as terminal emulators.",
5, 5, 21)
-- Now let's add a pink heart next to it
screen:set(codes.heart, palette.pink, screen.defaultbg, 3, 5)
-- We can easily iterate through all of the available tiles
for i = 0, 255 do
screen:setValue(i, (i % 16) + 32, math.floor(i / 16) + 5)
end
screen:rectangle("line", 31, 4, 17, 17)
-- ...or draw an image
local banteng = love.graphics.newImage("extra/Banteng.png")
screen:drawImage(
banteng,
{ alpha = 100 },
0, 0, 0,
screen.width/banteng:getWidth(),
screen.height/banteng:getHeight())
-- Here we show off the included Commodore 64 color scheme
local i = 0
for k, v in pairs(palette) do
if k ~= "white" and k ~= "lightgray" and k ~= "gray"
and k ~= "darkgray" and k ~= "black" then
screen:set(codes.smiley, v, screen.defaultbg, i*2 + 26, 24)
screen:set(0, palette.black, v, i*2 + 26, 26)
i = i + 1
end
end
end
function love.draw()
screen:draw()
end