タイマーイベント【javascript】

トップ】 【じんじんのいろいろ日記】 【カテゴリーサイトマップ

スポンサードリンク

【じんじん】
2025年1月30日
5時27分46秒

タイマーイベント【javascript】
var g_tcnt = 0;

const log = function(msg)
{
let time01 = gettimemin()-g_newtimemin;
//alert("log"+ganimeno);
if(ganimeno<0)
{
//movemap();
//return;
}
if(time01>=g_ibntimec)
{
//g_newtimemin=gettimemin();
}
else
{
//alert("timer"+time01);
return;
}

loopflg = true;
while(loopflg==true)
{
let flg001 = false;
//alert(ganimecode);
let tbl01 = ganimecode.split('¥n');
let tbl02 = tbl01[ganimeno].split(',');
//alert(tbl01[ganimeno]);

if(tbl02[0]=="settxtsound3_play")
{
//alert(tbl02[1]);
settxtsound3(g_soundlst,Number(tbl02[1]));
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="settxtsound2")
{
//alert(tbl02[1]);
g_soundlst = tbl02[1];
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="settxtsound2_play")
{
//alert(tbl02[1]);
settxtsound2(g_soundlst,Number(tbl02[1]));
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="putmapset2")
{
putmapset2(g_canvntbl[Number(tbl02[1])],Number(tbl02[2]),Number(tbl02[3]),Number(tbl02[4]),Number(tbl02[5]));
//alert(gmapscxpos+"("+tbl02[2]+")"+gmapscypos+"("+tbl02[3]+")"+gmapscxsize+tbl02[4]+gmapscysize+tbl02[5]);
//mapscxpos = Number(tbl02[2]);
//gmapscypos = Number(tbl02[3]);
//gmapscxsize = Number(tbl02[4]);
//gmapscysize = Number(tbl02[5]);
//putmapset(gmapscxpos,gmapscypos,gmapscxsize,gmapscysize);
ganimeno++;
flg001 = true;
}


if(tbl02[0]=="settxtcol")
{
g_drawText_ibn_col = tbl02[1];
g_drawText_ibn_col2 = tbl02[2];
g_drawText_ibn_font = tbl02[3];
g_drawText_ibn_maxwidth = tbl02[4];
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="//")
{
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="setwait")
{
g_ibntimec = tbl02[1];
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="puttxt")
{
let sptbl01 = tbl02[2].split(';');
for(let i=0;i<sptbl01.length;i++)
{
//drawText(g_canvntbl[tbl02[1]], sptbl01[i],Number(tbl02[3]),Number(tbl02[4])+i*30);
//g_drawText_font ='40px serif';
let sptbl01a = g_drawText_font.split('p');
//alert(sptbl01a[0]);
let haba = Number(sptbl01a[0]);
draw_ibn_TextW22(g_canvntbl[tbl02[1]], sptbl01[i],Number(tbl02[3]),Number(tbl02[4])+i*haba,g_drawText_ibn_maxwidth);
}
//drawText(g_canvntbl[tbl02[1]], tbl02[2],tbl02[3],tbl02[4]);
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="putimage")
{
let picture2 = new Image();
picture2.onload = function()
{
//ctxno = tbl02[4];
let ctxno = tbl02[1];
let sx = tbl02[3];
let sy = tbl02[4];
let xsize = tbl02[5];
let ysize = tbl02[6];
let putx = tbl02[7];
let puty = tbl02[8];
let putxsize = tbl02[9];
let putysize = tbl02[10];
//clearRect3(g_ctxtbl[ctxno],0,0,400,400);
g_ctxtbl[ctxno].drawImage(picture2,sx,sy,xsize,ysize,putx,puty,putxsize,putysize);
//drawText(g_canvntbl[4], "あいうえお",0,100);
//drawText2(4, "あいうえお",0,100);
}
picture2.src = tbl02[2];//画像ファイル
ganimeno++;
flg001 = true;
}
if(tbl02[0]=="clear")
{
clearRect3(g_ctxtbl[tbl02[1]],tbl02[2],tbl02[3],tbl02[4],tbl02[5]);
ganimeno++;
flg001 = true;
}
if(tbl02[0]=="return")
{
loopflg = false;
ganimeno++;
flg001 = true;
}

if(tbl02[0]=="end")
{
ganimeno=-1;
loopflg = false;
flg001 = true;
}
if(flg001 == false)
{
alert("コードエラー"+tbl02[0]+":"+ganimeno);
}
}
g_newtimemin=gettimemin();
return;

//let time01 = gettimemin()-g_newtimemin;
if(time01>=100)
{
clearRect2("id_canvas4",0,0,400,400);
//drawText("id_canvas4", time01,0,64);
let chipno01 = getmapno("たぬき");
let chipno02 = getmapno("とんぼ");
putmapimage2("id_canvas4",gmapdata[chipno01],100,50+g_tcnt*5);
putmapimage2("id_canvas4",gmapdata[chipno02],100+30,50+g_tcnt*5);
g_newtimemin=gettimemin();
g_tcnt = (g_tcnt+1)%30;
}
//alert(msg);
//console.log("test");
//clearRect2("id_canvas4",0,0,400,400);
//putcom01();
//let d = new Date();
//drawText("id_canvas4", time01,0,64);
}