ゴリラ向け動画サイト「ウホウホ動画」にありがちなこと

前回の質問の続き

function mousedown(e){
touchpiece(e.clientX ,e.clientY);
}
function touchpiece(tx,ty){
cx = Math.floor((tx-8)/psize);
cy = Math.floor((ty-8)/psize);
if (isinside(cx,cy,0,0,bw,bh)==false)return;
if (startx == -1){
movestart(cx,cy);
} else {
moveend(cx,cy);
startx = -1;
redraw();
}
}
function movestart(cx,cy){
id = board[cy][cx].id;
if(id == -1)return;
player = board[cy][cx].player;
if(player != turn)return;
startx = cx;
starty = cy;
drawpiece(startx,starty,id,player,2)
if (isinside(startx,starty,ofsx,ofsy,9,9) == false){
for (x=ofsx; x<(ofsx+9); x++){
pawn = 0;
for (y=ofsy; y<(ofsy+9); y++){
if(id != 7)break;
id2 = board[y][x].id;
player2 = board[y][x].player;
if((player == player2)&&(id2 == 7)){
pawn++;
}
}
if(pawn > 0)continue;
margin = [ 0,0,0,0,0,2,1,1 ];
flip = 1-(player*2);
y = ofsy+(player*8)+(margin[id]*flip);
while(isinside(x,y,ofsx,ofsy,9,9) == true){
if(board[y][x].id == -1){
drawpiece(x,y,-1,0,3);
board[y][x].movable = true;
}
y += flip;
}
}return;
}
for (dir=0; dir<10; dir++){
x = startx;
y = starty;
flip = 1-(player*2);
while(movtbl[id][dir] > 0){
x += x1[dir];
y += y1[dir]*flip;
if(isinside(x,y,ofsx,ofsy,9,9) == false)break;
id2 = board[y][x].id;
player2 = board[y][x].player;
if((id2 != -1)&&(player == player2))break;
drawpiece(x,y,id2,player2,3);
board[y][x].movable = true;
if(id2 != -1)break;
if(movtbl[id][dir] == 1)break;
}
}
}
function setMochi(id,player){
tx = (1-player)*(bw-3)+1;
ty = (1-player)*(bh-3)+1;
tx1 = (player*2)-1;
ty1 = (player*2)-1;
for (i=0; i<20; i++){
x = tx+(i % 3)*tx1;
y = ty+Math.floor(i/3)*ty1;
//console.log(i, x, y)
if(board[y][x].id == -1)break;
}
board[y][x].id = id & 7;
board[y][x].player = player;
}
function moveend(endx,endy){
if(board[endy][endx].movable == false)return;
id = board[starty][startx].id;
player = board[starty][startx].player;
if (isinside(startx,starty,ofsx,ofsy,9,9) == true){
exist1 = isinside(startx,starty,ofsx,ofsy+6*player,9,3);
exist2 = isinside(endx ,endy ,ofsx,ofsy+6*player,9,3);
if((exist1 == true)||(exist2 == true)){
if((id < 8)&&(nametbl[id | 8] != "")){
if(confirm("成りますか?")){
board[starty][startx].id |= 8;
}
}
}
}
if(board[endy][endx].id != -1){
setMochi(board[endy][endx].id, player);
}
board[endy][endx].id = board[starty][startx].id;
board[endy][endx].player = board[starty][startx].player;
board[starty][startx].id = -1;
turn = 1 - turn;
}
function drawpiece(x,y,id,player,color){
px = x*psize;
py = y*psize;
ctx.fillStyle = boxcolor[color];
ctx.fillRect(px, py, psize, psize);
ctx.fillStyle = fillcolor[color];
ctx.fillRect(px+1, py+1, psize-2, psize-2);
if(id == -1)return;
ctx.fillStyle = fontcolor[(id >> 3)& 1];
if(player){
px = -px-psize;
py = -py-psize;
ctx.rotate(Math.PI);
}
ctx.fillText(nametbl[id], px+4, py+24,300);
if(player)ctx.rotate(Math.PI);
}
function isinside(x,y,ax,ay,w,h){
if((x<ax)||(x>=(ax+w))||(y<ay)||(y>=(ay+h)))return(false);
return(true);
}
function redraw(){
for (y=0; y<bh; y++){
for (x=0; x<bw; x++){
if (isinside(x,y,ofsx,ofsy,9,9))c=1; else c=0;
id = board[y][x].id;
player = board[y][x].player;
drawpiece(x,y,id,player,c);
board[y][x].movable = false;
}
}
ctx.fillStyle = fontcolor[0];
ctx.fillText(playtbl[turn] ,280 ,(1-turn)*318+26,300);
}
教えて〜

A 回答 (1件)

分割投稿は違反なのさ。


元投稿への補足投稿で追加しましょ
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!

このQ&Aを見た人はこんなQ&Aも見ています


このQ&Aを見た人がよく見るQ&A