Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --SECTION 1, VARIABLES
- local posX, posY = 5, 5
- local w,h = term.getSize()
- weapon = "bow"
- local char = {
- " ",
- "@",
- " ",
- }
- local arrow = {
- "-"
- }
- --ART FUNCTIONS
- function printCenter(str, nolp)
- term.setCursorPos(w/2 - #str/2, nolp)
- term.write(str)
- end
- function printRight(str, nolpW)
- term.setCursorPos(w - #str, nolpW)
- term.write(str)
- end
- function drawHeader()
- printCenter("Game!", 1)
- printCenter(string.rep("#", w), 2)
- end
- local function picture(image,positionX,positionY)
- for y = 1,#image do
- term.setCursorPos(positionX,positionY + y - 1)
- term.write(image[y])
- end
- end
- --weapon functions
- function weapon()
- if weapon == "bow" then
- print("_")
- end
- end
- --MOVMENT
- while true do
- term.clear()
- drawHeader()
- picture(char,posX,posY)
- local event = {os.pullEvent()}
- --Movement
- if event[1] == "key" then
- if event[2] == 200 then --up
- posY = posY - 1
- elseif event[2] == 208 then --down
- posY = posY + 1
- elseif event[2] == 205 then --left
- posX = posX + 1
- elseif event[2] == 203 then --right
- posX = posX - 1
- elseif event[2] == 57 then
- weapon()
- end
- end
- end
- --Weapons
- weapon = "bow"
- arrow = {
- "-"
- }
- --bow
- while true do
- if weapon == "bow" then
- local event = {os.pullEvent()}
- if event[1] == "key" then
- if event[2] == 57 then
- Xpos = Xpos - 1
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment