8725 sujets

Développement web côté serveur, CMS

bonjour je suis en train de développer un mod trex-runner-chrome et je n'arrive pas a créer une variable qui peut être modifiée avec un bouton ( +1 ) et un bouton ( -1 ) voici le code si quelqu'un voudrait bien m'aider

      <div id="bouton-plus">
        <button onclick="" class="btn btn-plus">+1</a>
      </div>
      <div id="bouton-moins">
        <button onclick="" class="btn btn-moins">-1</a>
      </div>
    </body>
    <meta name="description" content="Ripped T-Rex/Dino game of Chromium">
    <meta property="og:title" content="Play the hidden T-Rex Dinosaur game of Chromium .">
    <meta property="og:type" content="article">
    <meta property="og:url" content="http://www.thecodepost.org">
    <meta property="og:image" content="http://img.thecodepost.org/2015/01/trex.png">
    <meta property="og:site_name" content="The Code Post">
    <meta property="og:description" content="Google Chrome has a hidden T-Rex game only for offline mode. But now, you can enjoy it any time and on any device, but you gotta stay online!!!">
    
    <meta name="twitter:card" content="summary_large_image">
    <meta name="twitter:site" content="@thecodepost">
    <meta name="twitter:creator" content="@thecodepost">
    <meta name="twitter:title" content="Check out the cool hidden game from Google Chrome!">
    <meta name="twitter:description" content="Check out the cool hidden game from Google Chrome!">
    <meta name="twitter:image:src" content="http://img.thecodepost.org/2015/01/trex.png">
    <script src="https://apis.google.com/js/platform.js" async defer></script>
    
        <!--script type="text/javascript" src="a.js"></script-->
        <script type="text/javascript">
        function hideClass(name) {
           var myClasses = document.querySelectorAll(name),
          i = 0,
          l = myClasses.length;
    
          for (i; i < l; i++) {
            myClasses[i].style.display = 'none';
          }
        }
        // Copyright (c) 2014 The Chromium Authors. All rights reserved.
        // Use of this source code is governed by a BSD-style license that can be
        // found in the LICENSE file.
        (function() {
        'use strict';
        /**
        * T-Rex runner.
        * @param {string} outerContainerId Outer containing element id.
        * @param {object} opt_config
        * @constructor
        * @export
        */
        function Runner(outerContainerId, opt_config) {
        // Singleton
        if (Runner.instance_) {
        return Runner.instance_;
        }
        Runner.instance_ = this;
        this.outerContainerEl = document.querySelector(outerContainerId);
        this.containerEl = null;
        this.detailsButton = this.outerContainerEl.querySelector('#details-button');
        this.config = opt_config || Runner.config;
        this.dimensions = Runner.defaultDimensions;
        this.canvas = null;
        this.canvasCtx = null;
        this.tRex = null;
        this.distanceMeter = null;
        this.distanceRan = 0;
        this.highestScore = 0;
        this.time = 0;
        this.runningTime = 0;
        this.msPerFrame = 1000 / FPS;
        this.currentSpeed = this.config.SPEED;
        this.obstacles = [];
        this.started = false;
        this.activated = false;
        this.crashed = false;
        this.paused = false;
        this.resizeTimerId_ = null;
        this.playCount = 0;
        // Sound FX.
        this.audioBuffer = null;
        this.soundFx = {};
        // Global web audio context for playing sounds.
        this.audioContext = null;
        // Images.
        this.images = {};
        this.imagesLoaded = 0;
        this.loadImages();
        }
        window['Runner'] = Runner;
        /**
        * Default game width.
        * @const
        */
        var DEFAULT_WIDTH = 3000;
        /**
        * Frames per second.
        * @const
        */
        var FPS = 60;
        /** @const */
        var IS_HIDPI = window.devicePixelRatio > 1;
        /** @const */
        var IS_IOS =
        window.navigator.userAgent.indexOf('UIWebViewForStaticFileContent') > -1;
        /** @const */
        var IS_MOBILE = window.navigator.userAgent.indexOf('Mobi') > -1 || IS_IOS;
        /** @const */
        var IS_TOUCH_ENABLED = 'ontouchstart' in window;
        /**
        * Default game configuration.
        * @param {number} speedvar 
        */
        Runner.config = {
        ACCELERATION: 0.001,
        BG_CLOUD_SPEED: 0.2,
        BOTTOM_PAD: 10,
        CLEAR_TIME: 3000,
        CLOUD_FREQUENCY: 0.5,
        GAMEOVER_CLEAR_TIME: 750,
        GAP_COEFFICIENT: 0.6,
        GRAVITY: 0.6,
        INITIAL_JUMP_VELOCITY: 12,
        MAX_CLOUDS: 6,
        MAX_OBSTACLE_LENGTH: 3,
        MAX_SPEED: 12,
        MIN_JUMP_HEIGHT: 35,
        MOBILE_SPEED_COEFFICIENT: 1.2,
        RESOURCE_TEMPLATE_ID: 'audio-resources',
        SPEED: 6,
        SPEED_DROP_COEFFICIENT: 3
        };

Modifié par _laurent (01 Mar 2022 - 23:31)