Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- k = 0
- local pixels = {}
- pixels[1] = {}
- pixels[1].x = 1
- pixels[1].y = 6
- pixels[1].color = colors.green
- _cX = 1
- _cY = 1
- function Render()
- term.setBackgroundColor(colors.black)
- term.clear()
- for i=1, #pixels do
- paintutils.drawPixel(pixels[i].x, pixels[i].y, pixels[i].color)
- end
- paintutils.drawPixel(_cX, _cY, colors.red)
- end
- function Gameloop()
- ev, key = os.pullEvent("key")
- if key == keys.up then
- _cY = _cY - 1
- elseif key == keys.left then
- _cX = _cX - 1
- elseif key == keys.right then
- _cX = _cX + 1
- end
- Render()
- sleep(0.1)
- Gameloop()
- end
- function Otherloop()
- for i = 1, #pixels do
- if pixels[i].y == _cY+1 and pixels[i].x == _cX then
- k = 1
- else
- k = 0
- end
- end
- if k == 0 then
- _cY = _cY + 1
- end
- Render()
- sleep(0.1)
- Otherloop()
- end
- Render()
- parallel.waitForAll(Gameloop(), Otherloop())
Advertisement
Add Comment
Please, Sign In to add comment