Rumah > hujung hadapan web > tutorial js > html5做剪刀石头布效果的教程

html5做剪刀石头布效果的教程

php中世界最好的语言
Lepaskan: 2017-12-02 11:38:46
asal
3159 orang telah melayarinya

相信大家都玩过剪刀石头布这个游戏,今天为大家带来一段基于angular.js的HTML5剪刀石头布小游戏的代码,这个游戏是人机对战的游戏。用户可以选择剪刀,石头或者布其中一类选项,电脑则会随机选出一个选项对战,胜者是可以加一分的,接下来我们看看源码

<!DOCTYPE html>
<html>
<head>
         <meta charset="UTF-8">
         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
         <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1">
         <meta name="apple-mobile-web-app-capable" content="yes">
         <meta name="apple-mobile-web-app-status-bar-style" content="default">
         <meta name="msapplication-tap-highlight" content="no">
         <title>html5制作剪刀石头布效果</title>
         <meta name="keywords" content=" html5制作剪刀石头布效果" />
         <meta name="description" content=" html5制作剪刀石头布效果" />
         <link rel=&#39;stylesheet prefetch&#39; href=&#39;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css&#39;>
         <link rel="stylesheet" type="text/css" href="css/normalize.css" />
         <link rel="stylesheet" type="text/css" href="css/htmleaf-demo.css">
         <link rel="stylesheet" href="css/style.css">  
</head>
<body ng-app="app" ng-controller="ctrl">
         <main style="background-image: {{b}}">
    <article>
      <div ng-class="{&#39;flip-me&#39;: answered}">
        <div>
          <div>
            <div class="chip bg-light">
              <span class="fa fa-hand-spock-o fa-fw ghost"></span>
            </div>
          </div>
          <div>
            <div class="chip bg-light">
              <span class="fa fa-hand-{{splashIcon}}-o fa-fw"></span>
            </div>
          </div>
        </div>
      </div>
      <div class="answers row around" ng-class="{&#39;ghost&#39;: spocked}">
        <div class="column align-center">
          <div ng-class="uiSetMoveClasses(&#39;rock&#39;, 1)" ng-click="uiPlay(&#39;rock&#39;)">
            <span class="fa fa-hand-rock-o fa-fw fa-2x"></span>
          </div>
        </div>
        <div class="column align-center">
          <div ng-class="uiSetMoveClasses(&#39;paper&#39;, 2)" ng-click="uiPlay(&#39;paper&#39;)">
            <span class="fa fa-hand-paper-o fa-fw fa-2x"></span>
          </div>
        </div>
        <div class="column align-center">
          <div ng-class="uiSetMoveClasses(&#39;scissors&#39;, 3)" ng-click="uiPlay(&#39;scissors&#39;)">
            <span class="fa fa-hand-scissors-o fa-fw fa-2x"></span>
          </div>
        </div>
      </div>
      <footer class="row around">
        <div>
          <span>Me</span>
          <h1>{{score.me}}</h1>
        </div>
        <div>
          <span>Spock</span>
          <h1>{{score.spock}}</h1>
        </div>
      </footer>
    </article>
    <div class="message-wrap content {{answered}}" ng-class="{&#39;show&#39;: answered}">
      <div class="message row align-center" ng-click="uiPlayAgain()" ng-class="{&#39;bg-warning&#39;: spocked, &#39;bg-info&#39;: winner===&#39;tie&#39;,&#39;bg-success&#39;: winner==&#39;me&#39;,&#39;bg-alert&#39;: winner==&#39;spock&#39;}">
        <div>{{message}}</div>
        <div class="chip beacon-1">
          <span class="fa fa-3x fa-refresh"></span>
        </div>
      </div>
    </div>
  </main>
         <script src=&#39;https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js&#39;></script>
         <script src=&#39;https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js&#39;></script>
         <script src="js/main.js"></script>
</body>
</html>
Salin selepas log masuk


相信看了这些案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

相关阅读:

用Js操作HTTP的Cookie的实现步骤

关于本地的Web-storage存储的详细介绍

网页布局的时候先写HTML还是先写CSS

Atas ialah kandungan terperinci html5做剪刀石头布效果的教程. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan