forked from TRASEVOL-DOG/sugarcoat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.lua
118 lines (86 loc) · 2.49 KB
/
demo.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
require("sugarlove/sugarlove")
local S = sugar.S
S.using_package(S, true)
local px,py
local dy
function love.load()
init_sugar("Hello world!", 128, 128, 3)
--screen_render_integer_scale(false)
--screen_render_stretch(true)
--screen_resizeable(true, 3)
screen_shader([[
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
vec4 effect(vec4 color, Image texture, vec2 coords, vec2 screen_coords)
{
vec4 col = Texel_color(texture, coords);
vec2 co = mod(coords * SCREEN_SIZE, .5);
float k = 1.0 - max(co.x * co.x, co.y * co.y);
return (k*.75 + 0.75) * col;
}
]])
load_png("spritesheet", "test.png", nil, true)
register_btn(0, 0, {input_id("keyboard", "left"),
input_id("keyboard", "a")})
register_btn(1, 0, {input_id("keyboard", "right"),
input_id("keyboard", "d")})
register_btn(2, 0, {input_id("keyboard", "up"),
input_id("keyboard", "w")})
register_btn(3, 0, {input_id("keyboard", "down"),
input_id("keyboard", "s")})
register_btn(4, 0, input_id("keyboard", "return"))
register_btn(5, 0, input_id("mouse_button", "scroll_y"))
px, py = 64, 64
dy = 64
log("init done!")
end
function love.update()
screen_shader_input({ time = t() })
if btn(0) then px = px - 1 end
if btn(1) then px = px + 1 end
if btn(2) then py = py - 1 end
if btn(3) then py = py + 1 end
dy = dy + btnv(5)
end
function love.draw()
-- camera()
color(0)
cls()
color(1)
rectfill(32,32,96,96)
circfill(64,64,32,2)
rect(34,34,98,98,3)
circ(66,66,32)
pset(32,32,2)
pset(96,96,2)
local a = t()/4
trifill(
64+32*cos(a), 64+32*sin(a),
64+32*cos(a+0.333), 64+32*sin(a+0.333),
64+32*cos(a+0.666), 64+32*sin(a+0.666), 3
)
tri(
64+36*cos(a), 64+36*sin(a),
64+36*cos(a+0.333), 64+36*sin(a+0.333),
64+36*cos(a+0.666), 64+36*sin(a+0.666), 3
)
printp(0x4440, 0x4140, 0x4240, 0x4400)
printp_color(3,0,1)
pprint("Hello world!", 0, 0)
printp(0x2120, 0x3230, 0x0300, 0x0000)
local str = "This is SugarLOVE!"
local x, y = 1, 12
for i = 1, #str do
local c = str:sub(i,i)
pprint(c, x+3*sin(-a * 1.1 + i/5), y + 3*cos(-a * 2 + i/5))
x = x + str_px_width(c)
end
spr(1, btnp(5) and 4 or 0, dy)
if btnr(4) then
aspr(0, px, py, -a, 2, 2, nil, nil, 3, 3)
elseif btn(4) then
aspr(0, px, py, -a, 2, 2, nil, nil, 2, 2)
else
aspr(0, px, py, -a, 2, 2)
end
end