Advertisement
szymski

Untitled

Aug 28th, 2015
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.26 KB | None | 0 0
  1. int deltaTime = 0
  2. int lastTime = realtime()
  3.  
  4. int cookies = 0
  5. int cookiesPS = 0
  6.  
  7. vector2 Cursor = vec2()
  8. bool Click = false
  9. bool ClickDown = false
  10. bool ClickUp = false
  11.  
  12. int mouseC = 0
  13.  
  14. int cursors = 0
  15. int minges = 0
  16. int gabens = 0
  17. int hl3s = 0
  18.  
  19. function bool GetMouseOn(vector2 pos, vector2 size) {
  20.     return (Cursor > pos && (Cursor < (pos+size)))
  21. }
  22.  
  23. client {
  24.     setFPS(60)
  25.    
  26.     function void DrawCookie() {
  27.         setDrawColor(190, 140, 50)
  28.         drawCircle(vec2(),60)
  29.         setDrawColor(190*0.6, 140*0.6, 50*0.6)
  30.         drawCircle(vec2(-30,-20),10)
  31.         drawCircle(vec2(5,-40),10)
  32.         drawCircle(vec2(25,20),10)
  33.         drawCircle(vec2(0,-5),10)
  34.         drawCircle(vec2(35,-15),10)
  35.         drawCircle(vec2(-35,15),10)
  36.         drawCircle(vec2(-5,35),10)
  37.     }
  38.    
  39.     array plusses = tableArray()
  40.    
  41.     int cookieSize = 1
  42.    
  43.     downloadURLMaterial("gaben", "http://orig11.deviantart.net/4b39/f/2014/326/8/7/gaben_by_rbrofficeman-d87c4v8.png")
  44.     downloadURLMaterial("hl3", "http://images1.wikia.nocookie.net/__cb57888/half-life/en/images/f/fe/HL3_logo.svg")
  45.    
  46.     event drawScreen(int w, int h) {
  47.         //Background
  48.         setDrawColor(0,40,100)
  49.         drawBox(vec2(),vec2(w,h))
  50.        
  51.         //Cookie    
  52.         setFont("Trebuchet 24", 32, color(255,255,255))
  53.         drawTextCentered(vec2(256,80), "Cookies: " + int(cookies))
  54.         drawTextCentered(vec2(256,110), "Cookies per second: " + cookiesPS)
  55.        
  56.         if(Cursor.distance(vec2(256,256)) < 60) {
  57.             if(Click) {
  58.             cookieSize = (cookieSize*5+0.8)/6
  59.             }
  60.             else {
  61.                 cookieSize = (cookieSize*5+1.2)/6
  62.             }
  63.         }
  64.         else {
  65.             cookieSize = (cookieSize*5+1)/6
  66.         }
  67.         pushMatrix(matrix(vec2(256,256), 0, vec2(cookieSize,cookieSize)))
  68.             DrawCookie()
  69.         popMatrix()
  70.        
  71.         //Cursors
  72.         for(int i=1; clamp(cursors,0,10); 1) {
  73.             matrix m = matrix()
  74.             m.scale(vec2(cookieSize,cookieSize))
  75.             m.setTranslation(vec2(256,256))
  76.             m.rotate(realtime()*40%360+i*36)
  77.             m.translate(vec(0,80,0))
  78.             pushMatrix(m)
  79.                 setDrawColor(255,255,255)
  80.                 setDrawTexture("vgui/cursors/hand")
  81.                 drawTexturedBox(vec2(-16, -16), vec2(32, 32))
  82.             popMatrix()
  83.         }
  84.        
  85.         //Drawing plusses
  86.         foreach(int key; table t : plusses) {
  87.             setFontColor(color(255,255,255,clamp(t[2,int]-100,0,255)))
  88.             drawTextCentered(vec2(t[1,int], t[2,int]), t[3,string])
  89.         }
  90.        
  91.         //Milk
  92.         setDrawColor(255,255,255,150)
  93.         //drawPoly(vector2Array(vec2(0,h), vec2(0,h-50+sin(realtime()*50)*10), vec2(w,h-50+cos(realtime()*50)*10), vec2(w,h)))
  94.        
  95.         array poly = vector2Array(vec2(w,h), vec2(0,h))
  96.         int max = 40
  97.         for(int i=0; max; 1) {
  98.             poly[#poly+1] = vec2(512/max*i, h - 50 + sin(realtime()*20+i*12) * 10 * sin(realtime()*40))
  99.         }
  100.         drawPoly(poly)
  101.        
  102.         //Shop
  103.         setFont("Trebuchet 24", 24, color(0,155,255))
  104.         setDrawColor(255,255,255,255)
  105.        
  106.         setDrawTexture("vgui/cursors/hand")
  107.         drawTexturedBox(vec2(20,380),vec2(80,80))
  108.         drawTextCentered(vec2(20+40,450), "Cursors: " + cursors)
  109.         drawTextCentered(vec2(20+40,474), "Price: " + (20 + (cursors * 20)))
  110.        
  111.         setDrawTexture("vgui/steam/games/icon_css")
  112.         drawTexturedBox(vec2(120,380),vec2(80,80))
  113.         drawTextCentered(vec2(120+40,450), "Minges: " + minges)
  114.         drawTextCentered(vec2(120+40,474), "Price: " + (100 + (minges * 100)))
  115.        
  116.        // setDrawTexture("vgui/resource/icon_vac")
  117.         setURLMaterial("gaben")
  118.         drawTexturedBox(vec2(215,380),vec2(80,80))
  119.         drawTextCentered(vec2(220+40,450), "Gabens: " + gabens)
  120.         drawTextCentered(vec2(220+40,474), "Price: " + (500 + (gabens * 250)))
  121.        
  122.         setURLMaterial("hl3")
  123.         drawTexturedBox(vec2(315,380),vec2(80,80))
  124.         drawTextCentered(vec2(320+40,450), "HL 3's: " + hl3s)
  125.         drawTextCentered(vec2(320+40,474), "Price: " + (3000 + (hl3s * 1500)))
  126.        
  127.     }
  128.    
  129.     event tick() {
  130.         deltaTime = realtime() - lastTime; lastTime = realtime()
  131.        
  132.         //Mouse stuff
  133.         Cursor = (localPlayer().getScreenCursor()+Cursor)/2
  134.         Click = localPlayer().keyUse()
  135.         if(!localPlayer().keyUse() && mouseC>1) ClickUp = true
  136.         if(localPlayer().keyUse() && mouseC == 1 ) ClickDown = true
  137.         if(!localPlayer().keyUse()) mouseC = 0
  138.         mouseC++
  139.        
  140.         for(int i=1; #plusses; 1) {
  141.             table t = plusses[i, table]
  142.             t[2] = t[2,int] - deltaTime * 100
  143.             if(t[2,int]<100) { plusses.removetable(i); break; }
  144.         }
  145.        
  146.         ClickDown = false
  147.         ClickUp = false
  148.     }
  149.    
  150.     netReceive("addcookies",function(netstream nst) {
  151.         int Count = nst.readNumber()
  152.         cookies += Count
  153.         plusses[#plusses+1] = {256,256,"+" + Count}
  154.     })
  155.    
  156.     netReceive("cookieupdate",function(netstream nst) {
  157.         cookies = nst.readNumber()
  158.         cookiesPS = nst.readNumber()
  159.     })
  160.    
  161.     netReceive("shopupdate",function(netstream nst) {
  162.         cookies = nst.readNumber()
  163.         cursors = nst.readNumber()
  164.         minges = nst.readNumber()
  165.         gabens = nst.readNumber()
  166.         hl3s = nst.readNumber()
  167.     })
  168.  
  169. }
  170. server {
  171.     player ply = owner()
  172.    
  173.     function void SendShopUpdate() {
  174.         netstream nst = stream()
  175.         nst.writeNumber(cookies)
  176.         nst.writeNumber(cursors)
  177.         nst.writeNumber(minges)
  178.         nst.writeNumber(gabens)
  179.         nst.writeNumber(hl3s)
  180.         nst.netBroadcast("shopupdate")
  181.     }
  182.    
  183.     event tick() {
  184.         deltaTime = realtime() - lastTime; lastTime = realtime()
  185.        
  186.         //Mouse stuff
  187.         Cursor = (ply.getScreenCursor()+Cursor)/2
  188.         Click = ply.keyUse()
  189.         if(!ply.keyUse() && mouseC>1) ClickUp = true
  190.         if(ply.keyUse() && mouseC == 1 ) ClickDown = true
  191.         if(!ply.keyUse()) mouseC = 0
  192.         mouseC++
  193.  
  194.         if(ClickDown && ply.getScreenCursor().distance(vec2(256,256)) < 60) {  
  195.             cookies += int(1+cookiesPS*0.5)
  196.             netstream nst = stream()
  197.             nst.writeNumber(int(1+cookiesPS*0.5))
  198.             nst.netBroadcast("addcookies")
  199.         }
  200.        
  201.         //Shop
  202.         if(ClickDown && GetMouseOn(vec2(20,380),vec2(80,80)) && cookies >= (20 + (cursors * 20))) {
  203.             cookiesPS += 0.2
  204.             cookies -= (20 + (cursors * 20))
  205.             cursors++
  206.             soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
  207.             SendShopUpdate()
  208.         }
  209.         else if(ClickDown && GetMouseOn(vec2(120,380),vec2(80,80)) && cookies >= (100 + (minges * 100))) {
  210.             cookiesPS += 2
  211.             cookies -= (100 + (minges * 100))
  212.             minges++
  213.             soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
  214.             SendShopUpdate()
  215.         }
  216.         else if(ClickDown && GetMouseOn(vec2(220,380),vec2(80,80)) && cookies >= (500 + (gabens * 250))) {
  217.             cookiesPS += 8
  218.             cookies -= (500 + (gabens * 250))
  219.             gabens++
  220.             soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
  221.             SendShopUpdate()
  222.         }
  223.         else if(ClickDown && GetMouseOn(vec2(320,380),vec2(80,80)) && cookies >= (3000 + (hl3s * 1500))) {
  224.             cookiesPS += 40
  225.             cookies -= (3000 + (hl3s * 1500))
  226.             hl3s++
  227.             soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
  228.             SendShopUpdate()
  229.         }
  230.        
  231.         ClickDown = false
  232.         ClickUp = false
  233.     }
  234.    
  235.     timerCreate("update",0.1,0,function() {
  236.         netstream nst = stream()
  237.         nst.writeNumber(cookies)
  238.         nst.writeNumber(cookiesPS)
  239.         nst.netBroadcast("cookieupdate")
  240.     })
  241.    
  242.     event playerChat(player pl, string s) {
  243.         if(pl == owner() && s.sub(0,1) == ">") {
  244.             ply = playerByName(s.sub(2,#s-1), false)
  245.             print("Changed to " + ply.name())
  246.             return ""
  247.         }
  248.     }
  249. }
  250.  
  251. timerCreate("persec",0.1,0,function() {
  252.     cookies += cookiesPS/10
  253. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement