Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1.  
  2. concommand.Add("BouncyBall",function(u)
  3.     local frame = vgui.Create("DFrame")
  4.     local x = 200
  5.     local y = 200
  6.     local Yvelocity = 0
  7.     local Xvelocity = 0
  8.     frame:SetPos(0,0)
  9.     frame:SetSize(400,400)
  10.     frame:MakePopup()
  11.     hook.Add("Tick","gwegh2g22",function()
  12.         if frame:IsValid() then
  13.             function frame:PaintOver()
  14.                 draw.RoundedBox(8,x,y,20,20,Color(255,0,0))
  15.             end
  16.        
  17.             if y>=frame:GetTall() - 20 then
  18.                 y=frame:GetTall() - 20
  19.             else
  20.                 Yvelocity = Yvelocity + 1
  21.                 y=y+Yvelocity
  22.             end
  23.             x=x+Xvelocity
  24.            
  25.             if input.IsKeyDown(KEY_UP) && y>=frame:GetTall() - 20 then
  26.                 y=y-1
  27.                 Yvelocity = -10
  28.             end
  29.            
  30.             if x>=frame:GetWide() - 20 then
  31.                 x=frame:GetWide() - 20
  32.                 Xvelocity=0
  33.             end
  34.            
  35.             if x<=0 then
  36.                 x=0
  37.                 Xvelocity=0
  38.             end
  39.            
  40.             if input.IsKeyDown(KEY_RIGHT) then
  41.                 if x<=frame:GetWide() - 30 then
  42.                     Xvelocity=Xvelocity+1
  43.                 end
  44.             elseif Xvelocity >= 1 then
  45.                 Xvelocity=Xvelocity-1
  46.             end
  47.             if input.IsKeyDown(KEY_LEFT) then
  48.                 if x>=10 then
  49.                     Xvelocity=Xvelocity-1
  50.                 end
  51.             elseif Xvelocity <= -1 then
  52.                 Xvelocity=Xvelocity+1
  53.             end
  54.         end
  55.     end)
  56. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement