Skip to content

Commit fe4aa10

Browse files
committed
Fixed 76 Car Game
1 parent b1b19f2 commit fe4aa10

6 files changed

Lines changed: 41 additions & 12 deletions

File tree

76 - Car Game/app.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function moveEnemies(playercar) {
3434
othercarb = item.getBoundingClientRect();
3535
if (! ((playercarb.bottom < othercarb.top) || (playercarb.top > othercarb.bottom) || (playercarb.left > othercarb.right) || (playercarb.right < othercarb.left)) )
3636
{
37-
alert("Game over , Refresh to play again");
37+
alert("Press OK to play again");
38+
location.reload()
3839
player.start = false;
3940
}
4041
if (item.y >= 630) {
@@ -123,5 +124,10 @@ function init() {
123124
roadArea.appendChild(enemies);
124125
}
125126
}
127+
128+
function myFunction() {
129+
document.querySelector('.button-container-div').style.display = "none";
130+
document.querySelector('.container').style.visibility = "visible";
131+
init();
132+
}
126133

127-
init();

76 - Car Game/car2.png

459 KB
Loading

76 - Car Game/enemycar.jpg

84.1 KB
Loading

76 - Car Game/enemycar2.png

490 KB
Loading

76 - Car Game/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
<link rel="stylesheet" href="style.css" />
99
</head>
1010
<body>
11+
<div class="button-container-div">
12+
<button class="btn" onclick="myFunction()">Start Car Game</button>
13+
</div>
1114
<div class="container">
1215
<div class="road"></div>
1316
</div>

76 - Car Game/style.css

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
*{
22
margin: 0;
33
padding: 0;
4+
background-color: rgb(118, 189, 159);
45
}
56

67
.container{
78
background-color: rgb(118, 189, 159);
89
background-size: cover;
10+
visibility: hidden;
911

1012
}
1113

@@ -29,21 +31,39 @@
2931
}
3032

3133
.car {
32-
height: 90px;
33-
width: 50px;
34+
height: 75px;
35+
width: 41px;
3436
position: absolute;
35-
background-color: blueviolet;
36-
background-image: url("car.jpg");
37-
background-size: contain;
37+
background-color: rgb(0, 0, 0);
38+
background-image: url("car2.png");
39+
background-size: cover;
3840
bottom:120px;
41+
background-position-x: center;
3942
}
4043

4144
.enemies {
4245
height: 90px;
43-
width: 50px;
46+
width: 41px;
4447
position: absolute;
45-
background-color: rgb(223, 27, 27);
46-
/* background-image: url("car.jpg"); */
47-
/* background-size: contain; */
48-
bottom:120px;
48+
background-color: rgb(0, 0, 0);
49+
background-image: url("enemycar2.png");
50+
-webkit-transform: scaleY(-1);
51+
background-size: cover;
52+
bottom: 120px;
53+
background-position-x: center;
54+
}
55+
56+
.button-container-div {
57+
height: 100vh;
58+
display: flex;
59+
}
60+
61+
.btn {
62+
background-color: crimson;
63+
color: #fff;
64+
border: 1px solid;
65+
padding: 10px;
66+
width: 200px;
67+
outline: none;
68+
margin: auto;
4969
}

0 commit comments

Comments
 (0)