Skip to content

Commit 93be3a9

Browse files
committed
x
0 parents  commit 93be3a9

File tree

4 files changed

+280
-0
lines changed

4 files changed

+280
-0
lines changed

doc.lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
изи - вручную
2+
привязать к bpm

main.lua

+231
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
local isDebug=arg[#arg] == "-debug"
2+
if isDebug then require("mobdebug").start() end
3+
4+
5+
6+
local is_fullscreen=true
7+
w=nil
8+
h=nil
9+
rnd=love.math.random
10+
draw=love.graphics.draw
11+
12+
local entities={}
13+
14+
stars = {}
15+
stars2 = {}
16+
local max_stars = 100
17+
local stars_r
18+
local stars_g
19+
local stars_b
20+
21+
local stars2_r
22+
local stars2_g
23+
local stars2_b
24+
25+
26+
local stars_refresh=function()
27+
for i=1, max_stars do
28+
local x = rnd(w)
29+
local y = rnd(h)
30+
stars[i] = {x, y}
31+
32+
x = rnd(w)
33+
y = rnd(h)
34+
stars2[i] = {x, y}
35+
end
36+
37+
stars_r=rnd()
38+
stars_g=rnd()
39+
stars_b=rnd()
40+
41+
stars2_r=rnd()
42+
stars2_g=rnd()
43+
stars2_b=rnd()
44+
end
45+
46+
47+
local stars_demo=function()
48+
if rnd()<0.02 then
49+
stars_refresh()
50+
end
51+
52+
love.graphics.setColor(stars_r,stars_g,stars_b)
53+
love.graphics.points(stars)
54+
55+
love.graphics.setColor(stars2_r,stars2_g,stars2_b)
56+
love.graphics.points(stars2)
57+
end
58+
59+
60+
61+
local update_size=function()
62+
w = love.graphics.getWidth()
63+
h = love.graphics.getHeight()
64+
end
65+
66+
67+
68+
69+
local lines_demo_1=function()
70+
local x1=rnd(w)
71+
local x2=rnd(w)
72+
73+
local y1=rnd(h)
74+
local y2=rnd(h)
75+
love.graphics.line(x1,y1,x2,y2)
76+
end
77+
78+
79+
local lines_demo_2=function()
80+
local x1=rnd(w)
81+
local x2=rnd(w)
82+
local x3=rnd(w)
83+
84+
local y1=rnd(h)
85+
local y2=rnd(h)
86+
local y3=rnd(h)
87+
love.graphics.line(x1,y1,x2,y2)
88+
love.graphics.line(x2,y2,x3,y3)
89+
end
90+
91+
local lines_demo_3=function()
92+
local x1=rnd(w)
93+
local x2=rnd(w)
94+
local y1=rnd(h)
95+
96+
love.graphics.setColor( 1,0, 0, 1 )
97+
love.graphics.line(x1,y1,x2,y1)
98+
end
99+
100+
local lines_demo_4=function()
101+
local x1=rnd(w)
102+
local y2=rnd(w)
103+
local y1=rnd(h)
104+
105+
love.graphics.setColor( 0,1, 1, 1 )
106+
love.graphics.line(x1,y1,x1,y2)
107+
end
108+
109+
local lines_demo_5=function()
110+
local x1=rnd(w)
111+
local x2=rnd(w)
112+
local x3=rnd(w)
113+
local x4=rnd(w)
114+
115+
local y1=rnd(h)
116+
local y2=rnd(h)
117+
local y3=rnd(h)
118+
local y4=rnd(h)
119+
120+
love.graphics.setColor( rnd(),rnd(), rnd(), 1 )
121+
122+
love.graphics.line(x1,y1,x2,y2)
123+
love.graphics.line(x2,y2,x3,y3)
124+
love.graphics.line(x3,y3,x4,y4)
125+
end
126+
127+
128+
local lines_demo_6=function()
129+
local x1=rnd(w)
130+
local y2=rnd(w)
131+
local y1=rnd(h)
132+
133+
love.graphics.setColor( 0,1, 1, 1 )
134+
love.graphics.line(x1,y1,x1,y2)
135+
end
136+
137+
138+
---
139+
140+
rnd2=function()
141+
return rnd()-0.5
142+
end
143+
144+
145+
146+
local lines7={}
147+
148+
149+
local init_lines_7=function()
150+
--x1,y1,x2,y2,r,g,b
151+
local new_line=function()
152+
return {rnd(w),rnd(h),rnd(w),rnd(h),rnd(),rnd(),rnd()}
153+
end
154+
155+
lines7[1]=new_line()
156+
lines7[2]=new_line()
157+
lines7[3]=new_line()
158+
end
159+
160+
161+
local lines_demo_7=function()
162+
for k,line in pairs(lines7) do
163+
line[1]=line[1]+rnd2()
164+
line[2]=line[2]+rnd2()
165+
line[3]=line[3]+rnd2()
166+
line[4]=line[4]+rnd2()
167+
168+
love.graphics.setColor(line[5],line[6],line[7], 1 )
169+
love.graphics.line(line[1],line[2],line[3],line[4])
170+
end
171+
172+
173+
174+
end
175+
176+
177+
---
178+
love.keypressed=function(key)
179+
if key=="escape" then
180+
is_fullscreen=not is_fullscreen
181+
love.window.setFullscreen(is_fullscreen, "desktop")
182+
update_size()
183+
end
184+
end
185+
186+
187+
love.update=function()
188+
player.update()
189+
end
190+
191+
192+
193+
194+
local bg
195+
local bg_y=-3000
196+
bg_draw=function()
197+
bg_y=bg_y+1
198+
draw(bg,0,bg_y)
199+
end
200+
201+
202+
love.draw=function()
203+
love.graphics.setColor( 1,1, 1, 1 )
204+
205+
-- out of style
206+
--bg_draw()
207+
lines_demo_1()
208+
lines_demo_2()
209+
lines_demo_3()
210+
lines_demo_4()
211+
lines_demo_5()
212+
lines_demo_6()
213+
lines_demo_7()
214+
stars_demo()
215+
-- love.graphics.polygon('line', 0, 0, 200, 400, 200, 100, 100,100, 90,70)
216+
player.draw()
217+
218+
end
219+
220+
221+
love.load=function()
222+
player=require("player")
223+
224+
stars_refresh()
225+
226+
love.window.setFullscreen(is_fullscreen, "desktop")
227+
228+
update_size()
229+
init_lines_7()
230+
-- bg=love.graphics.newImage("res/bg1.png")
231+
end

player.lua

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
local player={}
2+
3+
4+
local x=100
5+
local y=100
6+
7+
local speed=1
8+
9+
10+
player.draw=function()
11+
12+
local top_x=x
13+
local top_y=y-20
14+
15+
local left_x=x-10
16+
local left_y=y+10
17+
18+
local right_x=x+10
19+
local right_y=y+10
20+
21+
love.graphics.polygon("line",top_x,top_y,left_x,left_y,right_x,right_y)
22+
23+
local shift=100
24+
love.graphics.polygon("line",top_x+shift,top_y+shift,left_x+shift,left_y+shift,right_x+shift,right_y+shift)
25+
end
26+
27+
28+
player.update=function()
29+
if love.keyboard.isDown("d") then
30+
x=x+speed
31+
end
32+
if love.keyboard.isDown("a") then
33+
x=x-speed
34+
end
35+
36+
if love.keyboard.isDown("w") then
37+
y=y-speed
38+
end
39+
if love.keyboard.isDown("s") then
40+
y=y+speed
41+
end
42+
43+
end
44+
45+
46+
47+
return player

res/bg1.png

6.09 MB
Loading

0 commit comments

Comments
 (0)