アットウィキロゴ

mayu0

<!DOCTYPE html>
<html>
    <head>
        <title>戦争ゲームの練習</title>
        <meta charset="UTF-8">
<link rel="stylesheet" href="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.indigo-pink.min.css">
<script src="https://storage.googleapis.com/code.getmdl.io/1.0.6/material.min.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <script src="sample.js"></script>
        <script src="jquery.js"></script>
<script src="svgpaint.js"></script>
<script src="app.js"></script>
    </head>
   <body onload="sample()">
 
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
 
 
  <header class="mdl-layout__header">
    <div class="mdl-layout__header-row">
    <span class="mdl-layout-title">戦争ゲームの練習</span>
    </div>
      <div class="mdl-layout__tab-bar mdl-js-ripple-effect">
      <a href="#s1" class="mdl-layout__tab is-active">メイン</a>
      <a href="#s2" class="mdl-layout__tab">ルール</a>
    </div>
  </header>
 
  <div class="mdl-layout__drawer">
    <span class="mdl-layout-title">タイトル</span>
  </div>
 
 
  <main class="mdl-layout__content">
    <section class="mdl-layout__tab-panel is-active" id="s1">
        <div class="page-content">
            <p id="memo"></p>
        </div>
    </section>
    <section class="mdl-layout__tab-panel" id="s2">
      <div class="page-content">練習</div>
    </section>
  </main>
 
 
<footer class="mdl-mini-footer">
  <div class="mdl-mini-footer__left-section">
    <div class="mdl-logo">戦争ゲームの練習</div>
    <ul class="mdl-mini-footer__link-list">
      <li><a href="http://osomatsusan.com/">コード</a></li>
      <li><a href="http://osomatsusan.com/">ルール</a></li>
    </ul>
  </div>
</footer>
 
</div>
</body>
</html>
 
var ax=new Array();
var ay=new Array();
var bx=new Array();
var by=new Array();
var a=new Array();
var b=new Array();
 
function sample() {
 
for(s=1;s<11;s++){
a[s]=100;
b[s]=100;
ay[s]=1;
ax[s]=s;
by[s]=10;
bx[s]=s;
} 
 
 var timer;
var delay = 1000;
 
var loop = function () {
 
move_a(); 
 
move_b(); 
 
paint();
 
 
    clearTimeout(timer);
    timer = setTimeout(loop, delay);
}
 
loop();   
 
 
 
 
 
}
 
function move_a(){
 
for(s=1;s<11;s++){
y1=ay[s]+1;
if(y1>10)y1=10;
ch=check_a(ax[s],y1);
if(ch<50)ay[s]=y1;    
}
 
 
}
 
function move_b(){
 
for(s=1;s<11;s++){
y1=by[s]-1;
if(y1<1)y1=1;
ch=check_b(bx[s],y1);
if(ch<50)by[s]=y1;     
}
 
 
}
 
function check_a(px,py){
 
ch=0;
for(sx=1;sx<11;sx++){
h=0;
if(bx[sx]==px)h=h+1;
if(by[sx]==py)h=h+1;   
if(h==2)ch=100;
}
 
return ch;
} 
function check_b(px,py){
 
ch=0;
for(sx=1;sx<11;sx++){
h=0;
if(ax[sx]==px)h=h+1;
if(ay[sx]==py)h=h+1;   
if(h==2)ch=100;
}
 
return ch;
} 
 
function paint(){
 
var sub3=new svgpaint();
 
str="<svg width=\"500\" height=\"500\">";
 
for(s=1;s<11;s++){    
x1=ax[s];
y1=ay[s];
if(a[s]>50)str=str+sub3.rect(50*x1-50,500-50*y1,50,50,"red");
}
 
for(s=1;s<11;s++){    
x1=bx[s];
y1=by[s];
if(b[s]>50)str=str+sub3.rect(50*x1-50,500-50*y1,50,50,"blue");
}
 
 
str=str+"</svg>";
 
$("#memo").html(str);   
 
}
 
最終更新:2016年11月17日 11:12