js实现简易塔防类小游戏代码

代码语言:html

所属分类:其他

代码描述:js实现简易塔防类小游戏代码,有两个塔,一个塔攻击距离远,凡是速度慢,一个塔攻击距离近,但是速度快,点击鼠标选择放到你想要的位置,敌人就开始进来了。

代码标签: js 简易 塔防 游戏 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开


<!DOCTYPE html>
<html lang="en" >

<head>

  <meta charset="UTF-8">

  
  
  
<style>
html {
  min-height: 100vh;
  display: grid;
  place-items: center;
  font-family: system-ui;
  line-height: 100%;
  user-select: none;
  background: #000;
}

body {
  width: calc(var(--tile-size) * 7);
  position: relative;
}

* {
  user-select: none;
}

#game_map {
  position: relative;
  width: 100%;
  height: 100%;
}

#game_map > div:not(.enemy) {
  width: var(--tile-size);
  aspect-ratio: 1 / 1;
  float: left;
  display: grid;
  place-items: center;
  position: relative;
  outline: 1px dotted #000;
}

.game_ground {
  background: #1436FF;
}
.game_ground:hover {
  background: darkblue;
}
.game_path {
  outline: 0 !important;
  background: black;
  /*   background: 
  radial-gradient(circle, #FFABA5 20%, transparent 20%); */
}
.start:after {
  content: '';
  width: 100% ;
  height: 100%;
  position: absolute;
  lefT: 0;
  top: 0;
  display: grid;
  place-items: center;
  color: rgba(0,0,0,.25);
  /*   background:
  radial-gradient(circle, #FFABA5 15%, transparent 15%); */
}
.game_gold {
  color: black;
  outline: 0 !important;
}
.game_gold:before {
  content:'';
  width: 25%;
  height: 25%;
  position: absolute;
  left: 40%;
  top: 5%;
  z-index: -1;
  border-radius: 50%;
  box-shadow: inset 2px 0 0 2px sienna;
  transform: rotate(20deg);
}
.game_gold:after {
  content:'';
  width: 80%;
  height: 80%;
  position: absolute;
  left: 10%;
  top: 15%;
  background: red;
  clip-path: polygon(50% 14%, 60% 5%, 78% 4%, 94% 12%, 100% 40%, 97% 76%, 81% 94%, 69% 100%, 57% 100%, 50% 93%, 42% 100%, 26% 98%, 7% 77%, 0% 37%, 6% 11%, 25% 4%);
  z-index: -1;
}

#towers_box {
  width: 100%;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translate(-50%, -200%);
  text-align: center;
  z-index: 200;
}
.tow.........完整代码请登录后点击上方下载按钮下载查看

网友评论0