Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- sleep(0.1)
- wt = 0
- width, height = term.getSize()
- width = width/2
- height = height/2
- os.pullEvent = os.pullEventRaw
- function blockstart()
- -- Telling it to draw the shape
- term.setCursorPos(spw1, sph1)
- write("#")
- term.setCursorPos(spw2, sph2)
- write("#")
- term.setCursorPos(spw3, sph3)
- write("#")
- term.setCursorPos(spw4, sph4)
- write("#")
- end
- function newblock()
- --Setting Rotation to 1
- rot = 1
- -- Shape
- local bshape = math.ceil(math.random(0,3))
- if bshape == 0 then
- shape = "square"
- end
- if bshape == 1 then
- shape = "line"
- end
- if bshape == 2 then
- shape = "l"
- end
- if bshape == 3 then
- shape="hill"
- end
- startposw = width/2
- startposh = 1
- -- setting what shapes look like
- if shape == "hill" then
- spw1 = startposw
- spw2 = spw1 -1
- spw3 = spw1 +1
- spw4 = spw1
- sph1 = startposh
- sph2 = sph1 -1
- sph3 = sph1 -1
- sph4 = sph1 -1
- blockstart()
- end
- if shape == "l" then
- spw1 = startposw
- spw2 = spw1
- spw3 = spw1
- spw4 = spw3 +1
- sph1 = startposh
- sph2 = sph1 -1
- sph3 = sph2 -1
- sph4 = sph3
- blockstart()
- end
- if shape == "line" then
- spw1 = startposw
- spw2 = spw1
- spw3 = spw1
- spw4 = spw1
- sph1 = startposh
- sph2 = sph1 -1
- sph3 = sph2 -1
- sph4 = sph3 -1
- blockstart()
- end
- if shape == "square" then
- spw1 = startposw
- spw2 = spw1 +1
- spw3 = spw1
- spw4 = spw2
- sph1 = startposh
- sph2 = sph1
- sph3 = sph1 -1
- sph4 = sph1 -1
- blockstart()
- end
- end
- function updateblock()
- if wt ~= 4 then
- wt = wt +1
- end
- if wt == 4 then
- sph1 = sph1 -1
- sph2 = sph2 -1
- sph3 = sph3 -1
- sph4 = sph4 -1
- blockstart()
- end
- end
- function rotl()
- if rot == 1 then
- rot = 4
- if shape == "hill" then
- spw3 = spw1
- spw1 = spw2
- spw4 = spw4
- spw2 = spw4
- sph3 = sph1
- sph1 = sph2
- sph4 = sph4
- sph2 = sph4 -1
- end
- if shape == "square" then
- end
- if shape == "line" then
- spw3 = spw4 -1
- spw2 = spw3 -1
- spw1 = spw2 -1
- spw4 = spw4
- sph1 = sph4
- sph2 = sph4
- sph3 = sph4
- sph4 = sph4
- end
- if shape == "l" then
- sph4 = sph2
- sph2 = sph3
- sph1 = sph3
- sph3 = sph3
- spw2 = spw3 -1
- spw1 = spw2 -1
- spw4 = spw3
- spw3 = spw3
- end
- end
- if rot == 4 then
- rot = 3
- if shape == "hill" then
- spw3 = spw1
- spw1 = spw2
- spw4 = spw4
- spw2 = spw4 +1
- sph3 = sph1
- sph1 = sph2
- sph2 = sph4
- sph4 = sph4
- end
- if shape == "square" then
- end
- if shape == "line" then
- spw1 = spw4
- spw2 = spw4
- spw3 = spw4
- spw4 = spw4
- sph3 = sph4 -1
- sph2 = sph3 -1
- sph1 = sph2 -1
- sph4 = sph4
- end
- if shape == "l" then
- spw4 = spw4
- spw3 = spw4 +1
- spw2 = spw3
- spw1 = spw3
- sph4 = sph4
- sph3 = sph4
- sph2 = sph4 -1
- sph1 = sph2 -1
- end
- end
- if rot == 3 then
- rot = 2
- if shape == "l" then
- sph4 = sph2
- sph2 = sph3
- sph1 = sph3
- sph3 = sph3
- spw2 = spw3 +1
- spw1 = spw2 +1
- spw4 = spw4
- spw3 = spw3
- end
- if shape == "square" then
- end
- if shape == "line" then
- spw3 = spw4 +1
- spw2 = spw3 +1
- spw1 = spw2 +1
- spw4 = spw4
- sph3 = sph4
- sph2 = sph4
- sph1 = sph4
- sph4 = sph4
- end
- if shape == "hill" then
- spw3 = spw1
- spw1 = spw2
- spw2 = spw4
- spw4 = spw4
- sph3 = sph1
- sph1 = sph4
- sph2 = sph4 +1
- sph4 = sph4
- end
- end
- if rot == 2 then
- rot = 1
- if shape == "square" then
- end
- if shape == "line" then
- spw1 = spw4
- spw2 = spw4
- spw3 = spw4
- spw4 = spw4
- spw3 = spw4 +1
- spw2 = spw3 +1
- spw1 = spw2 +1
- end
- if shape == "hill" then
- spw3 = spw1
- spw1 = spw2
- spw2 = spw4 -1
- spw4 = spw4
- sph3 = sph4
- sph2 = sph4
- sph1 = sph4 +1
- end
- if shape == "l" then
- end
- end
- end
- function update()
- updateblock()
- os.startTimer(.1)
- end
- newblock()
- timer1 = os.startTimer(.1)
- while true do
- event , varx = os.pullEvent()
- if event == "timer" then
- if varx == "timer1" then
- update()
- end
- end
- if event == "char" then
- if varx == "a" then
- rotl()
- end
- if varx == "e" then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement