AdvLock

CTB

Aug 18th, 2015
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.83 KB | None | 0 0
  1. if not fs.exists "Flare" then
  2.     print "Downloading Flare"
  3.     local h = http.get "http://pastebin.com/raw.php?i=SD25GhYf"
  4.     if h then
  5.         local f, err = load( h.readAll(), "installer", nil, _ENV or getfenv() )
  6.         h.close()
  7.         f()
  8.     else
  9.         return error( "Cannot install Flare", 0 )
  10.     end
  11. end
  12. local files = {
  13.     ["init"] = "require \"UIButton\"\nrequire \"UIContainer\"\nrequire \"UIPanel\"\nrequire \"UIWindow\"\nrequire \"UITerminal\"\nrequire \"UIText\"\nrequire \"UITabs\"\n\nlocal gameRunning = false\n\napplication.view:createShortcut( \"Terminate\", \"ctrl-t\", function()\n\9application:stop()\nend )\napplication.view:createShortcut( \"Reboot\", \"ctrl-r\", function()\n\9os.reboot()\nend )\n\nlocal gameFrame = application.view:addChild( UIContainer( 0, application.view.height*-1, application.view.width, application.view.height ) )\ngameFrame.colour = colours.lightGrey\ngameFrame.transitionTime = .3\n\nlocal howto = gameFrame:addChild( UIContainer( 0, 0, math.floor( gameFrame.width / 1.5 ), math.floor( gameFrame.height / 1.5 ) ) )\nhowto.colour = colours.grey\nlocal howtotext = howto:addChild( UIText( 1, 1, howto.width-2, howto.height-2, \"\\n@t0@acCatch the Button - Quickguide\\n\\n@al@t8 Click as many buttons you can in 25 seconds.\\n@al Controls: @t0a mouse @t8(Not a real mouse)\" ) )\nlocal continue = howto:addChild( UIButton( 0, 0, math.floor( howto.width / 2 ), 3, \"Start\" ) )\n\ncontinue.colour = colours.cyan\ncontinue.textColour = colours.grey\ncontinue.x = math.floor( howto.width / 2 - continue.width / 2 )\ncontinue.y = howto.height - 5\n\ncontinue.onClick = function( ... )\n\9gameRunning = true\n\9howto:transitionOutBottom()\nend\n\nhowtotext.colour = colours.black\nhowto.x = math.floor( gameFrame.width / 2 - howto.width / 2 )\nhowto.y = math.floor( gameFrame.height /2  - howto.height / 2 )\n\nlocal launchFrame = application.view:addChild( UIContainer( 0, 0, application.view.width, application.view.height ) )\nlaunchFrame.colour = colours.lightGrey\n\n\n-- background animation --\nlocal _animtime = 1\n\n-- background shapes --\nlocal shape01 = launchFrame:addChild( UIButton( 0, 0, 10, 3, \"#catchme\" ) )\nlocal shape02 = launchFrame:addChild( UIButton( 0, 0, 10, 3, \"#awesome\" ) )\nlocal shape03 = launchFrame:addChild( UIButton( 0, 0, 10, 3, \"#game\" ) )\nlocal shape04 = launchFrame:addChild( UIButton( 0, 0, 10, 3, \"#havefun\" ) )\nshape01.colour = colours.grey\nshape01.textColour = colours.lightGrey\nshape02.colour = colours.grey\nshape02.textColour = colours.lightGrey\nshape03.colour = colours.grey\nshape03.textColour = colours.lightGrey\nshape04.colour = colours.grey\nshape04.textColour = colours.lightGrey\n\nlocal function backgroundHandler()\n\9local randomX, randomY = math.random( 1, (launchFrame.width-10) ), math.random( 1, (launchFrame.height-8) )\n\9shape01.animatedY = randomY\n\9shape01.animatedX = randomX\n\9local randomX, randomY = math.random( 1, (launchFrame.width-10) ), math.random( 1, (launchFrame.height-8) )\n\9shape02.animatedY = randomY\n\9shape02.animatedX = randomX\n\9local randomX, randomY = math.random( 1, (launchFrame.width-10) ), math.random( 1, (launchFrame.height-8) )\n\9shape03.animatedY = randomY\n\9shape03.animatedX = randomX\n\9local randomX, randomY = math.random( 1, (launchFrame.width-10) ), math.random( 1, (launchFrame.height-8) )\n\9shape04.animatedY = randomY\n\9shape04.animatedX = randomX\n\n\n\9Timer.queue( _animtime, function( ... )\n\9\9backgroundHandler()\n\9end )\nend\n\nbackgroundHandler()\n\n-- start screen\n--- / scoring\nlocal difficulty = launchFrame:addChild( UITabs( 0, 0, 30, { \"Easy+\", \"Easy\", \"Medium\", \"Hard\" } ) )\ndifficulty:select(1)\ndifficulty.transitionTime = .15\n\nlocal launch = launchFrame:addChild( UIButton( 0, -application.view.height, 25, 3, \"Start CatchTheButton\") )\nlaunch.colour = colours.white\n\nlocal exit = launchFrame:addChild( UIButton( 0, -application.view.height, 25, 3, \"Exit\" ) )\nexit.colour = colours.red\n\ndifficulty.animatedX = math.floor(launchFrame.width / 2 - difficulty.width / 2)\ndifficulty.animatedY = math.floor(launchFrame.height / 2 + 1)\nlaunch.animatedX = math.floor (launchFrame.width / 2 - launch.width / 2) \nlaunch.animatedY = math.floor (launchFrame.height / 2 - launch.height)\nexit.animatedX = math.floor (launchFrame.width / 2 - launch.width / 2) \nexit.animatedY = math.floor (launchFrame.height / 2 + launch.height)\n\n-- GAME settings --\nlocal gameTime = 25\nlocal gameScore = 0\n\nlocal maxButtons = 5\n\nlocal buttonsize = { 10, 6 }\nlocal elapsedTime = 0\nlocal framerate = .45\n\nlaunch.onClick = function( ... )\n\9if difficulty.selected == 4 then\n\9\9buttonsize = { 5, 3 }\n\9\9framerate = .45\n\9\9maxButtons = 5\n\9elseif difficulty.selected == 3 then\n\9\9buttonsize = { 7, 4 }\n\9\9framerate = .5\n\9\9maxButtons = 6\n\9elseif difficulty.selected == 2 then\n\9\9buttonsize = { 9, 5 }\n\9\9framerate = .55\n\9\9maxButtons = 7\n\9elseif difficulty.selected == 1 then\n\9\9buttonsize = { 11, 6 }\n\9\9framerate = .7\n\9\9maxButtons = 8\n\9end\n\9launchFrame:transitionOutBottom()\n\9gameFrame:transitionInTop()\nend\nexit.onClick = function( ... )\n\9launchFrame.transitionTime = .5\n\9launchFrame.animatedX = application.view.width * 2\n\9launchFrame.animatedY = application.view.height * 2\n\9Timer.queue( .5, function()\n\9\9term.clear()\n\9\9term.setCursorPos( 1, 1 )\n\9\9application:stop()\n\9end )\nend\n\nlocal Buttons = {}\n\nlocal TimeScore = gameFrame:addChild( UIPanel( 0, 0, 24, 3 ) )\nTimeScore.colour = colours.grey\nlocal Time  = TimeScore:addChild( UIText( 0, 1, 8, 3, \"@t8time @tb\" .. tostring( gameTime ) ) )\nlocal Score = TimeScore:addChild( UIText( 0, 1, 15, 3, \"@t8score @tc\" .. tostring( gameScore ) ) )\nTimeScore.x = math.floor( gameFrame.width / 2 - TimeScore.width / 2 )\n\nTime.colour = colours.grey\nScore.colour = colours.grey\nTime.x = math.floor( TimeScore.width / 2 - ( Time.width + 1 ) )\nScore.x = math.floor( TimeScore.width / 2 + 1 )\n\nlocal function gameTimer()\n\9Timer.queue( 1, function()\n\9\9if gameRunning then\n\9\9\9gameTime = gameTime - 1\n\9\9\9if gameTime <= 0 then\n\9\9\9\9gameRunning = false\n\9\9\9\9local b = {}\n\9\9\9\9for k, v in pairs( Buttons ) do\n\9\9\9\9\9b[#b + 1] = v\n\9\9\9\9end\n\9\9\9\9for i = 1, #b do\n\9\9\9\9\9b[i]:onClick()\n\9\9\9\9end\n\9\9\9\9Time.text = \"@t8time @tb\" .. tostring( gameTime )\n\9\9\9\9TimeScore.animatedHeight = math.floor( gameFrame.height / 2 - 2 )\n\9\9\9\9Timer.queue( .5, function()\n\9\9\9\9\9TimeScore.animatedWidth = math.floor( gameFrame.width /2  - 2 )\n\9\9\9\9\9Timer.queue( .5, function()\n\9\9\9\9\9\9TimeScore.animatedX = math.floor( gameFrame.width / 2 - TimeScore.width / 2 )\n\9\9\9\9\9\9TimeScore.animatedY = math.floor( gameFrame.height / 2 - TimeScore.height / 2 )\n\9\9\9\9\9end )\n\9\9\9\9\9\n\9\9\9\9\9Timer.queue( 1, function()\n\9\9\9\9\9\9Time.animatedX = math.floor( TimeScore.width / 2 - ( Time.width + 1 ) )\n\9\9\9\9\9\9Score.animatedX = math.floor( TimeScore.width / 2 + 1 )\n\9\9\9\9\9\9local Exit = TimeScore:addChild( UIButton( 0, 0, 9, 3, \"Exit\" ) )\n\9\9\9\9\9\9Exit.width = math.ceil( TimeScore.width / 3 )\n\9\9\9\9\9\9Exit.x = math.floor( TimeScore.width / 2 - Exit.width / 2 )\n\9\9\9\9\9\9Exit.y = TimeScore.height - 4\n\n\9\9\9\9\9\9Exit.colour = colours.cyan\n\9\9\9\9\9\9Exit.onClick = function()\n\9\9\9\9\9\9\9gameFrame:transitionOutTop()\n\9\9\9\9\9\9\9Timer.queue( 1, function()\n\9\9\9\9\9\9\9\9term.clear()\n\9\9\9\9\9\9\9\9term.setCursorPos( 1, 1 )\n\9\9\9\9\9\9\9\9application:stop()\n\9\9\9\9\9\9\9end )\n\9\9\9\9\9\9end\n\9\9\9\9\9end )\n\9\9\9\9end )\n\n\9\9\9else\n\9\9\9\9gameTimer()\n\9\9\9end\n\9\9else\n\9\9\9gameTimer()\n\9\9end\n\9end )\nend\ngameTimer()\n\nlocal function count( t )\n\9local i = 0\n\9while t[i + 1] do\n\9\9i = i + 1\n\9end\n\9return i\nend\n\ngameFrame.transitionTime = .5\nfunction Update()\n\9if gameRunning then\n\9\9Time.text = \"@t8time @tb\" .. tostring( gameTime )\n\9\9Score.text = \"@t8score @tc\" .. tostring( gameScore )\n\9\9for k, v in pairs( Buttons ) do\n\9\9\9local toX, toY = math.random( 1, gameFrame.width-buttonsize[1] ), math.random( 4, gameFrame.height - buttonsize[2])\n\9\9\9Buttons[k].animatedX = toX\n\9\9\9Buttons[k].animatedY = toY\n\9\9end\n\9\9while count( Buttons ) < maxButtons do\n\9\9\9local startX, startY = math.random( 1, gameFrame.width-buttonsize[1] ), math.random( 4, gameFrame.height - buttonsize[2])\n\9\9\9local _index = count( Buttons ) + 1\n\9\9\9Buttons[_index] = gameFrame:addChild( UIButton( startX, startY, buttonsize[1], buttonsize[2], \"ME!\" ))\n\9\9\9Buttons[_index].onClick = function( self, ... ) \n\9\9\9\9if gameRunning then\n\9\9\9\9\9gameScore = gameScore + 1\n\9\9\9\9end\n\9\9\9\9Buttons[_index] = nil\n\9\9\9\9self:remove()\n\9\9\9end\n\9\9end\n\9end\nend\n\nfunction gameFrame:onUpdate( dt )\n    elapsedTime = elapsedTime + dt\n    while elapsedTime >= framerate do\n        Update()\n        elapsedTime = elapsedTime - framerate\n    end\nend";
  14. }
  15. loadfile "Flare/run.lua" ( files, "init" )
Advertisement
Add Comment
Please, Sign In to add comment