MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / start

Function start

assets/js/carAvoidanceGame.js:77–104  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75 }
76}
77function start(){
78 startScreen.classList.add('hide');
79 gameArea.innerHTML="";
80 player.start=true;
81 player.score=0;
82 window.requestAnimationFrame(gamePlay);
83 for(x=0;x<5;x++){
84 let roadLine=document.createElement('div');
85 roadLine.setAttribute('class','lines');
86 roadLine.y=(x*150);
87 roadLine.style.top=roadLine.y + "px";
88 gameArea.appendChild(roadLine);
89 }
90 let car=document.createElement('div');
91 car.setAttribute('class','car');
92 gameArea.appendChild(car);
93 player.x=car.offsetLeft;
94 player.y=car.offsetTop;
95 for(x=0;x<3;x++){
96 let enemyCar=document.createElement('div');
97 enemyCar.setAttribute('class','enemy');
98 enemyCar.y=((x+1) *350) *-1;
99 enemyCar.style.top=enemyCar.y + "px";
100 enemyCar.style.backgroundColor=randomColor();
101 enemyCar.style.left=Math.floor(Math.random() *350) + "px";
102 gameArea.appendChild(enemyCar);
103 }
104}
105function randomColor(){
106 function c(){
107 let hex=Math.floor(Math.random()*256).toString(16);

Callers

nothing calls this directly

Calls 1

randomColorFunction · 0.70

Tested by

no test coverage detected