Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tInfo={curTime=os.time(),elapsed=0,startTime=os.time(),log={left=-1,right=-1},messages={}}
- local tBindings={a="left",d="right"}
- local tMap={
- scrolled={0,0},
- player={
- pos={3,2},
- status="still",
- hitbox={},
- anim={
- still={
- "o",
- "|",
- "|",
- relative={1,3},
- },
- runRight={
- {
- " o ",
- " \\.",
- "/ ",
- relative={2,3},
- },
- {
- " o .",
- "<.-/",
- "/ > ",
- relative={2,3},
- },
- },
- runLeft={
- {
- " o ",
- "./ ",
- " \\",
- relative={2,3},
- },
- {
- ". o ",
- "\\-.>",
- " < \\",
- relative={3,3},
- },
- },
- }
- }
- }
- local oFile=io.open("map","r")
- while true do
- local sLine=oFile:read()
- if not sLine then break end
- table.insert(tMap,sLine)
- end
- oFile:close()
- while true do
- local tEvt={}
- local timer=os.startTimer(0.1)
- while true do
- local evts={os.pullEvent()}
- if evts[1]=="timer" and evts[2]==timer then
- break
- else
- tEvt[evts[1]]=tEvt[evts[1]] or {}
- table.insert(tEvt[table.remove(evts,1)],evts)
- end
- end
- tInfo.elapsed=tInfo.elapsed+(os.time()-tInfo.curTime)%24
- tInfo.curTime=os.time()
- while tEvt.char and tEvt.char[1] do
- local action=tBindings[table.remove(tEvt.char,1)[1]]
- if action and tInfo.log[action] then
- if tInfo.elapsed-tInfo.log[action]>0.02 then
- table.insert(tInfo.messages,{"pulse "..action,tInfo.elapsed,0.04})
- else
- end
- tInfo.log[action]=tInfo.elapsed
- end
- end
- term.clear()
- local size={term.getSize()}
- for k,v in ipairs(tMap) do
- term.setCursorPos(1,size[2]-#tMap+k-1)
- write(v:sub(1+tMap.scrolled[1],size[1]+tMap.scrolled[1]))
- end
- local tCurrAnim=tMap.player.anim[tMap.player.status]
- if type(tCurrAnim[1])=="string" then
- elseif type(tCurrAnim[1])=="table" then
- end
- term.setCursorPos(1,1)
- print(tInfo.elapsed)
- local at=1
- while tInfo.messages[at] do
- print(tInfo.messages[at][1])
- if tInfo.elapsed-tInfo.messages[at][2]>=tInfo.messages[at][3] then
- table.remove(tInfo.messages,at)
- at=at-1
- end
- at=at+1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment