title: How do I create a new class which both of my classes will inherit methods and properties from?
body: <p>I have two classes, one is called "Player", the other one is called "Enemy". They both have similar methods and properties and I want them to inherit from a parent class which I'll create and call "Game Object".</p>
  
  <p>How do I go about creating it? </p>
  
  <p>This code is written in Javascript, I've tried to research it myself but didn't manage to understand it very well.  </p>
  
  <pre><code>class Enemy
  {
      constructor(sprite, positionX, positionY, speed)
      {
          this.sprite = sprite;
          this.positionX = positionX;
          this.positionY = positionY;
          this.speed = speed;
          this.direction = Math.floor(Math.random()*7) + 1;
          this.direction *= Math.floor(Math.random()*2) == 1 ? 1 : -1;
          this.active = false;
      }
      getCenterPoint()
      {
          return new Point(this.positionX + 16, this.positionY + 16);
      }
  }
  
  class Player
  {
      constructor(sprite, positionX, positionY, speed)
      {
          this.sprite = sprite;
          this.positionX = positionX;
          this.positionY = positionY;
          this.speed = speed;
          this.animationFrame = true;
      }
          getCenterPoint()
      {
          return new Point(this.positionX + 16, this.positionY + 16);
      }
  }   
  </code></pre>
  
  <p>I couldn't manage to get the results that I wanted and need some guidance.</p>