Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local src = {}
- src.lang = "java"
- src.mainclass = "Start"
- local soundQueue = {}
- local alreadImport = {}
- function readImportsFromFile(data)
- if src.lang == "java" then
- local ilist = {}
- for import in data:gmatch("import ([%d%w%._]+);") do
- ilist[#ilist+1] = import:gsub("%.","/")..".java"
- end
- return ilist
- end
- end
- function readFile(file)
- if not love.filesystem.exists(file) then return end
- if alreadImport[file] then return end
- local data = love.filesystem.read(file)
- local imports = readImportsFromFile(data)
- for i, v in pairs(imports) do
- table.insert(fileQueue,1,"src/"..v)
- end
- for i=1,#data do
- table.insert(soundQueue,data:byte(i)/(255/2))
- end
- alreadImport[file] = true
- end
- function love.load()
- SQ50 = love.sound.newSoundData( 16, 880*16, 16 )
- for n = 0, 15 do SQ50:setSample( n , n%2 == 1 and 1 or -1 ) end
- squ = love.audio.newSource("harp.ogg","static")
- dta = 1/10
- --squ:setLooping(true)
- fileQueue = {"src/Start.java"}
- end
- function love.update(dt)
- if fileQueue[1] then
- local f = fileQueue[1]
- table.remove(fileQueue,1)
- readFile(f)
- end
- if soundQueue[1] then
- if dta-dt <= 0 then
- squ:stop()
- squ:setPitch(soundQueue[1])
- squ:play()
- table.remove(soundQueue,1)
- dta = 1/10
- else
- dta = dta-dt
- end
- end
- end
- function love.draw()
- love.graphics.print((fileQueue[1] or "")..(soundQueue[1] or ""),0,0)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement