HTML5 tam猫 游戏

要的.就是@...... 2019-07-10 10:12:01
<kbd>用html写一个tom猫的小游戏</kbd><!doctype html><html lang="en"><head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equit="X-UA-Compatible" content="ie=edge"> <title>tam猫</title> <style> img:nth-child(1){width:400px;cursor:default;}img:nth-child(1):active{opacity:1;}img{width:80px;position:absolute;cursor:pointer;}img:active{opacity:0.5;} #肚子{ width:100px; height:100px; /* background-color:brown; */ position:absolute; left:155px; top:400px; } #尾巴{ width:40px; height:85px; /* background-color:brown; */ position:absolute; left:275px; top:500px; } #左脚{ width:50px; height:40px; /* background-color:brown; */ position:absolute; left:210px; top:585px; } #右脚{ width:50px; height:40px; /* background-color:brown; */ position:absolute; left:150px; top:590px; } #头{ width:220px; height:220px; /* background-color:brown; */ position:absolute; left:100px; top:115px; } </style> </head> <body> <img src="Resource/Animations/eat/eat_00.jpg" alt=""> <img src="Resource/Buttons/cymbal.png" alt="" onclick="play('cymbal',12)"> <img src="Resource/Buttons/drink.png" alt="" onclick="play('drink',80)"> <img src="Resource/Buttons/eat.png" alt="" onclick="play('eat',39)"> <img src="Resource/Buttons/fart.png" alt="" onclick="play('fart',27)"> <img src="Resource/Buttons/pie.png" alt="" onclick="play('pie',23)"> <img src="Resource/Buttons/scratch.png" alt="" onclick="play('scratch',55)"> <div id="肚子" onclick="play('stomach',33)"></div> <div id="尾巴" onclick="play('angry',25)"></div> <div id="左脚" onclick="play('foot_left',29)"></div> <div id="右脚" onclick="play('foot_right',29)"></div> <div id="头" onclick="play('knockout',80)"></div> </body> <script> var imgs =document.getElementsByTagName('img'); for(var i=1;i<7;i++){ var img=imgs[i]; img.style.left=parseInt(i/4)*300+20+"px"; img.style.top=((i+2)%3+3)*100+"px";} var tomImg=imgs[0]; var playing=false; function play(name,number){if(playing==true){return;}var count=0;playing=true;function eatshow(){count++;if(count<10){count="0"+count;}tomImg.src="Resource/Animations/"+name+"/"+name+"_"+count+".jpg";if(count<number){setTimeout(eatshow,100);}elseplaying=false;}} eatshow; } </script> </htm
...全文
32 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
好的,我会继续认真改进的
潇湘忆梦 2019-07-11
  • 打赏
  • 举报
回复
提两个小建议哈,
1. 代码写的有点乱,<script>最好还是写在body里面,不要写在body和html之间

2.script文件里面的调用,是不是有点问题呢,play(name, number)嵌套eatshow() 莫不如把eatshow() 拿出来放在play(name, number)平级

61,112

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧