-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
147 lines (123 loc) · 3.58 KB
/
index.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
147
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DreamCar</title>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript">
var x = 480;
var y = 408;
var speed = 5;
var angle = 0;
var mod = 0;
var canvas,context,car;
window.addEventListener("keydown", keypress_handler, false);
window.addEventListener("keyup", keyup_handler, false);
var moveInterval = setInterval(function () {
draw();
}, 10);
function draw() {
canvas = document.getElementById("pcanvas");
context = canvas.getContext("2d");
car = new Image();
car.src = 'c1.jpg';
context.clearRect(0, 0, 1200, 1200);
x -= (speed * mod) * Math.sin(-1 * Math.PI / 180 * angle);
y -= (speed * mod) * Math.cos(-1 * Math.PI / 180 * angle);
context.save();
if(x<1200&&y<700){
context.translate(x, y);
context.rotate(Math.PI / 180 * angle);
context.drawImage(car, -(car.width / 2), -(car.height / 2));
context.restore();
}
//checking the lcation of car and opens the links on reaching hotspot
if(x>420&&x<550&&y>0&&y<100)
window.location.href = "CheckMate/CheckmatePagemod5.html"
if(x>0&&x<70&&y>200&&y<300)
window.location.href = "Showroom/showroompage1.html"
if(x>890&&x<970&&y>200&&y<300)
window.location.href = "AboutUs/aboutus.html"
}
function keyup_handler(event) {
if (event.keyCode == 40 || event.keyCode == 38) {
mod = 0;
}
}
function keypress_handler(event) {
console.log(event.keyCode);
if (event.keyCode == 38) {
mod = 1;
}
if (event.keyCode == 40) {
mod = -1;
}
if (event.keyCode == 37) {
angle -= 5;
}
if (event.keyCode == 39) {
angle += 5;
}
}
window.addEventListener("keydown", function(e) {
if([32, 33, 34, 37, 38, 39, 40].indexOf(e.keyCode) > -1) {
e.preventDefault();
}
}, false);
</script>
<style type="text/css">
@import 'https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300';
html {
background: url(Homepage/back3.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
body{
background-color:transparent;
}
#mainb{
align-content: center;
margin-top: 2%;
}
h3{
color:white;
font-size:25px;
}
h2{
font-family: 'Open Sans Condensed', sans-serif;
font-size:30px;
color:white;
}
#cnv{
background-image:url(Homepage/back%20grass.jpg);
}
.site-footer, .page-wrap:after {
height: 40px;
margin-bottom: 3%;
}
.site-footer {
background: black;
background: rgb(0, 0, 0); /* Fall-back for browsers that don't
support rgba */
background: rgba(0, 0, 0, .7);/*rgba for setting transparency*/
color: white;
}
</style>
</head>
<body onLoad="draw()" onkeydown="keypress_handler(event)" onkeyup="keyup_handler(event)" >
<div id="mainb">
<center><img src="Homepage/heading2.jpg" id="head1" /><center>
<center><h2>YOUR DREAM CAR YOU DIDN'T KNOW OF...YET!</h2></center>
<div style="width:1000px;height:450px;id="box">
<div id="cnv">
<canvas id="pcanvas" width="1000" height="450" ></canvas>
</div>
</div>
</div>
<footer class="site-footer">
<h3><center> Use <strong>Arrow Keys</strong> to control the Car </center></h3>
</footer>
</body>
</html>