O'Reilly logo

HTML5 Game Development HOTSHOT by Makzan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the opponent's card

It is time to prepare for the battle. In this task, we will create the opponent's card.

Prepare for lift off

As usual, we will prepare the interface before adding logic to the game using the following steps:

  1. In the index.html file, append the following opponent's card object after our player's cards:
    <div class="card opponent out">
      <div class="front face">
        <div class="power">100</div>
      </div>
      <div class="back face">back</div>
    </div>
  2. The opponent's card is going in from the left side of the game scene. We define the style of placement and also the out and in classes for the JavaScript to toggle:
    .card.opponent {
      bottom: 250px;
    }
    .card.opponent.out {
      left: -200px;
    }
    .card.opponent.in {
      transition-delay:.8s;
      left: 40px;
    }

Engage ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required