Major Changes. Windows Compatibility.
authorU-christoph-TP\christoph <christoph@christoph-TP.(none)>
Wed, 7 Jul 2010 21:45:25 +0000 (23:45 +0200)
committerU-christoph-TP\christoph <christoph@christoph-TP.(none)>
Wed, 7 Jul 2010 21:45:25 +0000 (23:45 +0200)
58 files changed:
BUGS [changed mode: 0644->0755]
Makefile [changed mode: 0644->0755]
README [changed mode: 0644->0755]
anchor.png [changed mode: 0644->0755]
animation.lisp
background_test_layer_1.png [changed mode: 0644->0755]
background_test_layer_2.png [changed mode: 0644->0755]
background_test_layer_3.png [changed mode: 0644->0755]
blue_nasobem.png [changed mode: 0644->0755]
blue_nasobem2.png [changed mode: 0644->0755]
blue_nasobem3.png [changed mode: 0644->0755]
boomerang1.png [changed mode: 0644->0755]
boomerang2.png [changed mode: 0644->0755]
boomerang3.png [changed mode: 0644->0755]
boomerang4.png [changed mode: 0644->0755]
boomerang5.png [changed mode: 0644->0755]
boomerang6.png [changed mode: 0644->0755]
boomerang7.png [changed mode: 0644->0755]
boomerang8.png [changed mode: 0644->0755]
brown_stone.png [changed mode: 0644->0755]
burning-marshmallow.lisp [changed mode: 0644->0755]
burning_marshmallow_ld1.png [changed mode: 0644->0755]
burning_marshmallow_ld2.png [changed mode: 0644->0755]
burning_marshmallow_lu1.png [changed mode: 0644->0755]
burning_marshmallow_lu2.png [changed mode: 0644->0755]
burning_marshmallow_rd1.png [changed mode: 0644->0755]
burning_marshmallow_rd2.png [changed mode: 0644->0755]
burning_marshmallow_ru1.png [changed mode: 0644->0755]
burning_marshmallow_ru2.png [changed mode: 0644->0755]
coral.png [new file with mode: 0755]
door.png [changed mode: 0644->0755]
draw.lisp
empty.png [changed mode: 0644->0755]
files.lisp
fireball1.png [new file with mode: 0755]
fireball2.png [new file with mode: 0755]
flying-nasobem.lisp [changed mode: 0644->0755]
functions.lisp
game-object-with-animation.lisp
game.lisp
grass_colored.png [changed mode: 0644->0755]
gray_stone.png [changed mode: 0644->0755]
imagemagick.lisp [new file with mode: 0755]
key.png [changed mode: 0644->0755]
leaf.png [changed mode: 0644->0755]
leveleditor.lisp [changed mode: 0644->0755]
nasobem2.png [changed mode: 0644->0755]
nasobem3.png [changed mode: 0644->0755]
teleporter.png [changed mode: 0644->0755]
trampoline1.png [new file with mode: 0755]
trampoline2.png [new file with mode: 0755]
tulip2.png [changed mode: 0644->0755]
tulip3.png [changed mode: 0644->0755]
uxul-world-leveleditor.asd [changed mode: 0644->0755]
uxul-world-leveleditor.lisp [changed mode: 0644->0755]
uxul-world.asd
uxul1shoot_small.png [changed mode: 0644->0755]
uxul2shoot_small.png [changed mode: 0644->0755]

diff --git a/BUGS b/BUGS
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/README b/README
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index 20fce5b..c64a20a 100755 (executable)
@@ -4,6 +4,9 @@
 
 (in-package :uxul-world)
 
+(defparameter *zoom-ash* -1)
+(defmacro zoom-trans (x) `(ash ,x *zoom-ash*))
+
 (defparameter *graphics-table* nil)
 
 ;; the functions may assume that the contents of a graphics-file -
 ;; graphics with an equivalent path any time you load an image.
 
 (defclass animation (xy-coordinates)
-  ((images :initarg :images
-                    :initform (make-array (list 0) :element-type 'sdl:surface)
-                    :accessor images
-;                   :type (simple-array 'sdl:surface (*))
-                    :documentation "Array with the images")
+  (
+;;   (images :initarg :images
+;;                  :initform (make-array (list 0) :element-type 'sdl:surface)
+;;                  :accessor images
+;; ;                :type (simple-array 'sdl:surface (*))
+;;                  :documentation "Array with the images")
+   (images-2x :initarg :images-2x
+             :initform (make-array (list 0) :element-type 'sdl:surface)
+             :accessor images-2x
+             :documentation "Array of double-sized images")
+   (images-1x :initarg :images-1x
+             :initform (make-array (list 0) :element-type 'sdl:surface)
+             :accessor images-1x
+             :documentation "Array of normal-sized images")
+   (images-.5x :initarg :images-.5x
+              :initform (make-array (list 0) :element-type 'sdl:surface)
+              :accessor images-.5x
+              :documentation "Array of half-sized images")
+   (images-.25x :initarg :images-.25x
+               :initform (make-array (list 0) :element-type 'sdl:surface)
+               :accessor images-.25x
+               :documentation "Array of quarter-sized images")       
    (sprite-image-number :initform 0
                        :initarg :sprite-image-number
                        :accessor sprite-image-number
@@ -55,6 +75,18 @@ will be used to minimize the number of file-accesses for loading
 animations. For any animation created from a file by the api from
 below, this will refer to an animation in the *graphics-table*." )))
 
+(defmethod images ((obj animation))
+  (cond
+    ((= *zoom-ash* 0)
+     (images-2x obj))
+    ((= *zoom-ash* -1)
+     (images-1x obj))
+    ((= *zoom-ash* -2)
+     (images-.5x obj))
+    ((= *zoom-ash* -3)
+     (images-.25x obj))))
+
+
 (defmethod draw ((obj animation))
   (when (not (<= (sprite-delay obj) 0)) ;<=, because -a means "paused,
                                        ;but a is the delay when
@@ -66,8 +98,8 @@ below, this will refer to an animation in the *graphics-table*." )))
       (setf (sprite-image-number obj) (mod (+ 1 (sprite-image-number obj)) (length (images obj))))))
   (when (visible obj)
     (sdl:draw-surface-at-* (elt (images obj) (sprite-image-number obj))
-                          (+ *current-translation-x* (round (x obj)))
-                          (+ *current-translation-y* (round (y obj))))))
+                          (zoom-trans (+ *current-translation-x* (round (x obj))))
+                          (zoom-trans (+ *current-translation-y* (round (y obj)))))))
 
 ;additional methods to make life easier
 (defmethod pause ((obj animation))
@@ -112,10 +144,28 @@ reference, if the current filename already exists."
   "Create an animation from the list of animation-names given in the
 images-variable."
   (make-instance 'animation
-                :images (mapcar
-                         #'(lambda (x)
-                             (sdl:convert-surface :surface (sdl-image:load-image
-                              x
-                              :image-type :PNG :alpha 1 )))
-                                image-list)
+                :images-2x (mapcar
+                            #'(lambda (x)
+                                (sdl:convert-surface :surface (sdl-image:load-image
+                                                               (car x)
+                                                               :image-type :PNG :alpha 1 )))
+                            image-list)
+                :images-1x (mapcar
+                            #'(lambda (x)
+                                (sdl:convert-surface :surface (sdl-image:load-image
+                                                               (cadr x)
+                                                               :image-type :PNG :alpha 1 )))
+                            image-list)
+                :images-.5x (mapcar
+                            #'(lambda (x)
+                                (sdl:convert-surface :surface (sdl-image:load-image
+                                                               (caddr x)
+                                                               :image-type :PNG :alpha 1 )))
+                            image-list)
+                :images-.25x (mapcar
+                            #'(lambda (x)
+                                (sdl:convert-surface :surface (sdl-image:load-image
+                                                               (cadddr x)
+                                                               :image-type :PNG :alpha 1 )))
+                            image-list)
                 :sprite-delay frame-skip))
\ No newline at end of file
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/coral.png b/coral.png
new file mode 100755 (executable)
index 0000000..294d63f
Binary files /dev/null and b/coral.png differ
old mode 100644 (file)
new mode 100755 (executable)
index 1b058e6..82a32c9 100755 (executable)
--- a/draw.lisp
+++ b/draw.lisp
@@ -5,25 +5,26 @@
 (in-package :uxul-world)
 
 (defun draw-background (x-trans y-trans)
-  (let ((ani3 (car (images (make-animation 0 |background_test_layer_3|))))
-       (ani2 (car (images (make-animation 0 |background_test_layer_2|)))))
+  ;; (let ((ani3 (car (images (make-animation 0 |background_test_layer_3|))))
+;;     (ani2 (car (images (make-animation 0 |background_test_layer_2|)))))
 
-    (loop for i from -1 to 16
-        do (loop for j from -1 to 12
-                do (progn
-                     (sdl:draw-surface-at-* ani2
-                                            (+ (* i 64) (round
-                                                         (mod (/ x-trans 4) 64)))
-                                            (+ (* j 64) (round
-                                                         (mod (/ y-trans 4) 64)))))))
-    (loop for i from -1 to 16
-        do (loop for j from -1 to 12
-                do 
-                (sdl:draw-surface-at-* ani3
-                                            (+ (* 64 i) (round
-                                                         (mod (/ x-trans 2) 64)))
-                                            (+ (* 64 j) (round
-                                                         (mod (/ y-trans 2) 64))))))))
+;;     (loop for i from -1 to 16
+;;      do (loop for j from -1 to 12
+;;              do (progn
+;;                   (sdl:draw-surface-at-* ani2
+;;                                          (+ (* i 64) (round
+;;                                                       (mod (/ x-trans 4) 64)))
+;;                                          (+ (* j 64) (round
+;;                                                       (mod (/ y-trans 4) 64)))))))
+;;     (loop for i from -1 to 16
+;;      do (loop for j from -1 to 12
+;;              do 
+;;              (sdl:draw-surface-at-* ani3
+;;                                          (+ (* 64 i) (round
+;;                                                       (mod (/ x-trans 2) 64)))
+;;                                          (+ (* 64 j) (round
+;;                                                       (mod (/ y-trans 2) 64)))))))
+  )
 
 (defmethod draw ((obj room))
   (let ((*current-translation-x*
@@ -33,7 +34,7 @@
            (- 800 (width obj)))
           (T
            (- 400 (x (graphic-centralizer obj)))))|#
-        (- 400 (x (graphic-centralizer obj)))
+        (- (ash 400 (- *zoom-ash*)) (x (graphic-centralizer obj)))
          )
        (*current-translation-y*
         #|(cond
@@ -42,7 +43,7 @@
            (- 600 (height obj)))
           (T
            (- 300 (y (graphic-centralizer obj)))))|#
-        (- 300 (y (graphic-centralizer obj)))
+        (- (ash 300 (- *zoom-ash*)) (y (graphic-centralizer obj)))
          ))
     (draw-background *current-translation-x* *current-translation-y*)
     (dolist (image (get-objects obj 'uxul-world::game-object))
old mode 100644 (file)
new mode 100755 (executable)
index e8e50db..65918ae 100755 (executable)
@@ -8,27 +8,73 @@
 (defun si (var val)
   (setf (symbol-value (intern var)) val))
 
-(defun init-file (file)
-  "Load a file into a Variable. Access with |filename| (without .png
-and path)."
-  (si (pathname-name file)
-      (with-open-file (in file :element-type '(unsigned-byte 8)) 
-       (let* ((length (file-length in))
-              (content (make-array (list length)
-                                   :element-type '(unsigned-byte 8)
-                                   :adjustable nil)))
-         (read-sequence content in)
-         content))))
-
-(defun file-relevant-p (file)
+
+(defun stretch-image (x y img)
+  "Call ImageMagick to resize that file to 64x64."
+  (lisp-magick:with-magick-wand (mywand)
+    (lisp-magick::magick-read-image-blob mywand img)
+    (lisp-magick::magick-resize-image mywand x y #x00000000 1d0)
+    (lisp-magick::magick-set-format mywand "png")
+    (lisp-magick::magick-get-image-blob mywand)))
+
+(defun ash-sized-image (img a)
+  "Calculate an image of half of the size."
+  (lisp-magick:with-magick-wand (mywand)
+    (lisp-magick::magick-read-image-blob mywand img)
+    (let
+       ((w (lisp-magick::magick-get-image-width mywand))
+        (h (lisp-magick::magick-get-image-height mywand)))
+      (lisp-magick::magick-resize-image mywand
+                                       (max 1 (floor (/ w a))) (max 1 (floor (/ h a))) ;; no ash here ...
+                                       #x00000000 1d0)
+      (lisp-magick::magick-set-format mywand "png")
+      (lisp-magick::magick-get-image-blob mywand))))
+
+(defun all-sizes (img)
+  (list img
+       (ash-sized-image img 2)
+       (ash-sized-image img 4)
+       (ash-sized-image img 8)))
+
+
+;; (defun init-file (file)
+;;   "Load a file into a Variable. Access with |filename| (without .png
+;; and path)."
+;;   (si (pathname-name file)
+;;       (stretched-image 
+;;       (with-open-file (in file :element-type '(unsigned-byte 8)) 
+;;     (let* ((length (file-length in))
+;;            (content (make-array (list length)
+;;                                 :element-type '(unsigned-byte 8)
+;;                                 :adjustable nil)))
+;;       (read-sequence content in)
+;;       content)))))
+
+(defun init-png-file (file)
+  "Load an image file into a Variable. Set |filename| (without .png
+and path) to a list with all sizes of that image."
+  (si (pathname-name file) 
+      (all-sizes
+       (with-open-file (in file :element-type '(unsigned-byte 8)) 
+        (let* ((length (file-length in))
+               (content (make-array (list length)
+                                    :element-type '(unsigned-byte 8)
+                                    :adjustable nil)))
+          (read-sequence content in)
+          content)))))
+
+(defun png-p (file)
   "Is the file relevant for initialization? So far only .png-files are
 relevant."
   (string= (pathname-type file) "png"))
 
-(defun init-files ()
-  "Load the relevant files into variables"
+(defun init-png-files ()
   (cl-fad:walk-directory
    (asdf:component-pathname (asdf:find-system :uxul-world))
-   #'init-file :test #'file-relevant-p))
+   #'init-png-file :test #'png-p))
+
+(defun init-files ()
+  "Load the relevant files into variables"
+  (init-png-files))
 
 (init-files)
\ No newline at end of file
diff --git a/fireball1.png b/fireball1.png
new file mode 100755 (executable)
index 0000000..821075a
Binary files /dev/null and b/fireball1.png differ
diff --git a/fireball2.png b/fireball2.png
new file mode 100755 (executable)
index 0000000..d127bd0
Binary files /dev/null and b/fireball2.png differ
old mode 100644 (file)
new mode 100755 (executable)
index 2cbf8ca..aa71ef5 100755 (executable)
@@ -570,8 +570,9 @@ are not zero"
   
 
 (defun old-draw-rectangle (obj &key (r 0) (g 0) (b 0))
-  (sdl:draw-rectangle-* (+ *current-translation-x* (x obj))
-                       (+ *current-translation-y* (y obj))
-                       (width obj)
-                       (height obj)
+  (declare (type game-object obj))
+  (sdl:draw-rectangle-* (zoom-trans (+ *current-translation-x* (x obj)))
+                       (zoom-trans (+ *current-translation-y* (y obj)))
+                       (zoom-trans (width obj))
+                       (zoom-trans (height obj))
                        :color (sdl:color :r r :g g :b b)))
index 993e72e..f188e53 100755 (executable)
@@ -10,7 +10,8 @@
   ((animation-translation :initarg :animation-translation
                          :accessor animation-translation
                          :initform (make-xy 0 0)
-                         :documentation "The translation of the animation")
+                         :documentation "The translation of the
+                         animation (in double zoom).")
    (animation :initarg :animation
              :accessor animation
              :documentation "The animation of this object")
         (+ (y obj) (height obj) (y bounds))
         (- *current-translation-x*)
         (- *current-translation-y*)
-        (- +screen-width+ *current-translation-x*)
-        (- +screen-height+ *current-translation-y*))
-       T)))
+        (- (ash +screen-width+ (- *zoom-ash*)) *current-translation-x*)
+        (- (ash +screen-height+ (- *zoom-ash*)) *current-translation-y*))
+       T))
+)
 
 
 
index 5b98d6a..c026d4d 100755 (executable)
--- a/game.lisp
+++ b/game.lisp
@@ -17,6 +17,7 @@
   "Start the Game: Call room-function for getting the room-object to
 run. Music is ignored so far. 15-fps makes only every second frame be
 drawn (for very slow computers)"
+  (sdl:set-video-driver "directx")
      (sdl:with-init (sdl:sdl-init-video sdl:sdl-init-audio)
        (sdl:window +screen-width+ +screen-height+
                   :title-caption "Uxul World"
@@ -49,6 +50,12 @@ drawn (for very slow computers)"
                            (cond
                              ((sdl:key= key :SDL-KEY-ESCAPE)
                               (sdl:push-quit-event))
+                             ((sdl:key= key :SDL-KEY-O)
+                              (setf *zoom-ash*
+                                    (max -3 (1- *zoom-ash*))))
+                             ((sdl:key= key :SDL-KEY-I)
+                              (setf *zoom-ash*
+                                    (min 0 (1+ *zoom-ash*))))
                              (T
                               (on-key-down *current-room* key))))
           (:key-up-event (:key key)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/imagemagick.lisp b/imagemagick.lisp
new file mode 100755 (executable)
index 0000000..51b0e13
--- /dev/null
@@ -0,0 +1,36 @@
+;; Copyright 2010 Christoph Senjak\r
+\r
+(in-package :uxul-world)\r
+\r
+;; "Binding" for the "convert"-Program\r
+\r
+(defparameter *convert* #P"C:\\Program Files (x86)\\ImageMagick-6.6.2-Q16\\convert.exe")\r
+\r
+(defun run-convert (arguments in)\r
+  "Return output of convert"\r
+  (let* ((p (sb-ext:run-program *convert* arguments\r
+                                     :wait nil\r
+                                     :input :stream\r
+                                     :output :stream))\r
+        (pin (sb-ext:process-input p))\r
+        (pou (sb-ext:process-output p))\r
+        (ret '()))\r
+    (loop for byte across in do\r
+        (progn\r
+          (format t "doing~%")\r
+          (write-byte byte pin)\r
+          (loop while (listen pou) do\r
+               ;; this read should never fail and never be eof\r
+               (format t "reading 1~%")\r
+               (push (read-byte pou) ret))))\r
+    (format t "finishing out, closing~%")\r
+    (finish-output pin)\r
+    (close pin)\r
+    (let ((c 0))\r
+      (loop while (setf c (read-byte pou nil nil)) do\r
+          (format t "reading 2~%")\r
+          (push c ret)))\r
+    ret))\r
+\r
+(defun resize-image (bytes x y)\r
+  (run-convert (list "-scale" (format nil "~dx~d" x y) "-" "-") bytes))
\ No newline at end of file
diff --git a/key.png b/key.png
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
diff --git a/trampoline1.png b/trampoline1.png
new file mode 100755 (executable)
index 0000000..c103fcd
Binary files /dev/null and b/trampoline1.png differ
diff --git a/trampoline2.png b/trampoline2.png
new file mode 100755 (executable)
index 0000000..3ab30bd
Binary files /dev/null and b/trampoline2.png differ
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)
index b11d187..47b03e9 100755 (executable)
@@ -7,7 +7,8 @@
   :version "No Release Yet"
   :author "Christoph Senjak <firstName.secondName at googlemail.com>"
   :license "Copyright 2009 Christoph Senjak."
-  :depends-on (#:lispbuilder-sdl #:closer-mop
+  :depends-on (#:lispbuilder-sdl #:lisp-magick
+                                #:closer-mop
                                 #:cl-fad
                                  #:lispbuilder-sdl-image)
   :components ((:file "uxul-world")
old mode 100644 (file)
new mode 100755 (executable)
old mode 100644 (file)
new mode 100755 (executable)