summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-12-15 10:55:04 +0100
committertomsmeding <hallo@tomsmeding.nl>2015-12-15 10:55:04 +0100
commit7944bf6fe91e5af2f42aad4554e59328fafe477a (patch)
treea41831a1891cdf9d0aa0956f85879dc23a7a6ae2
parentefc74f972ab1200a52841f17cfaa6499d9bf2359 (diff)
wessel balls
-rw-r--r--index.html15
1 files changed, 12 insertions, 3 deletions
diff --git a/index.html b/index.html
index 852ff97..b2c25e1 100644
--- a/index.html
+++ b/index.html
@@ -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();