Advertisement
Guest User

Ball Game!

a guest
Aug 23rd, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.01 KB | None | 0 0
  1. if CLIENT then
  2.     concommand.Add("BallGame",function(u,c,a)
  3.         local frame = vgui.Create("DFrame")
  4.         local u = LocalPlayer()
  5.         frame:SetSize(400,400)
  6.         frame:SetPos(0,0)
  7.         frame:SetTitle("Ball Game")
  8.         frame:MakePopup()
  9.         local shop = vgui.Create("DButton",frame)
  10.         shop:SetPos(0,25)
  11.         shop:SetSize(frame:GetWide() / 3,20)
  12.         shop:SetText("Purchase Rainbow! $10")
  13.         function shop:DoClick()
  14.             if !u.rainbow then
  15.                 if u.COINS >= 10 then
  16.                     u.rainbow = true
  17.                     u.COINS = u.COINS - 10
  18.                     shop:SetText("Rainbow Purchased!")
  19.                     timer.Simple(1,function()
  20.                         if frame:IsValid() then
  21.                             shop:SetText("Purchase Rainbow! $10")
  22.                         end
  23.                     end)
  24.                 else
  25.                     shop:SetText("Collect More Coins!")
  26.                     timer.Simple(1,function()
  27.                         if frame:IsValid() then
  28.                             shop:SetText("Purchase Rainbow! $10")
  29.                         end
  30.                     end)
  31.                 end
  32.             else
  33.                 shop:SetText("Already Owned!")
  34.                 timer.Simple(1,function()
  35.                     if frame:IsValid() then
  36.                         shop:SetText("Purchase Rainbow! $10")
  37.                     end
  38.                 end)
  39.             end
  40.         end
  41.         local shop2 = vgui.Create("DButton",frame)
  42.         shop2:SetPos(shop:GetWide(),25)
  43.         shop2:SetSize(frame:GetWide() / 3,20)
  44.         shop2:SetText("Speed Boost! $5")
  45.         function shop2:DoClick()
  46.             if u.rainbow then
  47.                 if u.COINS >= 5 then
  48.                     u.speed = u.speed + 5
  49.                     u.COINS = u.COINS - 5
  50.                     shop2:SetText("Boost Purchased!")
  51.                     timer.Simple(1,function()
  52.                         if frame:IsValid() then
  53.                             shop2:SetText("Speed Boost! $5")
  54.                         end
  55.                     end)
  56.                 else
  57.                     shop2:SetText("Collect More Coins!")
  58.                     timer.Simple(1,function()
  59.                         if frame:IsValid() then
  60.                             shop2:SetText("Speed Boost! $5")
  61.                         end
  62.                     end)
  63.                 end
  64.             else
  65.                 shop2:SetText("You need Rainbow!")
  66.                 timer.Simple(1,function()
  67.                     if frame:IsValid() then
  68.                         shop2:SetText("Speed Boost! $5")
  69.                     end
  70.                 end)
  71.             end
  72.         end
  73.         local shop3 = vgui.Create("DButton",frame)
  74.         shop3:SetPos(shop:GetWide() + shop2:GetWide(),25)
  75.         shop3:SetSize(frame:GetWide() / 3,20)
  76.         shop3:SetText("Jump Boost! $10")
  77.         function shop3:DoClick()
  78.             if u.rainbow then
  79.                 if u.COINS >= 10 then
  80.                     u.jump = u.jump + 2.5
  81.                     u.COINS = u.COINS - 10
  82.                     shop3:SetText("Boost Purchased!")
  83.                     timer.Simple(1,function()
  84.                         if frame:IsValid() then
  85.                             shop3:SetText("Jump Boost! $10")
  86.                         end
  87.                     end)
  88.                 else
  89.                     shop3:SetText("Collect More Coins!")
  90.                     timer.Simple(1,function()
  91.                         if frame:IsValid() then
  92.                             shop3:SetText("Jump Boost! $10")
  93.                         end
  94.                     end)
  95.                 end
  96.             else
  97.                 shop3:SetText("You need Rainbow!")
  98.                 timer.Simple(1,function()
  99.                     if frame:IsValid() then
  100.                         shop3:SetText("Jump Boost! $10")
  101.                     end
  102.                 end)
  103.             end
  104.         end
  105.         frame.t = 0
  106.         frame.b = 400
  107.         frame.l = 0
  108.         frame.r = 400
  109.         u.rainbow = false
  110.         u.color = Color(0,255,0,255)
  111.         u.size = 20
  112.         u.x = 190
  113.         u.y = 30
  114.         u.COINS = 0
  115.         u.gravity = 0
  116.         u.weight = 0.3
  117.         u.speed = 5
  118.         u.jump = 15
  119.         u.coinx = math.random(frame.l,frame.r)
  120.         u.coiny = math.random(frame.t,frame.b)
  121.         u.coincolor = Color(200,200,0,255)
  122.         u.coinsize = 20
  123.         u.coinvalid = true
  124.         hook.Add("Tick","3gb23v",function()
  125.             if frame:IsValid() then
  126.                 frame:SetPos(frame.l,frame.t)
  127.                 frame:SetSize(frame.r,frame.b)
  128.                 function frame:Paint()
  129.                     draw.RoundedBox(0,frame.l,frame.t,frame.r,frame.b,Color(0,0,0,255))
  130.                     draw.RoundedBox(8,u.x,u.y,u.size,u.size,u.color)
  131.                     draw.RoundedBox(8,u.coinx,u.coiny,u.coinsize,u.coinsize,u.coincolor)
  132.                     draw.DrawText(u.COINS,"DermaLarge",frame.r / 2,frame.b / 1.5,Color(255,255,255,255))
  133.                 end
  134.                
  135.                 if u.rainbow then
  136.                     u.color = Color(math.random(1,255),math.random(1,255),math.random(1,255))
  137.                 end
  138.                
  139.                 u.gravity = u.gravity + 1
  140.                
  141.                 if u.y >= frame.b - u.size then
  142.                     u.gravity = 0
  143.                     u.y = frame.b - u.size
  144.                 elseif u.y <= frame.b - u.size then
  145.                     u.y = (u.y + u.gravity)+u.weight
  146.                 end
  147.                
  148.                 if (u.x + u.size >= u.coinx && u.x <= u.coinx + u.coinsize) && (u.y + u.size >= u.coiny && u.y <= u.coiny + u.coinsize) then
  149.                     if u.coinvalid then
  150.                         u.coinvalid = false
  151.                         u.COINS = u.COINS + 1
  152.                         u.coinx = math.random(frame.l,frame.r)
  153.                         u.coiny = math.random(frame.t,ScrH())
  154.                         u.coinvalid = true
  155.                     end
  156.                 end
  157.                
  158.                 /*-------------------------------------
  159.                 -----ADD KEY BINDS BELOW HERE!!!!------
  160.                 */-------------------------------------
  161.                
  162.                 if input.IsKeyDown(KEY_UP) then
  163.                     if u.y == frame.b - u.size then
  164.                         u.y=u.y-1
  165.                         u.gravity = u.gravity - u.jump
  166.                     end
  167.                 end
  168.                
  169.                 if input.IsKeyDown(KEY_RIGHT) then
  170.                     if u.x <= frame.r - u.size then
  171.                         u.x = u.x + u.speed
  172.                     end
  173.                 end
  174.                
  175.                 if input.IsKeyDown(KEY_LEFT) then
  176.                     if u.x >= frame.l then
  177.                         u.x = u.x - u.speed
  178.                     end
  179.                 end
  180.                
  181.                 if input.IsKeyDown(KEY_PAD_8) then
  182.                     if frame.b >= frame.t + u.size then
  183.                         frame.b = frame.b - u.speed
  184.                     end
  185.                 end
  186.                
  187.                 if input.IsKeyDown(KEY_PAD_2) then
  188.                     if frame.b <= ScrH() then
  189.                         frame.b = frame.b + u.speed
  190.                     end
  191.                 end
  192.             end
  193.         end)
  194.     end)
  195. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement