Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local char = ">"
- local playerX = 1
- local playerY = 1
- function drawCharacter()
- term.clear()
- term.setCursorPos(playerX, playerY)
- write(char)
- end
- function newSolidObject(obx, oby, obj)
- term.setCursorPos(obx, oby)
- write(obj)
- if playerX == obx and char == ">" then
- playerX = playerX - 1
- elseif playerX == obx and char == "<" then
- playerX = playerX + 1
- elseif playerY == oby and char == "^" then
- playerY = playerY + 1
- elseif playerY == oby and char == "v" then
- playerY = playerY -1
- drawCharacter()
- end
- end
- function drawMap()
- term.clear()
- newSolidObject(4, 4, "x")
- drawCharacter()
- end
- while true do
- drawCharacter()
- drawMap()
- local e,key = os.pullEvent( "key" )
- if key == 17 or key == 200 then
- playerY = playerY -1
- char = "^"
- elseif key == 31 or key == 208 then
- playerY = playerY +1
- char = "v"
- elseif key == 203 or key == 30 then
- playerX = playerX -1
- char = "<"
- elseif key == 205 or key == 32 then
- playerX = playerX +1
- char = ">"
- elseif key == 15 then
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment