;;;; Ru*** roLeplay Playground virtual tabletop ;;;; Copyright (C) 2022 Zull ;;;; ;;;; This program 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. ;;;; ;;;; This program 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 this program. If not, see . (in-package :rulp.layers) (defgeneric bounce (v p) (:documentation "Given a point v and a plane p this generic check if the point collide with some wall or it is out of bound and return t when it is, nil otherwise")) (defun lex< (a b) "lexycal-graphical orders between a and b, returns t if a < b, otherwise returns nil" (declare (list a b) (optimize (speed 3))) (if (eql (car a) (car b)) (< (cdr a) (cdr b)) (< (car a) (car B)))) (defclass plane (displayable) ((collision-list :accessor collision-list :initarg :collision-list :initform nil :type list :documentation "an ordered list of collision, use when entities do stuff") (entities-list :accessor entities-list :initarg :entities-list :initform nil :type list :documentation "the entities contained into the plane") ;; (width :accessor width ;; :initarg :width ;; :initform 0 ;; :type number ;; :documentation "the width of the plane, when 0 or negative it uses the texture width") ;; (height :accessor height ;; :initarg :height ;; :initform 0 ;; :type number ;; :documentation "the height of the plane, when 0 or negative it uses the texture height") (background :accessor background :initarg :background :initform "" :type string :documentation "the path for the construction, that can be a image or something else") (grid :accessor plane-grid :initarg :grid) (span :accessor grid-dimension :initarg :grid-dimension :documentation "the dimension of the standard grid, this will be replaced with a function" :initform 70))) ;; grid logic, to be placed in the correct package (and file (defmethod bounce (v (p plane)) "rapidly check if the given point is in the collision list" (member v (collision-list p))) ;; the name is intended to be temporary ;; BUG: this method is (somehow) being replaced by the entity version. (defmethod display ((p plane) (grid t)) (declare (ignore grid)) (render (get-screen (background p)) 0 0 (w p) (h p))) (defmethod w ((obj plane)) (if (= (car (slot-value obj 'size)) 0) (w (get-screen (background obj))) (car (slot-value obj 'size)))) (defmethod h ((obj plane)) (if (= (cdr (slot-value obj 'size)) 0) (h (get-screen (background obj))) (car (slot-value obj 'size)))) ;; temporary, they are used somewhere on view for the evenience the ;; plane was moved (now the plane doesn't consider coordinates) (defmethod x ((obj plane)) 0) (defmethod y ((obj plane)) 0)