Skip to content

Commit 33d0271

Browse files
committed
Improved Car game - Fix 2
1 parent 775f878 commit 33d0271

File tree

3 files changed

+14
-20
lines changed

3 files changed

+14
-20
lines changed

76 - Car Game/app.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,14 @@ function moveEnemies(playercar) {
3535
othercarb = item.getBoundingClientRect();
3636
if (!((playercarb.bottom < othercarb.top) || (playercarb.top > othercarb.bottom) || (playercarb.left > othercarb.right) || (playercarb.right < othercarb.left))) {
3737
// alert("Press OK to play again");
38-
alert("The Score is " + (score) + "\n Press OK to play again");
38+
alert("The Final Score is " + (score) + "\n Press OK to play again");
3939
location.reload()
4040
player.start = false;
4141
}
4242
if (item.y >= 815) {
4343
// Player will earn score when the car will pass enemy car
4444
score = score + 1;
45+
startBtn.innerHTML = "Score: " + score;
4546
item.y = -300;
4647
item.style.left = Math.floor(Math.random() * 350) + 'px';
4748
}
@@ -129,9 +130,10 @@ function init() {
129130
}
130131

131132
function startgame() {
132-
startBtn.innerHTML = "Use Arrow keys to Navigate";
133-
startBtn.style.opacity = 0.65;
133+
document.querySelector(".push").style.border = "5px solid rgb(86,50,57)";
134+
startBtn.style.backgroundColor = "rgb(86,50,57)";
134135
startBtn.style.cursor = "not-allowed";
136+
startBtn.innerHTML = "Use Arrow keys to Navigate";
135137
init();
136138
}
137139

76 - Car Game/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<meta charset="UTF-8" />
66
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
77
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>Document</title>
8+
<title>Car Game</title>
99
<link rel="stylesheet" href="style.css" />
1010
</head>
1111

1212
<body>
1313
<div class="container">
1414
<div class="road">
15-
<div class="push">
16-
<button class="btn" onclick="startgame()">Start Game</button>
17-
</div>
15+
</div>
16+
<div class="push">
17+
<button class="btn" onclick="startgame()">Start Game</button>
1818
</div>
1919
</div>
2020

76 - Car Game/style.css

+5-13
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,24 @@
1010
} */
1111
body {
1212
overflow: hidden;
13+
1314
}
1415

1516
.container {
1617
background-color: rgb(118, 189, 159);
1718
background-size: cover;
1819
min-height: 99%;
19-
20-
/* Equal to height of footer */
21-
/* But also accounting for potential margin-bottom of last child */
22-
margin-bottom: -50px;
23-
/* visibility: hidden; */
24-
2520
}
2621

2722
.road {
2823
background-color: black;
29-
height: 100vh;
24+
height: 93vh;
3025
width: 400px;
3126
margin: auto;
3227
position: relative;
3328
border-left: 5px white dashed;
3429
border-right: 5px white dashed;
3530
z-index: 1;
36-
/* display: flex; */
37-
/* border-collapse: collapse;
38-
display: table; */
3931
}
4032

4133
.lines {
@@ -73,7 +65,6 @@ body {
7365
}
7466

7567
.btn {
76-
7768
background-color: crimson;
7869
color: #fff;
7970
border: 1px solid;
@@ -86,6 +77,7 @@ body {
8677

8778
.push {
8879
height: 50px;
89-
top: 100%;
90-
transform: translateY(1515%);
80+
width: 401px;
81+
transform: translateX(107%);
82+
border: 5px solid crimson;
9183
}

0 commit comments

Comments
 (0)