js+css实现俄罗斯方块拼图游戏代码
代码语言:html
所属分类:游戏
代码描述:js+css实现俄罗斯方块拼图游戏代码,玩法:点击一个形状 > 点击一个网格块。填满盒子就赢了并重置游戏。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
height: 100vh;
background-color: #232b2b;
margin: 0;
--block-width: 25px;
font-family: system-ui;
color: gray;
font-size: 12px;
}
* {
box-sizing: border-box;
}
p {
max-width: calc(var(--block-width) * 7.5);
user-select: none;
}
#game_box {
position: relative;
width: calc(var(--block-width) * 4);
aspect-ratio: 1/1;
outline: 2px solid black;
}
.winner {
animation: winner 1s linear forwards;
}
@keyframes winner {
100% {
transform: rotate(1080deg);
}
}
.generic_block {
/* background-color: red; */
width: var(--block-width);
height: var(--block-width);
float: left;
border-right: 1px solid black;
border-bottom: 1px solid black;
}
.generic_block:hover {
background: gray;
}
span {
width: var(--block-width);
height: var(--block-width);
border: 2px inset rgba(0, 0, 0, 0.75);
display: block;
pointer-events: all;
cursor: pointer;
}
.square span {
background-color: yellow;
}
.rectangle span {
background-color: turquoise;
}
.lshape span {
background-color: darkorange;
}
.lshape_two span {
background-color: violet;
}
.rectangle {
position: absolute;
/* left: 0; */
/* top: 0; */
}
.lshape,
.lshape_two {
display: grid;
/* transform: rotate(0.75turn); */
grid-template-columns: repeat(3, 25px);
grid-template-rows: repeat(2, 25px);
gap: 0;
position: absolute;
/* left: calc(var(--block-width) * 1); */
/* top: 0; */
}
.lshape_two {
/* left: calc(var(--block-width) * 1); */
/* top: calc(var(--block-width) * 2); */
transform: scaleY(-1);
}
.square {
display: grid;
grid-template-columns: repeat(2, 25px);
grid-template-rows: repeat(2, 25px);
gap: 0;
position: absolute;
/* left: calc(var(--block-width) * 2); */
/* .........完整代码请登录后点击上方下载按钮下载查看
网友评论0