File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ( ) ;
Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change 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
2931}
3032
3133.car {
32- height : 90 px ;
33- width : 50 px ;
34+ height : 75 px ;
35+ width : 41 px ;
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 : 50 px ;
46+ width : 41 px ;
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}
You can’t perform that action at this time.
0 commit comments