local char = ">"
local playerX = 1
local playerY = 1
function drawCharacter()
term.clear()
term.setCursorPos(playerX, playerY)
write(char)
drawMap()
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")
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
whenever I run it the character shows up, I tried many different combinations but
here is the situations that happen:
The character shows up but the object doesnt
The object shows up but the character doesnt
The character shows up but its trapped in a three by three box, and the object doesnt show up
I would like to know whats wrong, I would also know how to
change the code to where the camera follows the character