Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- print("Click the yellow square")
- print("Made by mrSLIMEguy")
- print("Click the yellow square to score points!")
- print("Press Q to quit")
- print(" ")
- --term.setTextColour(colours.yellow)
- print("Press any key to start")
- event, key = os.pullEvent("key")
- score = 0
- term.clear()
- term.setCursorPos(1,1)
- w,h = term.getSize()
- sx = math.random(1,w)
- sy = math.random(1,h)
- while true do
- term.setCursorPos(1,1)
- print("Score: "..tostring(score))
- if sx and sy == oldsx and oldsy then
- paintutils.drawPixel(sx,sy,colours.red)
- else
- paintutils.drawPixel(sx,sy,colours.yellow)
- end
- event, data1, data2, data3 = os.pullEvent()
- if event == "key" and data1 == 16 then
- term.clear()
- term.setCursorPos(1,1)
- print("Thanks for playing! You got "..tostring(score).." points!")
- break
- elseif event == "mouse_click" and data1 == 1 then
- if data2 == sx and data3 == sy then
- score = score+1
- oldsx = sx
- oldsy = sy
- else
- term.clear()
- term.setCursorPos(1, 1)
- print("Thanks for playing! You got "..tostring(score).." points!")
- break
- end
- if score < 0 then
- term.clear()
- term.setCursorPos(1, 1)
- print("Game Over!")
- print("You got negative points!")
- break
- end
- sx = math.random(1,w)
- sy = math.random(1,h)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement