1 ;;;; Ru*** roLeplay Playground virtual tabletop
2 ;;;; Copyright (C) 2022 Zull
4 ;;;; This program is free software: you can redistribute it and/or modify
5 ;;;; it under the terms of the GNU General Public License as published by
6 ;;;; the Free Software Foundation, either version 3 of the License, or
7 ;;;; (at your option) any later version.
9 ;;;; This program is distributed in the hope that it will be useful,
10 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ;;;; GNU General Public License for more details.
14 ;;;; You should have received a copy of the GNU General Public License
15 ;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
17 (in-package :rulp.layers)
19 (defgeneric bounce (v p)
20 (:documentation "Given a point v and a plane p this generic check if
21 the point collide with some wall or it is out of bound and return t
22 when it is, nil otherwise"))
25 "lexycal-graphical orders between a and b, returns t if a < b, otherwise returns nil"
28 (if (eql (car a) (car b))
32 (defclass plane (displayable)
33 ((collision-list :accessor collision-list
34 :initarg :collision-list
37 :documentation "an ordered list of collision, use when entities do stuff")
38 (entities-list :accessor entities-list
39 :initarg :entities-list
42 :documentation "the entities contained into the plane")
43 ;; (width :accessor width
47 ;; :documentation "the width of the plane, when 0 or negative it uses the texture width")
48 ;; (height :accessor height
52 ;; :documentation "the height of the plane, when 0 or negative it uses the texture height")
53 (background :accessor background
57 :documentation "the path for the construction, that can be a image or something else")
58 (grid :accessor plane-grid
60 (span :accessor grid-dimension
61 :initarg :grid-dimension
62 :documentation "the dimension of the standard grid, this will be replaced with a function"
65 ;; grid logic, to be placed in the correct package (and file
66 (defmethod bounce (v (p plane))
67 "rapidly check if the given point is in the collision list"
68 (member v (collision-list p)))
70 ;; the name is intended to be temporary
71 ;; BUG: this method is (somehow) being replaced by the entity version.
72 (defmethod display ((p plane) (grid t))
73 (declare (ignore grid))
74 (render (get-screen (background p)) 0 0 (w p) (h p)))
76 (defmethod w ((obj plane))
77 (if (= (car (slot-value obj 'size)) 0)
78 (w (get-screen (background obj)))
79 (car (slot-value obj 'size))))
81 (defmethod h ((obj plane))
82 (if (= (cdr (slot-value obj 'size)) 0)
83 (h (get-screen (background obj)))
84 (car (slot-value obj 'size))))
86 ;; temporary, they are used somewhere on view for the evenience the
87 ;; plane was moved (now the plane doesn't consider coordinates)
88 (defmethod x ((obj plane))
91 (defmethod y ((obj plane))