;; This file is part of Menace of the Mines.
;; Menace of the Mines is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; Menace of the Mines is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with Menace of the Mines in the file COPYING. If not, see <http://www.gnu.org/licenses/>.
(in-package :motm)
(define-symbol-macro *level* (level *dungeon*))
(defmethod terrain (x y)
(aref (terrains *level*) x y))
(defmethod (setf terrain) (value x y)
(setf (aref (terrains *level*) x y) value))
(defmethod top (x y)
(or (terrain x y)))
(defmethod (setf top) (value x y)
(setf (terrain x y) value))
(defgeneric mov (x1 y1 x2 y2 what))
(defmethod mov (x1 y1 x2 y2 (what (eql 'terrain)))
(rotatef (terrain x1 y1) (terrain x2 y2)))
(defmethod draw ((what level))
(werase (window :game))
(loop for y from 0 to 22 do
(loop for x from 0 to 59 do
(funcall (draw (top x y))))
(printf :game "~%"))
(wmove (window :game) (player-y) (player-x)))
(defmethod movep (x y)
(if (and (>= x 0) (<= x 59) (>= y 0) (<= y 22)) (values (_movep (terrain x y)) t) (values nil nil)))