Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- m=peripheral.wrap("bottom")
- ship={"^","v","<",">"}
- xMax,yMax=m.getSize()
- x=xMax/2-0.5
- y=yMax/2-0.5
- score=0
- ex=math.random(1,xMax-2)
- ey=math.random(2,yMax-2)
- os.pullEvent=os.pullEventRaw
- function printChar(x,y,char,ex,ey)
- m.clear()
- m.setCursorPos(1,1) m.write("score: "..tostring(score))
- m.setCursorPos(x,y)
- m.write(char)
- m.setCursorPos(ex,ey)
- m.write("o")
- end
- while true do
- pos=0
- if redstone.testBundledInput("left",colors.blue)==true then pos=1 if y>2 then y=y-1 end end
- if redstone.testBundledInput("right",colors.orange)==true then pos=2 if y<yMax-1 then y=y+1 end end
- if redstone.testBundledInput("left",colors.red)==true then pos=3 if x>0 then x=x-1 end end
- if redstone.testBundledInput("right",colors.lime)==true then pos=4 if x<xMax-1 then x=x+1 end end
- if pos~=0 then
- printChar(x,y,ship[pos],ex,ey)
- end
- if x==ex and y==ey then
- score=score+1
- ex=math.random(1,xMax-2)
- ey=math.random(2,yMax-2)
- rs.setOutput("top",true)
- sleep(0.5)
- rs.setOutput("top",false)
- end
- sleep(0.5)
- end
Add Comment
Please, Sign In to add comment