Works again.
[uxul-world.git] / draw.lisp
1 ;;; Copyright 2009-2011 Christoph Senjak
2
3 ;; various draw-methods
4
5 (in-package :uxul-world)
6
7 (defun draw-background (x-trans y-trans)
8   ;; (let ((ani3 (car (images (make-animation 0 |background_test_layer_3|))))
9 ;;      (ani2 (car (images (make-animation 0 |background_test_layer_2|)))))
10
11 ;;     (loop for i from -1 to 16
12 ;;       do (loop for j from -1 to 12
13 ;;               do (progn
14 ;;                    (sdl:draw-surface-at-* ani2
15 ;;                                           (+ (* i 64) (round
16 ;;                                                        (mod (/ x-trans 4) 64)))
17 ;;                                           (+ (* j 64) (round
18 ;;                                                        (mod (/ y-trans 4) 64)))))))
19 ;;     (loop for i from -1 to 16
20 ;;       do (loop for j from -1 to 12
21 ;;               do 
22 ;;               (sdl:draw-surface-at-* ani3
23 ;;                                           (+ (* 64 i) (round
24 ;;                                                        (mod (/ x-trans 2) 64)))
25 ;;                                           (+ (* 64 j) (round
26 ;;                                                        (mod (/ y-trans 2) 64)))))))
27   )
28
29 (defmethod draw ((obj room))
30   (let ((*current-translation-x*
31          (* (- +screen-width+ (x (graphic-centralizer obj)))))
32         (*current-translation-y*
33          (* (- +screen-height+ (y (graphic-centralizer obj))))))
34     (draw-background *current-translation-x* *current-translation-y*)
35     (gl:scale *zoomx* (- *zoomy*) 1)
36     (gl:translate *current-translation-x* *current-translation-y* 0)
37     (dolist (image (get-objects obj 'uxul-world::game-object))
38       (and (redraw image) (visible image) (draw image)))))
39
40
41 ;; FIXME
42
43 (defvar *player-bar-color* -255)
44
45 (defmethod draw ((obj player))
46   #+nil(if (rectangle-in-screen obj)
47            (old-draw-rectangle obj :r 255 :g 255 :b 255))
48
49   ;;; FIXME ************
50   ;; (sdl:draw-box-*
51   ;;  10 10 (floor (* (power obj) (/ (- +screen-width+ 20) 10))) 10
52   ;;  :color (sdl:color :r (abs *player-bar-color*) :g (abs *player-bar-color*) :b (abs *player-bar-color*)))
53   (incf *player-bar-color* 5)
54   (if (= *player-bar-color* 255) (setf *player-bar-color* -255))
55
56   (call-next-method))
57
58 (defmethod draw ((obj stone)) (call-next-method))
59
60 (defmethod draw ((obj simple-enemy)) (call-next-method))