Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int deltaTime = 0
- int lastTime = realtime()
- int cookies = 0
- int cookiesPS = 0
- vector2 Cursor = vec2()
- bool Click = false
- bool ClickDown = false
- bool ClickUp = false
- int mouseC = 0
- int cursors = 0
- int minges = 0
- int gabens = 0
- int hl3s = 0
- function bool GetMouseOn(vector2 pos, vector2 size) {
- return (Cursor > pos && (Cursor < (pos+size)))
- }
- client {
- setFPS(60)
- function void DrawCookie() {
- setDrawColor(190, 140, 50)
- drawCircle(vec2(),60)
- setDrawColor(190*0.6, 140*0.6, 50*0.6)
- drawCircle(vec2(-30,-20),10)
- drawCircle(vec2(5,-40),10)
- drawCircle(vec2(25,20),10)
- drawCircle(vec2(0,-5),10)
- drawCircle(vec2(35,-15),10)
- drawCircle(vec2(-35,15),10)
- drawCircle(vec2(-5,35),10)
- }
- array plusses = tableArray()
- int cookieSize = 1
- downloadURLMaterial("gaben", "http://orig11.deviantart.net/4b39/f/2014/326/8/7/gaben_by_rbrofficeman-d87c4v8.png")
- downloadURLMaterial("hl3", "http://images1.wikia.nocookie.net/__cb57888/half-life/en/images/f/fe/HL3_logo.svg")
- event drawScreen(int w, int h) {
- //Background
- setDrawColor(0,40,100)
- drawBox(vec2(),vec2(w,h))
- //Cookie
- setFont("Trebuchet 24", 32, color(255,255,255))
- drawTextCentered(vec2(256,80), "Cookies: " + int(cookies))
- drawTextCentered(vec2(256,110), "Cookies per second: " + cookiesPS)
- if(Cursor.distance(vec2(256,256)) < 60) {
- if(Click) {
- cookieSize = (cookieSize*5+0.8)/6
- }
- else {
- cookieSize = (cookieSize*5+1.2)/6
- }
- }
- else {
- cookieSize = (cookieSize*5+1)/6
- }
- pushMatrix(matrix(vec2(256,256), 0, vec2(cookieSize,cookieSize)))
- DrawCookie()
- popMatrix()
- //Cursors
- for(int i=1; clamp(cursors,0,10); 1) {
- matrix m = matrix()
- m.scale(vec2(cookieSize,cookieSize))
- m.setTranslation(vec2(256,256))
- m.rotate(realtime()*40%360+i*36)
- m.translate(vec(0,80,0))
- pushMatrix(m)
- setDrawColor(255,255,255)
- setDrawTexture("vgui/cursors/hand")
- drawTexturedBox(vec2(-16, -16), vec2(32, 32))
- popMatrix()
- }
- //Drawing plusses
- foreach(int key; table t : plusses) {
- setFontColor(color(255,255,255,clamp(t[2,int]-100,0,255)))
- drawTextCentered(vec2(t[1,int], t[2,int]), t[3,string])
- }
- //Milk
- setDrawColor(255,255,255,150)
- //drawPoly(vector2Array(vec2(0,h), vec2(0,h-50+sin(realtime()*50)*10), vec2(w,h-50+cos(realtime()*50)*10), vec2(w,h)))
- array poly = vector2Array(vec2(w,h), vec2(0,h))
- int max = 40
- for(int i=0; max; 1) {
- poly[#poly+1] = vec2(512/max*i, h - 50 + sin(realtime()*20+i*12) * 10 * sin(realtime()*40))
- }
- drawPoly(poly)
- //Shop
- setFont("Trebuchet 24", 24, color(0,155,255))
- setDrawColor(255,255,255,255)
- setDrawTexture("vgui/cursors/hand")
- drawTexturedBox(vec2(20,380),vec2(80,80))
- drawTextCentered(vec2(20+40,450), "Cursors: " + cursors)
- drawTextCentered(vec2(20+40,474), "Price: " + (20 + (cursors * 20)))
- setDrawTexture("vgui/steam/games/icon_css")
- drawTexturedBox(vec2(120,380),vec2(80,80))
- drawTextCentered(vec2(120+40,450), "Minges: " + minges)
- drawTextCentered(vec2(120+40,474), "Price: " + (100 + (minges * 100)))
- // setDrawTexture("vgui/resource/icon_vac")
- setURLMaterial("gaben")
- drawTexturedBox(vec2(215,380),vec2(80,80))
- drawTextCentered(vec2(220+40,450), "Gabens: " + gabens)
- drawTextCentered(vec2(220+40,474), "Price: " + (500 + (gabens * 250)))
- setURLMaterial("hl3")
- drawTexturedBox(vec2(315,380),vec2(80,80))
- drawTextCentered(vec2(320+40,450), "HL 3's: " + hl3s)
- drawTextCentered(vec2(320+40,474), "Price: " + (3000 + (hl3s * 1500)))
- }
- event tick() {
- deltaTime = realtime() - lastTime; lastTime = realtime()
- //Mouse stuff
- Cursor = (localPlayer().getScreenCursor()+Cursor)/2
- Click = localPlayer().keyUse()
- if(!localPlayer().keyUse() && mouseC>1) ClickUp = true
- if(localPlayer().keyUse() && mouseC == 1 ) ClickDown = true
- if(!localPlayer().keyUse()) mouseC = 0
- mouseC++
- for(int i=1; #plusses; 1) {
- table t = plusses[i, table]
- t[2] = t[2,int] - deltaTime * 100
- if(t[2,int]<100) { plusses.removetable(i); break; }
- }
- ClickDown = false
- ClickUp = false
- }
- netReceive("addcookies",function(netstream nst) {
- int Count = nst.readNumber()
- cookies += Count
- plusses[#plusses+1] = {256,256,"+" + Count}
- })
- netReceive("cookieupdate",function(netstream nst) {
- cookies = nst.readNumber()
- cookiesPS = nst.readNumber()
- })
- netReceive("shopupdate",function(netstream nst) {
- cookies = nst.readNumber()
- cursors = nst.readNumber()
- minges = nst.readNumber()
- gabens = nst.readNumber()
- hl3s = nst.readNumber()
- })
- }
- server {
- player ply = owner()
- function void SendShopUpdate() {
- netstream nst = stream()
- nst.writeNumber(cookies)
- nst.writeNumber(cursors)
- nst.writeNumber(minges)
- nst.writeNumber(gabens)
- nst.writeNumber(hl3s)
- nst.netBroadcast("shopupdate")
- }
- event tick() {
- deltaTime = realtime() - lastTime; lastTime = realtime()
- //Mouse stuff
- Cursor = (ply.getScreenCursor()+Cursor)/2
- Click = ply.keyUse()
- if(!ply.keyUse() && mouseC>1) ClickUp = true
- if(ply.keyUse() && mouseC == 1 ) ClickDown = true
- if(!ply.keyUse()) mouseC = 0
- mouseC++
- if(ClickDown && ply.getScreenCursor().distance(vec2(256,256)) < 60) {
- cookies += int(1+cookiesPS*0.5)
- netstream nst = stream()
- nst.writeNumber(int(1+cookiesPS*0.5))
- nst.netBroadcast("addcookies")
- }
- //Shop
- if(ClickDown && GetMouseOn(vec2(20,380),vec2(80,80)) && cookies >= (20 + (cursors * 20))) {
- cookiesPS += 0.2
- cookies -= (20 + (cursors * 20))
- cursors++
- soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
- SendShopUpdate()
- }
- else if(ClickDown && GetMouseOn(vec2(120,380),vec2(80,80)) && cookies >= (100 + (minges * 100))) {
- cookiesPS += 2
- cookies -= (100 + (minges * 100))
- minges++
- soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
- SendShopUpdate()
- }
- else if(ClickDown && GetMouseOn(vec2(220,380),vec2(80,80)) && cookies >= (500 + (gabens * 250))) {
- cookiesPS += 8
- cookies -= (500 + (gabens * 250))
- gabens++
- soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
- SendShopUpdate()
- }
- else if(ClickDown && GetMouseOn(vec2(320,380),vec2(80,80)) && cookies >= (3000 + (hl3s * 1500))) {
- cookiesPS += 40
- cookies -= (3000 + (hl3s * 1500))
- hl3s++
- soundPlay(round(random(1,5)), 0.5, "buttons/button17.wav")
- SendShopUpdate()
- }
- ClickDown = false
- ClickUp = false
- }
- timerCreate("update",0.1,0,function() {
- netstream nst = stream()
- nst.writeNumber(cookies)
- nst.writeNumber(cookiesPS)
- nst.netBroadcast("cookieupdate")
- })
- event playerChat(player pl, string s) {
- if(pl == owner() && s.sub(0,1) == ">") {
- ply = playerByName(s.sub(2,#s-1), false)
- print("Changed to " + ply.name())
- return ""
- }
- }
- }
- timerCreate("persec",0.1,0,function() {
- cookies += cookiesPS/10
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement