;;;; You should have received a copy of the GNU General Public License
;;;; along with this program. If not, see <https://www.gnu.org/licenses/>.
-(in-package :layers)
+(in-package :rulp.layers)
;; This is the most generic class in the program with model, this class define
;; objects to be displayed on screen, whenever they are entities, planes text
;; or icons.
:accessor surface)
(path :accessor image-path
:initarg :image
- :initform (merge-pathnames parameters:*rulp-share* "test.png"))
+ :initform (merge-pathnames rulp.parameters:*rulp-share* "test.png"))
(s-rect :initform nil
:documentation "this value contains the source rectangle to be used, don't
interact directly with this but use screen-source instead")
(defmethod (setf height) (value (s screen))
(setf (cdr (slot-value s 'size)) value))
+;; FIXME: entities use size as a simple integer, change to make it work better
(defmethod initialize-instance :after ((s screen) &rest args)
- (setf (surface s) (sdl2-image:load-image (slot-value s 'path))))
+ (declare (ignore args))
+ (setf (surface s) (sdl2-image:load-image (slot-value s 'path)))
+ (setf (width s) (sdl2:surface-width (surface s))
+ (height s) (sdl2:surface-height (surface s)))
+ (setf (slot-value s 's-rect) (sdl2:make-rect 0 0 (width s) (height s))))
(defmethod screen-source ((s screen))
"return the source rectangle, the portion of texture to display (standard all)"
- nil)
+ (slot-value s 's-rect))
;; FIXME: save and use the make-rect. destroy and create a new one when
;; info don't match
(sdl2:make-rect (x s) (y s) (width s) (height s))
)
-(defmethod screen-purge ((s screen))
+(defun screen-purge (screen)
"purge screens video data. This data is automatically generated during rendering"
(sdl2:destroy-texture (texture s))
- (sdl2:free-surface (surface s)))
+ (when (surface s)
+ (sdl2:free-surface (surface s))))