-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
67 lines (67 loc) · 1.85 KB
/
index.html
File metadata and controls
67 lines (67 loc) · 1.85 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<html>
<head>
<title>Dragtar</title>
<style>
body {
background:#000;
}
.map {
width:10px;
height:10px;
position: relative;
margin:10% auto ;
padding-left:120px;
}
.tile {
width:128px;
height:64px;
background-image:url("tile.png");
position: Absolute;
}
.stone1 {
background-position: 256px -128px;
}
.grass1 {
background-position: 0px 0px;
}
.stone2 {
background-position: 384px -128px;
}
.grass2 {
background-position: 256px -192px;
}
.tile:hover {
box-shadow:inset 1px 1px 5px 0px rgba(115, 63, 63, 0.75);
}
</style>
</head>
<body>
<div class="map">
</div>
</body>
<script>
const map=document.querySelector(".map");
let marginX=0;
let marginY=0;
let plusX=0;
let plusY=0;
for(let y=0;y<5;y++){
for(let x=0;x<5;x++){
let tile=Math.floor((Math.random()*10));
if(tile>0 && tile<6){
tile="grass1";
}else if(tile>=6 && tile<=7){
tile="stone1";
}
else if(tile>8 && tile<=10){
tile="stone2";
}
map.insertAdjacentHTML("beforeend",`<div class="tile ${tile}" style="left:${marginX}px; top:${marginY}px;"></div>`);
marginY+=32;
marginX+=64;
}
marginX=-(64*(y+1));
marginY=(32*(y+1));
}
</script>
</html>