-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.html
146 lines (103 loc) · 3.39 KB
/
2.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<html>
<head>
<style>
.ship{
width:200;
position:absolute;
left:260px;
}
.mainbox{
position:absolute;
border-color:grey;
border-width:2px;
border-style:solid;
width:720px;
height:1280px;
background: #537cdb; /* Old browsers */
background: -moz-linear-gradient(top, #537cdb 0%, #ddf1f9 35%, #000eaa 80%, #0025f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#537cdb), color-stop(35%,#ddf1f9), color-stop(80%,#000eaa), color-stop(100%,#0025f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #537cdb 0%,#ddf1f9 35%,#000eaa 80%,#0025f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #537cdb 0%,#ddf1f9 35%,#000eaa 80%,#0025f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #537cdb 0%,#ddf1f9 35%,#000eaa 80%,#0025f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #537cdb 0%,#ddf1f9 35%,#000eaa 80%,#0025f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#537cdb', endColorstr='#0025f7',GradientType=0 ); /* IE6-9 */
}
</style>
<script>
function init(){
ship={
width:200,
xpeed:0,
spos:260,
img:document.getElementById("shipimg"),
calx:function(){
this.spos+=this.xpeed;
},
click:function(event){
if(event.pageX<685) this.xpeed+=1;
else this.xpeed-=1;
},
left:function(){
if(ship.xpeed<1) ship.xpeed=3;
else ship.xpeed+=1;
},
right:function(){
if(ship.xpeed>-1) ship.xpeed=-3;
else ship.xpeed-=1;
}
}
stream={
speed:2,
roll:function() {
ship.calx();
ctx.drawImage(c, 0, 0, w, h-stream.speed, 0, stream.speed, w, h-stream.speed);
ctx.fillRect(ship.spos,ship.hor,ship.width,ship.height+stream.speed);
//ctx.drawImage(ship.blank, ship.spos-10, ship.hor+stream.speed-5,ship.width+20,ship.height+stream.speed+15);
ctx.drawImage(ship.img, ship.spos, ship.hor,ship.width,ship.height);
},
gravity:function(){
setInterval(function(){
if(ship.spos<150-ship.width/2) ship.xpeed-=1;
else ship.xpeed+=1;
},330)
}
}
setInterval(function(){var a=new iceberg();},3000);
console.log("init called")
}
function iceberg()
{
this.width=Math.random()*150+50;
this.vert=Math.random()*(720-this.width);//random;
this.speed=Math.random()*4+1;
this.hor=40;
var ob=document.createElement("IMG");
ob.src="iceberg.png";
ob.style.position="absolute";
ob.style.left=""+this.vert+"px";
ob.style.width=""+this.width+"px";
ob.class="ice";
document.getElementById("shipimg").appendChild(ob);
this.img=ob;
console.log("ice called")
}
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
$(".ice").load(function(){
$(".ice").animate({top:1920},{duration:(3000),easing:'linear'});
})
$('.ship').each(function()
{
var xPos = $(this).offset().left;
xPos += 200;
$(this).offset({'left':xPos});
});
</script>
</head>
<body onclick="init();">
<div class="mainbox" >
<img id="shipimg" class="ship" src="jshipup.png"></img>
</div>
</body>
</html>