-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
310 lines (249 loc) · 9.71 KB
/
main.lua
File metadata and controls
310 lines (249 loc) · 9.71 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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
--love.filesystem.setIdentity(love.filesystem.getIdentity(),false)
local discordRPC = require "discordRPC"
local appId = require("applicationId")
local presence
camera = require 'lib/camera'
local cam = camera()
urutora = require 'lib/urutora'
local u = urutora:new()
local mainUI = urutora:new()
playGame = require("pressedPlay")
function love.mousemoved(x, y, dx, dy) u:moved(x, y, dx, dy) mainUI:moved(x, y, dx, dy) end
function love.mousereleased(x, y, button) u:released(x, y) mainUI:released(x, y) end
function love.textinput(text) u:textinput(text) mainUI:textinput(text) end
function love.keypressed(k, scancode, isrepeat) u:keypressed(k, scancode, isrepeat) mainUI:keypressed(k, scancode, isrepeat) end
local width = nil
local height = nil
local UI_COLOR = {126/255,99/255,118/255}
local camX = 0
local camY = 0
local camXstart = 0
local camYstart = 0
local scale = 1
local scene = "main"
local offset = -500
local name_project = nil
local create = mainUI.button({
text = '+ New Project',
x = 500, y = 65,
w = 150,
h = 50,
})
local start = mainUI.button({ text = "NEXT", w = 100, h = 35 })
local stopp = mainUI.button({ text = "CANCEL", w = 100, h = 35 }):setStyle({ bgColor = {0.7, 0.2, 0.2} })
local projectname = mainUI.text({ text = "Project Name", w = 200, h = 35})
local ex = mainUI.text({ text = "1080", w = 75, h = 35})
local why = mainUI.text({ text = "720", w = 75, h = 35})
local threeDee = mainUI.toggle({ text = "Patformer Gravity", false, w = 165, h = 35})
local engineType = mainUI.multi({ items = {"2D Game","3D Game (g3d library)", "DS game (microLua)"}, w = 165, h = 35})
function love.load(arg, otherarg)
------------------------------------------------------------
discordRPC.initialize(appId, true)
local now = os.time(os.date("*t"))
presence = {
state = "In the menus, viewing their projects...",
largeImageKey = "hyperpsad"
}
nextPresenceUpdate = 0
------------------------------------------------------------
behavior = love.graphics.newImage("assets/behavior.png")
love.filesystem.setIdentity(love.filesystem.getIdentity(),false)
local clickMe = u.button({
text = 'Play',
x = 10, y = 10,
w = 100,
h = 100,
})
local export = u.button({
text = 'Export',
x = 125, y = 10,
w = 100,
h = 100,
})
width = u.text({
text = '1080',
x = 250, y = 50,
w = 50,
})
height = u.text({
text = '720',
x = 350, y = 50,
w = 50,
})
clickMe:action(function(e)
if scene == "editor" then
setConfLua()
e.target.text = 'playtesting...'
playGame.load(arg, otherarg)
end
end)
export:action(function(e)
if scene == "editor" then
setConfLua()
e.target.text = 'exporting...'
--love.filesystem.write('EXPORT-main.lua', playGame.secondary_main_dot_lua)
print(playGame.secondary_main_dot_lua);
print(playGame.secondary_conf_dot_lua);
end
end)
u:add(clickMe)
u:add(export)
u:add(width)
u:add(height)
create:action(function(e)
if scene == "main" then
print("test")
offset = 50
end
end)
stopp:action(function(e)
if scene == "main" then
print("test")
offset = -500
end
end)
start:action(function(e)
if scene == "main" then
name_project = projectname.text
scene = "editor"
presence = {
state = "Editing the project - ".. name_project,
largeImageKey = "edit",
smallImageKey = "hyperpsad"
}
end
end)
mainUI:add(create)
mainUI:add(stopp)
mainUI:add(start)
mainUI:add(projectname)
mainUI:add(ex)
mainUI:add(why)
mainUI:add(threeDee)
mainUI:add(engineType)
end
function love.update(dt)
------------------------------------------------------
if nextPresenceUpdate < love.timer.getTime() then
discordRPC.updatePresence(presence)
nextPresenceUpdate = love.timer.getTime() + 2.0
end
discordRPC.runCallbacks()
------------------------------------------------------
u:update(dt)
mainUI:update(dt)
--camX = (camX + dt) * 1
--cam:move(camX, camY)
if love.mouse.isDown(3) then
local currentX, currentY = love.mouse.getPosition()
camX = (currentX - camXstart)*-1
camY = (currentY - camYstart)*-1
--directionY = camYstart - CurrentY
--camX = (camX + directionX)/10
--camY = (camY + directionY)/10
cam:move(camX, camY)
camXstart = currentX
camYstart = currentY
end
--scenes--
if scene == "main" then
create.x = ((love.graphics.getWidth() - create.w)-10)
start.x = (love.graphics.getWidth()/2 - start.w/2) + 55
stopp.x = (love.graphics.getWidth()/2 - stopp.w/2) - 55
projectname.x = (love.graphics.getWidth()/2 - projectname.w/2)
ex.x = (love.graphics.getWidth()/2 - ex.w/2)-50
why.x = (love.graphics.getWidth()/2 - why.w/2)+50
threeDee.x = (love.graphics.getWidth()/2 - threeDee.w/2)
engineType.x = (love.graphics.getWidth()/2 - engineType.w/2)
projectname.y = 150 +offset
ex.y = 250 +offset
why.y = 250 +offset
threeDee.y = 300 +offset
engineType.y = 350 +offset
stopp.y = 400 +offset
start.y = 400 +offset
end
end
function love.draw()
love.graphics.setNewFont("font/FreeSans.ttf", 25)
if scene == "editor" then
cam:attach()
love.graphics.scale(scale,scale)
love.graphics.setColor(UI_COLOR)
love.graphics.draw(behavior, 250, 250, 0, 0.15, 0.15)
cam:detach()
love.graphics.setBackgroundColor(54/255,61/255,69/255)
love.graphics.setColor(34/255,38/255,41/255)
love.graphics.rectangle("fill", 0, 0, 225, love.graphics.getHeight())
love.graphics.setColor(51/255,51/255,51/255)
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), 120)
love.graphics.setColor(72/255,77/255,81/255)
love.graphics.rectangle("fill", 0, 120, love.graphics.getWidth(), 5)
love.graphics.setColor(1,1,1)
u:draw()
end
if scene == "main" then
love.graphics.setBackgroundColor(54/255,61/255,69/255)
love.graphics.setColor(51/255,51/255,51/255)
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), 50)
love.graphics.setColor(72/255,77/255,81/255)
love.graphics.rectangle("fill", 0, 50, love.graphics.getWidth(), 5)
love.graphics.setColor(1,1,1)
love.graphics.setColor(51/255,51/255,51/255)
love.graphics.rectangle("fill", 0, love.graphics.getHeight() - 50, love.graphics.getWidth(), 50)
love.graphics.setColor(72/255,77/255,81/255)
love.graphics.rectangle("fill", 0, love.graphics.getHeight() - 50, love.graphics.getWidth(), 5)
love.graphics.setColor(1,1,1)
local widthBox = 450
local heightBox = 400
love.graphics.setColor(49/255,45/255,52/255)
love.graphics.rectangle("fill", love.graphics.getWidth()/2 - widthBox/2, 70 + offset, widthBox, heightBox)
love.graphics.setColor(1,1,1)
love.graphics.setNewFont("font/FreeSans.ttf", 23)
love.graphics.setColor(6/255,178/255,116/255)
love.graphics.printf("Create New Project", love.graphics.getWidth()/2 - 100, 100 +offset, 200,"center")
love.graphics.setColor(95/255,91/255,98/255)
love.graphics.setNewFont("font/FreeSans.ttf", 18)
love.graphics.printf("Game Resolution (Width and Height)", love.graphics.getWidth()/2 - 200, 210 +offset, 400,"center")
love.graphics.setColor(1,1,1)
mainUI:draw()
love.graphics.setColor(143/255,143/255,143/255)
love.graphics.setNewFont("font/FreeSans.ttf", 25)
love.graphics.printf("All Projects", love.graphics.getWidth()/2 - 100, 60, 200,"center")
local offset = 100
local Items = 4
love.graphics.setNewFont("font/FreeSans.ttf", 20)
love.graphics.printf("Projects", (love.graphics.getWidth()/Items - offset), love.graphics.getHeight() - 40, 200,"center")
love.graphics.printf("Settings", (love.graphics.getWidth()/Items - offset)*2, love.graphics.getHeight() - 40, 200,"center")
love.graphics.printf("Packages", (love.graphics.getWidth()/Items - offset)*3, love.graphics.getHeight() - 40, 200,"center")
love.graphics.printf("Help", (love.graphics.getWidth()/Items - offset)*4, love.graphics.getHeight() - 40, 200,"center")
end
end
function setConfLua()
playGame.secondary_conf_dot_lua = [[
function love.conf(t)
t.window.width = ]].. width.text..
[[ t.window.height = ]].. height.text..
[[ t.console = false
end
]]
end
function love.mousepressed(x, y, button, istouch)
if button == 3 and scene == "editor" then -- Versions prior to 0.10.0 use the MouseConstant 'l'
camXstart = x
camYstart = y
print(x)
end
u:pressed(x, y)
mainUI:pressed(x, y)
end
function love.wheelmoved(x, y)
if y > 0 and scene == "editor" then
scale = scale + y/15
elseif y < 0 and scene == "editor" then
scale = scale + y/15
end
u:wheelmoved(x, y)
mainUI:wheelmoved(x, y)
end
--filler--