-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgame.js
More file actions
52 lines (51 loc) · 1.09 KB
/
game.js
File metadata and controls
52 lines (51 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
function main(){
init();
for(var i=1;i<=9;i++)Piece_Data("hu",0,i,0);
}
function init(){
var board=new Array();
for(var i=0;i<9;i++){
board[i] = new Array();
for(var j=0;j<9;j++){
board[i][j] = document.createElement("img");
document.body.appendChild(board[i][j]);
board[i][j].src = "res/ban.jpg";
board[i][j].style.position="absolute";
}
}
for(var x=32,i=0;i<9;x+=33,i++){
for(var y=32,j=0;j<9;y+=33,j++){
board[i][j].style.left=x+"px";
board[i][j].style.top=y+"px";
}
}
}
function hoge(picName,n){
var hu;
hu=document.createElement("img");
document.body.appendChild(hu);
hu.src = "res/"+picName+".jpg";
hu.style.position="absolute";
hu = DisplayPos(n,7,hu);
return hu;
}
function DisplayPos(x,y,pic){
var dx = Convert_PosX(x);
var dy = Convert_PosY(y);
pic.style.left = dx+"px";
pic.style.top = dy+"px";
return pic;
}
function Piece_Data(name,which,x,y){
this.name = name;
this.which = which; //敵か味方
this.x = x;
this.y = y;
this.pic = hoge(name,this.x);
}
function Convert_PosX(x){
return 32*x+x-1;
}
function Convert_PosY(y){
return 32*y+y-1;
}