-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhorse.html
56 lines (49 loc) · 1023 Bytes
/
horse.html
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
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.horse {
background: url("img/horse.jpg") no-repeat scroll 0% 0% rgba(0, 0, 0, 0);
background-position: 0 0;
height: 136px;
width: 189px;
}
</style>
</head>
<body>
<div class="horse">
</div>
</body>
</html>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var posx = 0;
var posy = 0;
var x = 3;
var y = 3;
var count = 0;
window.setInterval(function(){
run_now();
}, 50);
function run_now() {
posx = -x*183;
posy = -y*134;
//console.log(posx + " " + posy);
x++;
if(x>3) {
x = 0;
y = y + 1;
}
if(y > 3) {
x = 0;
y = 0;
}
//console.log(posy+"y");
$(".horse").css({'background-position': posx+'px '+ posy+'px'});
//$(".horse").css('background-position-x', -posx);
//$(".horse").css('background-position-y', -posy);
}
});
</script>