name: "Main Area" panels { name: "FRUIT" path: "Panels/Room_1/panel_2" clue: "fruit" answer: "peach" symbols: EXAMPLE } panels { name: "FLOWER" path: "Panels/Room_1/panel_3" clue: "flower" answer: "rose" symbols: EXAMPLE } panels { name: "GEM" path: "Panels/Room_1/panel_4" clue: "gem" answer: "jade" symbols: EXAMPLE } panels { name: "DAIRY" path: "Panels/Room_1/panel_5" clue: "dairy" answer: "cream" symbols: EXAMPLE } panels { name: "TREE" path: "Panels/Room_1/panel_6" clue: "tree" answer: "walnut" symbols: EXAMPLE } panels { name: "METAL" path: "Panels/Room_1/panel_7" clue: "metal" answer: "silver" symbols: EXAMPLE } panels { name: "CLOTHES" path: "Panels/Room_1/panel_8" clue: "clothes" answer: "denim" symbols: EXAMPLE } panels { name: "SPICE" path: "Panels/Room_1/panel_9" clue: "spice" answer: "sage" symbols: EXAMPLE } ports { name: "ENTRY" path: "Components/Warps/worldport" } lue='switch'/> Five platformers in one
summary refs log blame commit diff stats
path: root/src/vector.h
blob: 3abd98a0ff36332d97e2f29e3ea2dc7d63a3130f (plain) (tree)














































































































                                                         
#ifndef COORDINATES_H_A45D34FB
#define COORDINATES_H_A45D34FB

template <typename T>
class vec2 {
public:

  T coords[2];

  vec2() = default;

  vec2(double x, double y) : coords{x, y}
  {
  }

  inline T& x()
  {
    return coords[0];
  }

  inline const T& x() const
  {
    return coords[0];
  }

  inline T& w()
  {
    return coords[0];
  }

  inline const T& w() const
  {
    return coords[0];
  }

  inline T& y()
  {
    return coords[1];
  }

  inline const T& y() const
  {
    return coords[1];
  }

  inline T& h()
  {
    return coords[1];
  }

  inline const T& h() const
  {
    return coords[1];
  }

  template <typename R>
  operator vec2<R>() const
  {
    return vec2<R>(x(), y());
  }

  vec2 operator+(const vec2& other) const
  {
    return vec2(x() + other.x(), y() + other.y());
  }

  vec2& operator+=(const vec2& other)
  {
    x() += other.x();
    y() += other.y();

    return *this;
  }

  vec2 operator-(const vec2& other) const
  {
    return vec2(x() - other.x(), y() - other.y());
  }

  vec2 operator-=(const vec2& other)
  {
    x() -= other.x();
    y() -= other.y();

    return *this;
  }

  vec2 operator-() const
  {
    return vec2(-x(), -y());
  }

  vec2 operator*(double s) const
  {
    return vec2(x() * s, y() * s);
  }

  vec2& operator*=(double s)
  {
    x() *= s;
    y() *= s;

    return *this;
  }

};

using vec2d = vec2<double>;
using vec2i = vec2<int>;

#endif /* end of include guard: COORDINATES_H_A45D34FB */