diff options
author | tomsmeding <hallo@tomsmeding.nl> | 2015-12-15 10:55:04 +0100 |
---|---|---|
committer | tomsmeding <hallo@tomsmeding.nl> | 2015-12-15 10:55:04 +0100 |
commit | 7944bf6fe91e5af2f42aad4554e59328fafe477a (patch) | |
tree | a41831a1891cdf9d0aa0956f85879dc23a7a6ae2 | |
parent | efc74f972ab1200a52841f17cfaa6499d9bf2359 (diff) |
wessel balls
-rw-r--r-- | index.html | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -8,6 +8,8 @@ <script> "use strict"; +var SOUND_ON=location.hostname!="localhost"&&location.hostname!="127.0.0.1"; + var COLOURS=["#00F","#F00","#0CC"]; var socket=io(),me=[-1,""],userlist=[],rooms={},visibleroomuidiv=null; @@ -315,7 +317,7 @@ function dodestroyroom(roomid){ } function drawboard(ctx,cellsz,bd,clr,lastplacepos){ - var x,y,i,angle,radius; + var x,y,i,angle,radius,ballradius; ctx.clearRect(0,0,W*cellsz+1,H*cellsz+1); ctx.strokeStyle=COLOURS[+clr]; ctx.beginPath(); @@ -337,15 +339,21 @@ function drawboard(ctx,cellsz,bd,clr,lastplacepos){ } for(y=0;y<H;y++){ for(x=0;x<W;x++){ + if(bd[y][x].n==0)continue; ctx.fillStyle=COLOURS[bd[y][x].c]; angle=1/bd[y][x].n*2*Math.PI; - radius=bd[y][x].n==1?0:.15; + switch(bd[y][x].n){ + case 1: radius=0; break; + case 2: radius=.15; break; + default: radius=.2; break; + } + ballradius=cellsz*(0.1+bd[y][x].n*.05); for(i=0;i<bd[y][x].n;i++){ ctx.beginPath(); ctx.arc( (x+.5+radius*Math.cos(angle*i))*cellsz, (y+.5+radius*Math.sin(angle*i))*cellsz, - cellsz*.2,0,2*Math.PI,1); + ballradius,0,2*Math.PI,1); ctx.fill(); } } @@ -465,6 +473,7 @@ function queueapplymove(id,ctx,cellsz,idx,c,lastplacepos){ var sounddong__audioelem=null; function sounddong(){ + if(!SOUND_ON)return; if(sounddong__audioelem==null)sounddong__audioelem=document.getElementById("dongaudioelem"); sounddong__audioelem.currentTime=0; sounddong__audioelem.play(); |