# forked from jsdo.it_team's "第一回全国統一 HTML5実技コンテスト エントリー用コード" http://jsdo.it/jsdo.it_team/esTj CONST = rpsImg: ["http://jsrun.it/assets/a/H/C/r/aHCrM.png", "http://jsrun.it/assets/a/r/G/j/arGjf.png", "http://jsrun.it/assets/5/R/8/k/5R8kA.png"] rpsName: ["g", "c", "p"] resultMsg: [["じゃん", "けん", "ぽん!"], "DRAW", "YOU WIN", "YOU LOSE"] numBox: 6 $box=$("#win0r") $img=$("#win0i") $rows=$("#rows") $hitArea=$("#hitArea") boxOffset=parseInt($rows.attr("y")) - parseInt($box.attr("y")) boxHeight=parseInt $box.attr("height") hitAreaY=parseInt $hitArea.attr("y") beginYOfImg=parseInt $rows.attr("y") endYOfImg=parseInt($rows.attr("y")) + parseInt($rows.attr("height")) - parseInt($img.attr("height")) beginYOfHit=hitAreaY - boxHeight endYOfHit=hitAreaY + parseInt $hitArea.attr("height") $nbox=$("#win0r").show() $nimg=$("#win0i").attr("xlink:href","http://jsrun.it/assets/5/R/8/k/5R8kA.png").show() fall = (boxID,sp,wait,ls) -> if ls.length !=0 comChoice = Math.floor(Math.random() * 3) [x,xs...] = ls raw=switch x when 1 then "#win" when 2 then "#draw" when 3 then "#lose" if 1<=x<=3 $("#dummy").animate( null: endYOfImg - beginYOfImg , duration: 3000 easing: "linear" step: (now) -> imgY=beginYOfImg + now boxY=imgY+boxOffset # console.log now $nbox.attr("y",imgY) $nimg.attr("y",boxY) if beginYOfHit $nbox.hide() $nimg.hide() ) sBase() _.delay(fall, wait, (boxID+1)%CONST.numBox,sp,wait,xs) sBase = -> document.getElementById("sbase").pause() document.getElementById("sbase").play() sHit = -> document.getElementById("shit").pause() document.getElementById("shit").play() #$("#iconG").click -> fall 0,1500,500, [1,2,2,3,1,1,3,0,0,1,0,3,3,0,0,0,0]