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))
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 (span :accessor grid-dimension
59 :initarg :grid-dimension
60 :documentation "the dimension of the standard grid, this will be replaced with a function"
63 ;; grid logic, to be placed in the correct package (and file
64 (defmethod bounce (v (p plane))
65 "rapidly check if the given point is in the collision list"
66 (member v (collision-list p)))
68 ;; the name is intended to be temporary
69 (defmethod display ((p plane))
70 (render (get-screen (background p)) 0 0 (width p) (height p)))
72 (defmethod width ((s plane))
73 (if (= (slot-value s 'width) 0)
74 (width (get-screen (background s)))
75 (slot-value s 'width)))
77 (defmethod height ((s plane))
78 (if (= (slot-value s 'height) 0)
79 (height (get-screen (background s)))
80 (slot-value s 'height)))
82 ;; temporary, they are used somewhere on view for the evenience the
83 ;; plane was moved (now the plane doesn't consider coordinates)
84 (defmethod x ((s plane))
87 (defmethod y ((s plane))