js+css实现移动鼠标穿过数字迷宫不碰墙壁闯关游戏代码

代码语言:html

所属分类:游戏

代码描述:js+css实现移动鼠标穿过数字迷宫不碰墙壁闯关游戏代码,每个字母就是一关卡。

代码标签: js css 移动 鼠标 穿过 数字 迷宫 不碰 墙壁 闯关 游戏 代码

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

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

<head>
 
<meta charset="UTF-8">
 

 
 
 
 
<style>
@import url("https://fonts.googleapis.com/css2?family=Passion+One:wght@400;700;900&display=swap");

html
{
       
--solid-size: calc(85vh * .0714);
       
min-height: 100vh;
       
background: var(--block-color);
       
overflow: hidden;
       
cursor: none;
       
display: grid;
       
place-items: center;
       
font-family: system-ui;
       
box-shadow: inset 0 0 25vmin 10vmin black;
}

body:after {
       
content: "";
       
position: absolute;
       
inset: 0;
       
pointer-events: none;
}

#title_screen {
       
display: grid;
       
place-items: center;
       
align-content: center;
       
position: fixed;
       
inset: 0;
       
color: white;
       
font-family: "Passion One", system-ui;
       
z-index: 999;
       
cursor: default;
       
background: rgba(0, 0, 0, 0.5);
       
backdrop-filter: blur(5px);
}

#cool_title {
       
font-size: 12rem;
       
text-shadow: 0 10px 10px rgba(0,0,0,.5);
       
margin: 2rem 0;
       
text-align: center;
       
line-height: 72%;
       
transform: skewX(-25deg);
}
#cool_title:before,
#cool_title:after {
       
content: '';
       
width: 50%;
       
height: 40%;
       
position: absolute;
       
background: linear-gradient(to bottom, white 4px, transparent 4px);
       
background-size: 100% 10%;
       
-webkit-mask-image: linear-gradient(to left, black 5%, transparent 60%);
 
mask-image: linear-gradient (to left, black 5%, transparent 60%);
}

#cool_title:before {
       
left: -33%;
       
top: 4%;
       
transform: skewX(10deg);
}
#cool_title:after {
       
left: -43%;
       
top: 55%;
       
transform: skewX(10deg);
}

.title_btn {
       
font-size: 1.5rem;
       
padding: 0.5rem 2rem;
       
font-family: "Passion One", system-ui;
       
line-height: 100%;
       
border-radius: 2rem;
       
color: white;
       
border: 2px solid white;
       
cursor: pointer;
       
background: transparent;
       
letter-spacing: 3px;
       
text-transform: uppercase;
       
display: block;
       
margin: 2rem auto;
       
transition: 0.33s;
       
opacity: .75;
}
.title_btn:hover {
       
background: white;
       
color: black;
       
opacity: 1;
}

#menu_toggle {
       
position: fixed;
       
left: 1rem;
       
top: 1rem;
       
z-index: 9999;
       
padding: 0.75rem 0.5rem 0.5rem 0.5rem;
       
line-height: 80%;
       
margin: 0;
       
opacity: 0.5;
       
letter-spacing: 0;
}
#menu_toggle:hover {
       
opacity: 1;
       
box-shadow: none;
}

#maze {
       
width: calc(var(--solid-size) * 14);
       
font-size: 0;  
}

.block {
       
width: var(--solid-size);
       
aspect-ratio: 1/1;
       
position: relative;
       
display: inline-block;
}

.solid {
       
background: conic-gradient(
                at
50% 35%,
                rgba
(0, 0, 0, 0.05) 55deg,
                rgba
(0, 0, 0, 0.25) 55deg 140deg,
                rgba
(0, 0, 0, 0.65) 140deg 220deg,
                rgba
(0, 0, 0, 0.35) 215deg 305deg,
                rgba
(0, 0, 0, 0.05) 305deg
       
),
                var
(--block-color);
       
outline: 1px solid black;
       
box-shadow: 0 25px 5px rgba(0, 0, 0, .25);
}

.path {
       
background: rgba(0, 0, 0, 0.5);
}

.start:after,
.end:after {
       
content: "\21DB";
       
position: absolute;
       
inset: 0;
       
display: grid;
       
place-items: center;
       
color: var(--block-color);
       
font-size: 2rem;
       
line-height: var(--solid-size);
       
filter: none !important;
       
animation: start_end 2s linear infinite;
}

@keyframes start_end {
       
25% {
               
transform: translateX(5px);
       
}
       
75% {
               
transform: translateX(-5px);
       
}
}

.even_level .start:after,
.even_level .end:after {
       
content: "\21DA" !important;
}

#light {
       
width: var(--solid-size);
       
aspect-ratio: 1/1;
       
background: radial-gradient(
                circle at
50% 50%,
                transparent
20%,
                white
20% 24%,
                transparent
24%
       
),
                linear-gradient
(to right, transparent 48%, white 48% 52%, transparent 52%),
                linear-gradient
(
                        to bottom
,
                        transparent
48%,
                        white
48% 52%,
                        transparent
52%
               
);
       
border-radius: 50%;
       
position: absolute;
       
/*   box-shadow: 0 0 200px 50px white; */
       
pointer-events: none;
       
filter: drop-shadow(0px 0px 5px white);
}

/* END SCREEN END SCREEN */
/* END SCREEN END SCREEN */
/* END SCREEN END SCREEN */
/* END SCREEN END SCREEN */
/* END SCREEN END SCREEN */
#level_complete {
       
padding: 2rem;
       
z-index: 1000;
       
position: fixed;
       
inset: 0;
       
background: rgba(0, 0, 0, 0.75);
       
backdrop-filter: blur(5px);
       
text-align: center;
       
box-sizing: border-box;
       
color: white;
       
font-family: "Passion One", system-ui;
       
display: grid;
       
place-items: center;
       
align-content: center;
       
display: none;
       
cursor: auto;
}
#level_complete * {
       
box-sizing: border-box;
}

#level_complete h1 {
       
font-size: 7rem;
       
margin: 0 0 0rem 0;
       
/*   font-variant: small-caps; */
}

#last_run {
       
font-size: 1.5rem;
       
letter-spacing: 0.15rem;
       
margin-bottom: 2rem;
}
#last_run span {
       
font-size: 3rem;
       
line-height: 80%;
       
vertical-align: middle;
       
/*   display: block; */
}

#level_complete .runs {
       
/*   margin: 4rem 0; */
}

#level_complete #current_run,
#level_complete #best_run {
       
display: inline-block;
       
vertical-align: middle;
       
margin: 2rem;
}

#level_complete #current_run {
       
font-size: 2rem;
       
font-weight: 400;
       
text-transform: uppercase;
       
background-color: white;
       
/*   box-shadow: inset 0 0 0 4px rgba(0,0,0,.25); */
       
width: fit-content;
       
color: black;
       
padding: 1rem 1rem 1rem 6rem;
       
border-radius: 1rem;
       
position: relative;
       
text-align: right;
       
perspective: 500px;
}
#level_complete #current_run span {
       
font-size: 5rem;
       
line-height: 80%;
       
font-weight: 900;
       
display: block;
       
letter-spacing: 0.25rem;
}

#level_complete #best_run {
       
font-size: 2rem;
       
text-transform: uppercase;
       
position: relative;
}

.time_spot {
       
font-size: 3rem;
       
margin: 1rem;
       
position: relative;
       
padding: 0 1rem 0 2rem;
       
background: rgba(255, 255, 255, 0.15);
       
border-radius: 0.5rem;
}

.gold_:after,
.silver_:after,
.bronze_:after {
       
content: "";
       
height: 50%;
       
aspect-ratio: 1/1;
       
background-color: gold;
       
position: absolute;
       
left: 0%;
       
top: 25%;
       
transform: translateX(-50%);
}
.gold_:after {
       
transform: translateX(-50%) rotate(45deg);
}
.silver_:after {
       
background-color: silver;
       
border-radius: 50%;
}
.bronze_:after {
       
background-color: darkgoldenrod;
}

#current_run.gold_:after {
       
animation: gold_rays 1s linear infinite, gold_spin 5s linear infinite;
}
@keyframes gold_rays {
       
0% {
               
box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.1), 0 0 0 5px rgba(255, 215, 0, 0.8),
                       
0 0 0 10px rgba(255, 215, 0, 0.4), 0 0 0 15px rgba(255, 215, 0, 0.2),
                       
0 0 0 20px rgba(255, 215, 0, 0.1);
       
}
       
100% {
               
box-shadow: 0 0 0 5px rgba(255, 215, 0, 0.8),
                       
0 0 0 10px rgba(255, 215, 0, 0.4), 0 0 0 15px rgba(255, 215, 0, 0.2),
                       
0 0 0 20px rgba(255, 215, 0, 0.1);
       
}
}
@keyframes gold_spin {
       
100% {
               
transform: translateX(-50%) rotateZ(-45deg) rotateY(360deg) rotateX(360deg);
       
}
}

#current_run.silver_:after {
       
animation: silver_rays 1s linear infinite, silver_spin 5s linear infinite;
}
@keyframes silver_rays {
       
0% {
               
box-shadow: 0 0 0 0 rgba(192, 192, 192, 0.1),
                       
0 0 0 5px rgba(192, 192, 192, 0.8), 0 0 0 10px rgba(192, 192, 192, 0.4),
                       
0 0 0 15px rgba(192, 192, 192, 0.2), 0 0 0 20px rgba(192, 192, 192, 0.1);
       
}
       
100% {
               
box-shadow: 0 0 0 5px rgba(192, 192, 192, 0.8),
                       
0 0 0 10px rgba(192, 192, 192, 0.4), 0 0 0 15px rgba(192, 192, 192, 0.2),
                       
0 0 0 20px rgba(192, 192, 192, 0.1);
       
}
}
@keyframes silver_spin {
       
100% {
               
transform: translateX(-50%) rotateY(360deg);
       
}
}
#current_run.bronze_:after {
       
animation: bronze_rays 1s linear infinite, silver_spin 5s linear infinite;
}
@keyframes bronze_rays {
       
0% {
               
box-shadow: 0 0 0 0 rgba(184, 134, 11, 0.1), 0 0 0 5px rgba(184, 134, 11, 0.8),
                       
0 0 0 10px rgba(184, 134, 11, 0.4), 0 0 0 15px rgba(184, 134, 11, 0.2),
                       
0 0 0 20px rgba(184, 134, 11, 0.1);
       
}
       
100% {
               
box-shadow: 0 0 0 5px rgba(184, 134, 11, 0.8),
                       
0 0 0 10px rgba(184, 134, 11, 0.4), 0 0 0 15px rgba(184, 134, 11, 0.2),
                       
0 0 0 20px rgba(184, 134, 11, 0.1);
       
}
}
.replay_or_next {
       
display: flex;
       
flex-direction: row;
       
align-items: center;
       
gap: 2rem;
}
#next_level,
#replay_level {
       
position: relative !important;
       
transition: 0.5s;
       
opacity: 0.5;
}
#next_level:hover,
#replay_level:hover {
       
opacity: 1;
       
background: white;
       
color: black;
}

#level_complete button {
       
font-size: 1.5rem;
       
padding: 0.5rem 2rem;
       
font-family: "Passion One", system-ui;
       
line-height: 100%;
       
border-radius: 2rem;
       
color: white;
       
border: 2px solid white;
       
position: absolute;
       
cursor: pointer;
       
background: transparent;
       
letter-spacing: 3px;
}


#levels_menu {
       
/*   display: none; */
       
top: 1rem;
       
left: 1rem;
       
transform-origin: 0% 50%;
       
transform: scale(0.75);
}

/* .gold {
background: gold;
}
.silver {
background: silver;
}
.bronze {
background: darkgoldenrod;
} */


/* LEVEL SELECT LEVEL SELECT */
#level_select {
       
padding: 2rem;
       
z-index: 1000;
       
position: fixed;
       
inset: 0;
       
background: rgba(0, 0, 0, 0.75);
       
backdrop-filter: blur(5px);
       
text-align: center;
       
box-sizing: border-box;
       
color: white;
       
font-family: "Passion One", system-ui;
       
display: grid;
       
place-items: center;
       
align-content: center;
       
/*   overflow-y: scroll; */
       
display: none;
       
cursor: default;
}
#level_select * {
       
box-sizing: border-box;
       
user-select: none;
}

#level_select h1 {
       
font-size: 7rem;
       
margin: 0 0 4rem 0;
       
/*   font-variant: small-caps; */
}

#tile_box {
       
width: 100%;
       
max-width: 1200px;
       
perspective: 500px;
}

.level_tile {
       
display: grid;
       
place-items: center;
       
width: calc(100% / 12);
       
padding: 1.25rem 1rem;
       
aspect-ratio: 1/1;
       
font-size: 3rem;
       
text-transform: uppercase;
       
background: white;
       
color: black;
       
margin: 1rem;
       
cursor: pointer;
       
transition: 0.25s;
       
transform-origin: 50% 50%;
       
line-height: 90%;
       
float: left;
}
.level_tile:hover {
       
transform: scale(1.2);
}

.level_tile b {
       
font-size: 1rem;
       
line-height: 0;
}

.gold_tile {
       
background: gold !important;
       
clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}
.silver_tile {
       
background: silver !important;
       
border-radius: 50% !important;
}
.bronze_tile {
       
background: darkgoldenrod !important;
       
clip-path: polygon(10% 10%, 90% 10%, 90% 90%, 10% 90%);
}
</style>

 
</head>

<body translate="no">

<button id='menu_toggle' class='title_btn' onclick='title_screen.style.display = "grid"; level_select.style.display = "none"; level_complete.style.display = "none"'>&#9776;</button>
<div id='title_screen'>
       
<p id='cool_title'>Speedy<br>McMousy</p>
       
<div>
               
<button class='title_btn' onclick='this.parentElement.parentElement.style.display = "none"'>Play ></button>
               
<button class='title_btn' onclick='this.parentElement.parentElement.style.display = "none"; openLevels()'>Levels ></button>
               
<!--     <button class='title_btn' onclick='options()'>Options ></button> -->
       
</div>
       
<p>&copy; 2024 </p>
</div>
<div id='level_complete'>
       
<h1 id='level_name'>Level A</h1>
       
<div id='last_run'>
                &#128337;&#xFE0E;&nbsp;
               
<span id='this_run'>00.00</span>
       
</div>

       
<!--   <button id='levels_menu' onclick='openLevels()'>LEVELS</button> -->
       
<div class='runs'>
               
<div id='current_run'>
                       
<span id='best_ever'>0:00.00</span>
                        Best Time
               
</div>
               
<div id='best_run'>
                       
<!--       Goals -->
               
</div>
       
</div>
       
<div class='replay_or_next'>
               
<button id='replay_level' onclick='replayLevel()'>REPLAY ></b.........完整代码请登录后点击上方下载按钮下载查看

网友评论0