通过前端HTML、css,js编写的一个小游戏,通过点击事件和鼠标事件设置打击的坐标等等
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> *{ margin: 0; padding: 0; } canvas{ border: 1px solid #ccc; } </style> </head> <body> <button id="btn">开始游戏</button><br> <canvas id="game"></canvas> <script src="./js/GameTime.js"></script> <script src="./js/Wolf.js"></script> <script src="./js/GameMap.js"></script> <script src="./js/GameMenu.js"></script> <script src="./js/GameOver.js"></script> <script src="./js/GameView.js"></script> <script src="./js/Game.js"></script> <script> let game = new Game('game',480,800); document.getElementById('btn').onclick = function(){ game.start(); } </script> </body> </html>
评论