File indexing completed on 2024-11-24 03:43:17

0001 /*******************************************************************
0002 *
0003 * Copyright 2007  Aron Boström <c02ab@efd.lth.se>
0004 *
0005 * Bovo is free software; you can redistribute it and/or modify
0006 * it under the terms of the GNU General Public License as published by
0007 * the Free Software Foundation; either version 2, or (at your option)
0008 * any later version.
0009 *
0010 * Bovo is distributed in the hope that it will be useful,
0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013 * GNU General Public License for more details.
0014 *
0015 * You should have received a copy of the GNU General Public License
0016 * along with Bovo; see the file COPYING.  If not, write to
0017 * the Free Software Foundation, 51 Franklin Street, Fifth Floor,
0018 * Boston, MA 02110-1301, USA.
0019 *
0020 ********************************************************************/                     
0021 
0022 #include "coord.h"
0023 
0024 /** @file file implementing class Coord */
0025 
0026 /** namespace for game engine */
0027 namespace bovo {
0028 
0029 Coord::Coord(usi x, usi y): m_x(x), m_y(y) {
0030 }
0031 
0032 Coord Coord::down() const {
0033     return Coord(m_x, m_y+1);
0034 }
0035 
0036 Coord Coord::left() const {
0037     return Coord(m_x-1, m_y);
0038 }
0039 
0040 bool Coord::null() const {
0041     return m_x == static_cast<usi>(-1) && m_y == static_cast<usi>(-1);
0042 }
0043 
0044 Coord Coord::right() const {
0045     return Coord(m_x+1, m_y);
0046 }
0047 
0048 Coord Coord::up() const {
0049     return Coord(m_x, m_y-1);
0050 }
0051 
0052 usi Coord::x() const {
0053     return m_x;
0054 }
0055 
0056 usi Coord::y() const {
0057     return m_y;
0058 }
0059 
0060 } /* namespace bovo */