Who is the reporter... ?
CBSE, JEE, NEET, CUET
Question Bank, Mock Tests, Exam Papers
NCERT Solutions, Sample Papers, Notes, Videos
Posted by Royal Thakur ? 3 years, 3 months ago
- 4 answers
Royal Thakur ? 2 years, 9 months ago
Thank you
Bro
</marquee>
Royal Thakur ? 2 years, 9 months ago
Thank you
Bro </marquee>
Royal Thakur ? 3 years, 3 months ago
Simple Shooter Game
On building this simple game I learnt more about how the programming languages HTML5, CSS and JavaScript worked. The rules are stated below
- jkdsgjs
- hfdja
- `jeatngdadv
Have fun!!
<button onclick="shootLeft()" style="top:400px; left:100px;" type="leftButton">Shoot left</button> <button onclick="shootRight()" style="top:400px; left:200px;" type="rightButton">Shoot right</button> <div> </div> </div> <script> var ball = null; var x = 1; var score = 0; document.getElementById('score').innerHTML = '0'; var animate; ball = document.getElementById('ball'); function shootLeft(){ var ran = Math.random(); while(parseInt(ball.style.top) != 300){ ball.style.left = parseInt(ball.style.left) - 1 + 'px'; ball.style.top = parseInt(ball.style.top) - 1 + 'px'; animate = setTimeout(shootLeft,20); } if(ran<0.3){ score = score + 1; document.getElementById('score').innerHTML = score; } else{ document.getElementById('score').innerHTML = score; } x++; if(x==10){ document.getElementById('gameover').innerHTML = "Game over! You got a score of " + score; } ball.style.left = '300px'; ball.style.top = '410px'; } function shootRight(){ van ran = Math.random(); while(parseInt(ball.style.top != 300){ ball.style.left = parseInt(ball.style.left) + 1 + 'px'; ball.style.top = parseInt(ball.style.top) - 1 + 'px'; animate = setTimeout(shootRight,20); } if(ran>0.7){ score = score + 1; document.getElementById('score').innerHTML = score; } else{ document.getElementById('score').innerHTML = score; } x++; if(x==10){ document.getElementById('gameover').innerHTML = "Game over! You got a score of " + score; } ball.style.left = '300px'; ball.style.top = '410px'; } } </script> </body> </html>Related Questions
Posted by Account Deleted 1 month, 4 weeks ago
- 4 answers
Posted by Account Deleted 1 month, 3 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 4 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 3 weeks ago
- 5 answers
Posted by ...... ..... 1 week, 2 days ago
- 5 answers
Posted by Account Deleted 1 month, 4 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 4 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 3 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 3 weeks ago
- 5 answers
Posted by Account Deleted 1 month, 4 weeks ago
- 5 answers
myCBSEguide
Trusted by 1 Crore+ Students
Test Generator
Create papers online. It's FREE.
CUET Mock Tests
75,000+ questions to practice only on myCBSEguide app
Kanha Gupta 1 year, 10 months ago
1Thank You