add basic script

master
Fouque Dimitri 2017-12-08 21:22:36 +01:00 committed by GitHub
parent 473749c2a3
commit 50982ed04a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 100 additions and 0 deletions

1
de_tank-master/README.md Normal file
View File

@ -0,0 +1 @@
# de_tank

View File

@ -0,0 +1,39 @@
body{
margin: 0;
padding: 0;
font-family: sans-serif;
background: #232323;
}
.header{
text-align: center;
}
.header h1{
display: inline-block;
font-size: 42px;
padding-top: 15px;
padding-bottom: 20px;
color: #fff;
}
.map{
width: 1170px;
height: 658px;
border: solid 3px red;
background: url(../img/bg_sand.png) repeat;
position: absolute;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
}
.block{
height: 20px;
width: 20px;
background: green;
position: absolute;
left: 50px;
top: 50px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -0,0 +1,43 @@
function move(event) {
var k = event.keyCode,
chrId = document.querySelector('.test'),
chrId = document.querySelector('.alderiate'),
chr = {
updown: function () {
var y = parseInt(getComputedStyle(chrId).top);
if (k == 38) {
y -= 10;
if ( y == -10 ){
y += 10;
}
} else if (k == 40) {
y += 10;
if ( y == 410 ){
y -= 10;
}
}
return y;
},
leftright: function () {
var x = parseInt(getComputedStyle(chrId).left);
if (k == 37) {
x -= 10;
if ( x == -10 ){
x += 10;
}
} else if (k == 39) {
x += 10;
if ( x == 910 ){
x -= 10;
}
}
return x;
}
};
chrId.style.top = (chr.updown()) + "px";
chrId.style.left = (chr.leftright()) + "px";
}
document.addEventListener('keydown', move);

17
de_tank-master/index.html Normal file
View File

@ -0,0 +1,17 @@
<html>
<head>
<meta charset="UTF-8">
<title>de_tank</title>
<link rel="stylesheet" href="./assets/css/style.css">
</head>
<body>
<section class="header">
<h1>de_tank</h1>
</section>
<section class="map">
<div class="block"></div>
</section>
</body>
<script src="assets/js/script.js"></script>
</html>