Advertisement
szymski

Untitled

Dec 28th, 2015
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.99 KB | None | 0 0
  1. client {
  2. audio aud
  3.  
  4. bool useDown = false
  5. int useC = 0
  6.  
  7. int volume = 50
  8.  
  9. function number lpintersect(vector P1,vector N1,vector P2,vector N2)
  10. {
  11. return (N1.dot(P1-P2))/(N1.dot(N2))
  12. }
  13.  
  14. function bool VecIn(vector2 m, vector2 pos, vector2 size) {
  15. return (m>pos && (m<(pos+size)))
  16. }
  17.  
  18. function void DrawGUI() {
  19. vector guipos = entity().pos() + vec(0,0,60)
  20. angle an = (guipos-localPlayer().shootPos()).angle()
  21.  
  22. vector realPos = guipos-(guipos-localPlayer().shootPos()).normal()*clamp(guipos.distance(localPlayer().shootPos())-45,20,150)
  23.  
  24. vector planePos = localPlayer().shootPos()+localPlayer().eye()*lpintersect(realPos, an.forward(), localPlayer().shootPos(), localPlayer().eye())
  25.  
  26. vector2 mpos = vec2(-((planePos-realPos).getY()*cos(an.getYaw())-(planePos-realPos).getX()*sin(an.getYaw())) * 20, -(planePos-realPos).getZ() * 20)
  27.  
  28. start3D2D(guipos-(guipos-localPlayer().shootPos()).normal()*clamp(guipos.distance(localPlayer().shootPos())-45,20,150),
  29. an+ang(-an.getPitch(),-90,90-an.getPitch()), 0.05)
  30.  
  31. setDrawColor(255,255,255)
  32. drawBox(vec2(-200,-120), vec2(400,240))
  33.  
  34. setFont("Trebuchet24", 32)
  35. setFontColor(color(100,100,100))
  36. drawText(vec2(-195,-115), "Playing: Something")
  37.  
  38. if(mpos.distance(vec2(0,0)) > 70)
  39. setDrawColor(200,200,200)
  40. else {
  41. setDrawColor(150,150,150)
  42. if(useDown) {
  43. if(aud.isPaused())
  44. aud.play()
  45. else
  46. aud.pause()
  47. }
  48. }
  49. drawCircle(vec2(0,0), 70)
  50.  
  51. setDrawColor(100,100,100)
  52.  
  53. if(!aud.isPaused()) {
  54. drawBox(vec2(-30,-40), vec2(20,80))
  55. drawBox(vec2(10,-40), vec2(20,80))
  56. }
  57. else {
  58. drawPoly(vector2Array(vec2(-20,-40),vec2(-20,40),vec2(40,0)))
  59. }
  60.  
  61. setDrawColor(100,100,100)
  62. drawBox(vec2(120,-80), vec2(40,160))
  63.  
  64. setDrawColor(0,150,235)
  65. drawBox(vec2(120,-80+160*(1-volume/100)), vec2(40,round(volume/100*160)+1))
  66.  
  67. if(VecIn(mpos, vec2(120,-90+160*(1-volume/100)), vec2(40,20))) {
  68. if(localPlayer().keyUse()) {
  69. volume = clamp(100*((80-mpos.getY())/160),0,100)
  70. }
  71. setDrawColor(150,150,150)
  72. }
  73. else
  74. setDrawColor(200,200,200)
  75. drawBox(vec2(120,-90+160*(1-volume/100)), vec2(40,20))
  76.  
  77. setDrawColor(100,100,100)
  78. drawBox(vec2(-200,100), vec2(400,10))
  79.  
  80. setDrawColor(0,150,235)
  81. drawBox(vec2(-200,100), vec2(aud.isBlockStreamed() ? 400 : realtime()*50%400,10))
  82. //int p = tan(realtime()*50)*50
  83. //drawBox(vec2(-30 + p,100), vec2(clamp(200-p+30,0,60),10))
  84.  
  85. end3D2D()
  86.  
  87. // print(mpos)
  88.  
  89. }
  90.  
  91. //http://stream.house-radio.com/listen.pls
  92. //http://ponyvillelive.com/station/playlist/id/3/format/pls
  93. //http://ponyvillelive.com/station/playlist/id/39/format/pls
  94. //http://94.23.89.48:7300/listen.pls
  95. //http://szymekk.info/music/griefers.mp3
  96. //http://uploads.damianu.info/Music/Bats.mp3
  97.  
  98. array dubs = numberArray()
  99. int maxdub = 0
  100. int nextdub = 0
  101. bool cooldown = false
  102. int maxDistance = 2000
  103. bool fading = true
  104. array fft = numberArray()
  105. array fftSmooth = numberArray()
  106. function void Play() {
  107. playURL("http://stream.house-radio.com/listen.pls","",function(audio a) {
  108. aud = a
  109. a.play()
  110. a.setVolume(volume)
  111. fft = a.fft(41)
  112. fftSmooth = fft
  113. event tick() {
  114. fft = aud.fft(41)
  115. if(fading) {
  116. aud.setVolume(clamp((1-entity().pos().distance(localPlayer().pos())/maxDistance)*volume,0,100))
  117. }
  118. }
  119. event draw3D() {
  120. if(localPlayer().keyUse() && !useDown && useC == 0) {useDown = true; useC = 1 }
  121. int sz = 100 + sin(realtime()*50) * 40
  122. setRenderMat("color")
  123. renderEnableDepth(false)
  124. start3D2D(entity().pos(), ang())
  125. setDrawColor(0,0,0)
  126. drawCircle(vec2(),500)
  127.  
  128. foreach(int key; int val : dubs) {
  129. dubs[key] = val + frameTime() * 500
  130. if(dubs[key,int] > 500) {
  131. dubs.removenumber(key)
  132. break
  133. }
  134. color c = hsv2rgb((realtime()*100)%360,1,1)
  135. c.setAlpha(clamp((500-val)/500*255,0,255))
  136. setDrawColor(c)
  137. drawCircle(vec2(),val)
  138. setDrawColor(0,0,0)
  139. drawCircle(vec2(),val-15)
  140. }
  141. end3D2D()
  142. renderEnableDepth(true)
  143. if(#fft > 0) {
  144. for(int i=1; clamp(#fftSmooth,0,40); 1) {
  145. fftSmooth[i] = (fft[i,number]+fftSmooth[i,number]*3)/4 //Smoothing, because why not ;p
  146. draw3DBox(entity().pos()+vec(sin(i*9)*sz,cos(i*9)*sz,0),ang(0,-i*9,0),-vec(5,5,5),vec(5,5,fftSmooth[i,int]*200),hsv2rgb((realtime()*100+i*9)%360,1,1))
  147. }
  148. setRenderMat("sprites/light_ignorez")
  149. drawSprite(entity().pos()+vec(0,0,50),fftSmooth[1,int]*1000,fftSmooth[1,int]*1000,color(random(0,255),random(0,255),random(0,255)))
  150.  
  151. setRenderMat("trails/laser")
  152. //for(int i=2; clamp(#fftSmooth,0,40); 1) {
  153. // draw3DBeam(entity().pos()+vec(sin(i*9-9)*(sz+20),cos(i*9-9)*(sz+20),fftSmooth[i-1,int]*1000),entity().pos()+vec(sin(i*9)*(sz+20),cos(i*9)*(sz+20),fftSmooth[i,int]*1000),15,15,5,color(255,255,255))
  154. //}
  155. for(int i=2; clamp(#fftSmooth,0,41); 1) {
  156. draw3DBeam(entity().pos()+vec(sin(i*9-9)*(sz+20),cos(i*9-9)*(sz+20),20),entity().pos()+vec(sin(i*9)*(sz+20),cos(i*9)*(sz+20),20),15,15,5,color(255,255,255,clamp(fftSmooth[i,int]*200,0,255)))
  157. }
  158.  
  159. if(fft[2,int]*1000 > maxdub-20 && realtime() > nextdub && !cooldown && fft[2,int]*1000 > 100) {
  160. nextdub = realtime() + 0.2
  161. dubs.insert(0)
  162. cooldown = true
  163. }
  164.  
  165. if(fft[2,int]*1000 > maxdub-80) {
  166. maxdub = (maxdub*8+fft[2,int]*1000)/9
  167. }
  168.  
  169. if(fft[2,int]*1000 < maxdub-20 || fft[2,int]*1000 > maxdub+20) cooldown = false
  170.  
  171. }
  172. renderEnableDepth(false)
  173. DrawGUI()
  174. useDown = false
  175. if(!localPlayer().keyUse()) useC = 0
  176. }
  177. },function() {})
  178. }
  179. if(canPlayFromURL()) {
  180. Play()
  181. }
  182. event enablePlayURL() {
  183. Play()
  184. netstream nst = stream()
  185. nst.writeString(localPlayer().name())
  186. nst.sendToServer("enabled")
  187. }
  188.  
  189. event drawScreen(int w, int h) {
  190. setFontColor(color(0,100,255))
  191. setFont("Trebuchet24",48)
  192. drawText(vec2(h/2-getTextWidth("Enable URL sounds :>")/2,230), "Enable URL sounds :>")
  193. }
  194.  
  195. event draw3D() {}
  196.  
  197. event requestFeatures() {
  198. request3DRendering()
  199. requestPlayURL()
  200. return true
  201. }
  202.  
  203. event acceptedFeatures() {
  204. Play()
  205. }
  206. }
  207. server {
  208. netReceive("enabled", function(netstream st) {
  209. print(st.readString() + "has enabled Radio")
  210. })
  211.  
  212.  
  213. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement