js实现一个简单类似超级玛丽闯关小游戏代码

代码语言:html

所属分类:游戏

代码描述:js实现一个简单类似超级玛丽闯关小游戏代码

代码标签: js 简单 类似 超级 玛丽 闯关 小游戏 代码

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

<!doctype html>
<html>
<head>
<meta charset="utf-8">


<style>
body {
  background: #222;
}

h2 {
  color: #666;
  font-family: monospace;
  text-align: center;
}

.background {
  table-layout: fixed;
  border-spacing: 0;
}

.background td {
  padding: 0;
}

.lava, .actor {
  background: #e55;
}

.wall {
  background: #444;
  border: solid 3px #333;
  box-sizing: content-box;
}

.actor {
  position: absolute;
}

.coin {
  background: #e2e838;
  border-radius: 50%;
}

.player {
  background: #335699;
  box-shadow: none;
}

.lost .player {
  background: #a04040;
}

.won .player {
  background: green;
}

.game {
  position: relative;
  overflow: hidden;
}
</style>
</head>
<body>

<h2>简单JavaScript闯关小游戏</h2>

<script>
var LEVELS = [
	["                                                                                ",
		"                                                                                ",
		"                                                                                ",
		"                                                                                ",
		"                                                                                ",
		"                                                                                ",
		"                                                                  xxx           ",
		"                                                   xx      xx    xx!xx          ",
		"                                    o o      xx                  x!!!x          ",
		"                                                                 xx!xx          ",
		"                                   xxxxx                          xvx           ",
		"                                                                            xx  ",
		"  xx                                      o o                                x  ",
		"  x                     o                                                    x  ",
		"  x                                      xxxxx                             o x  ",
		"  x          xxxx       o                                                    x  ",
		"  x  @       x  x                                                xxxxx       x  ",
		"  xxxxxxxxxxxx  xxxxxxxxxxxxxxx   xxxxxxxxxxxxxxxxxxxx     xxxxxxx   xxxxxxxxx  ",
		"                              x   x                  x     x                    ",
		"                              x!!!x                  x!!!!!x                    ",
		"                              x!!!x                  x!!!!!x                    ",
		"                              xxxxx                  xxxxxxx                    ",
		"                                                                                ",
		"                                                                                "
	],
	["                                      x!!x                        xxxxxxx                                    x!x  ",
		"                                      x!!x                     xxxx     xxxx                                 x!x  ",
		"                                      x!!xxxxxxxxxx           xx           xx                                x!x  ",
		"                                      xx!!!!!!!!!!xx         xx             xx                               x!x  ",
		"                                       xxxxxxxxxx!!x         x                                    o   o   o  x!x  ",
		"                                                xx!x         x     o   o                                    xx!x  ",
		"                                                 x!x         x                                xxxxxxxxxxxxxxx!!x  ",
		"                                                 xvx         x     x   x                        !!!!!!!!!!!!!!xx  ",
		"                                                             xx  |   |   |  xx            xxxxxxxxxxxxxxxxxxxxx   ",
		"                                                              xx!!!!!!!!!!!xx            v                        ",
		"                                                               xxxx!!!!!xxxx                                      ",
		"                                               x     x            xxxxxxx        xxx         xxx                  ",
		"                                               x     x                           x x         x x                  ",
		"                                               x     x                             x         x                    ",
		"                                               x     x                             xx        x                    ",
		"                                               xx    x                             x         x                    ",
		"                                               x     x      o  o     x   x         x         x                    ",
		"               xxxxxxx        xxx   xxx        x     x               x   x         x         x                    ",
		"              xx     xx         x   x          x     x     xxxxxx    x   x   xxxxxxxxx       x                    ",
		"             xx       xx        x o x          x    xx               x   x   x               x                    ",
		"     @       x         x        x   x          x     x               x   x   x               x                    ",
		"    xxx      x         x        x   x          x     x               x   xxxxx   xxxxxx      x                    ",
		"    x x      x         x       xx o xx         x     x               x     o     x x         x                    ",
		"!!!!x x!!!!!!x         x!!!!!!xx     xx!!!!!!!!xx    x!!!!!!!!!!     x     =     x x         x                    ",
		"!!!!x x!!!!!!x         x!!!!!xx       xxxxxxxxxx     x!!!!!!!xx!     xxxxxxxxxxxxx xx  o o  xx                    ",
		"!!!!x x!!!!!!x         x!!!!!x    o                 xx!!!!!!xx !                    xx     xx                     ",
		"!!!!x x!!!!!!x         x!!!!!x                     xx!!!!!!xx  !                     xxxxxxx                      ",
		"!!!!x x!!!!!!x         x!!!!!xx       xxxxxxxxxxxxxx!!!!!!xx   !                                                  ",
		"!!!!x x!!!!!!x         x!!!!!!xxxxxxxxx!!!!!!!!!!!!!!!!!!xx    !                                                  ",
		"!!!!x x!!!!!!x         x!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!xx     !                                                  "
	],
	["                                                                                                              ",
		"                                                                                                              ",
		"                                                                                                              ",
		"                                                                                                              ",
		"                                                                                                              ",
		"                                        o                                                                     ",
		"                                                                                                              ",
		"                                        x                                                                     ",
		"                                        x                                                                     ",
		"                                        x                                                                     ",
		"                                        x                                                                     ",
		"                                       xxx                                                                    ",
		"                                       x x                 !!!        !!!  xxx                                ",
		"                                       x x                 !x!        !x!                                     ",
		"                                     xxx xxx                x          x                                      ",
		"                                      x   x                 x   oooo   x       xxx                            ",
		"                                      x   x                 x          x      x!!!x                           ",
		"                                      x   x                 xxxxxxxxxxxx       xxx                            ",
		"                                     xx   xx      x   x      x                                                ",
		"                                      x   xxxxxxxxx   xxxxxxxx              x x                               ",
		"                                      x   x           x                    x!!!x                              ",
		"                                      x   x           x                     xxx                               ",
		"                                     xx   xx          x                                                       ",
		"                                      x   x= = = =    x            xxx                                        ",
		"                                      x   x           x           x!!!x                                       ",
		"                                      x   x    = = = =x     o      xxx       xxx                              ",
		"                                     xx   xx          x                     x!!!x                             ",
		"                              o   o   x   x           x     x                xxv        xxx                   ",
		"                                      x   x           x              x                 x!!!x                  ",
		"                             xxx xxx xxx xxx     o o  x!!!!!!!!!!!!!!x                   vx                   ",
		"                             x xxx x x xxx x          x!!!!!!!!!!!!!!x                                        ",
		"                             x             x   xxxxxxxxxxxxxxxxxxxxxxx                                        ",
		"                             xx           xx                                         xxx                      ",
		"  xxx                         x     x     x                                         x!!!x                xxx  ",
		"  x x                         x    xxx    x                                          xxx                 x x  ",
		"  x                           x    xxx    xxxxxxx                        xxxxx                             x  ",
		"  x                           x           x                              x   x                             x  ",
		"  x                           xx          x                              x x x                             x  ",
		"  x                                       x       |xxxx|    |xxxx|     xxx xxx                             x  ",
		"  x                xxx             o o    x                              x         xxx                     x  ",
		"  x               xxxxx       xx          x                             xxx       x!!!x          x         x  ",
		"  x               oxxxo       x    xxx    x                             x x        xxx          xxx        x  ",
		"  x                xxx        xxxxxxxxxxxxx  x oo x    x oo x    x oo  xx xx                    xxx        x  ",
		"  x      @          x         x           x!!x    x!!!!x    x!!!!x    xx   xx                    x         x  ",
		"  xxxxxxxxxxxxxxxxxxxxxxxxxxxxx           xxxxxxxxxxxxxxxxxxxxxxxxxxxxx     xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx  ",
		"                                                                                                              ",
		"                                                                                                              "
	],
	["                                                                                                  xxx x       ",
		"                                                                                                      x       ",
		"                                                                                                  xxxxx       ",
		"                                                                                                  x           ",
		"                                                                                                  x xxx       &qu.........完整代码请登录后点击上方下载按钮下载查看

网友评论0