[Pal-devel] Re: pal question (problem ?)

Tomi Neste flatlander at yellow-hut.com
Fri Jul 20 13:12:56 UTC 2007


Nicolas Lamirault <lam at tuxfamily.org> kirjoitti Fri, 20 Jul 2007 15:22:40  
+0300:

>
> thanks for your help.
> i make another game : http://www.cliki.net/Cletris
> using PAL
>
> thans for your very nice software.
>
>
> "Tomi Neste" <flatlander at yellow-hut.com> writes:
>
>> Nicolas Lamirault <lam at perave.org> kirjoitti Wed, 11 Jul 2007 19:07:32
>> +0300:
>>
>>>
>>> hi,
>>> i try your PAL library. It seems very useful. So i try to start use it
>>> with a Simon like game.
>>> first tests are concluants.
>>> But i've got a problem to load several image in a loop :
>>>
>>> (defun play-sequence ()
>>>   "Draw the current color, and play the associated sound."
>>>   (loop for color in *random*
>>>      do
>>>        (when *debug*
>>>          (format t "~&Play ~A~%" color))
>>>        (set-simon color)
>>>        (draw *simon*)
>>>        (play-music (load-music *sound*) nil 255)
>>>        (sleep (/ 1 2))
>>>        (set-simon :base)
>>>        (draw *simon*)))
>>>
>>>
>>> this function read *random* list and for each color draw the available
>>> image :
>>>
>>> (defmethod draw ((s simon))
>>>   (when *debug*
>>>     (format t "~&Draw ~A : ~A" *simon* (simon-image s)))
>>>   (draw-image (simon-image s) (v 0 0)))
>>>
>>>
>>> set-simon update some internal variables.
>>>
>>> i've a test :
>>>
>>> (defun climon-test ()
>>>   (with-pal (:width +width+ :height +height+ :fullscreenp nil
>>>                     :paths   (concatenate  'string  *climon-directory*
>>>   "font/"))
>>>     (initialize-simon)
>>>     (draw *simon*)
>>>     (setf *random* '(:blue :yellow :red :blue :green :blue :green
>>>                      :red :red :blue :red))
>>>     (event-loop ()
>>>       (test-keys
>>>         (:key-space (play-sequence))
>>>         (:key-q (return-from event-loop))))))
>>>
>>> each  object (simon-{color})  contains  the same  image  but with  the
>>> specified color with a nice light.
>>>
>>> when we do the test, it seems  that all the images are drawing. But in
>>> real, i don't see images with specified colors. Sounds are ok
>>>
>>> any idea of my problems .
>>>
>>> i send you with this mail  my code. Graphics and sound are stolen from
>>> memotux (Simon in OCaml).
>>>
>>> thanks for any help
>>>
>>>
>>
>> Nice little game you got there! I'm surprised you got that far with
>> the current PAL documentation being what it is... ;)
>> It looks like your problem is in the play-sequence function, the
>> following should work:
>>
>> (defun play-sequence ()
>>   "Draw the current color, and play the associated sound."
>>   (loop for color in *random*
>>      do
>>      (when *debug*
>>        (format t "~&Play ~A~%" color))
>>      (set-simon color)
>>      (draw *simon*)
>>      (pal::update-screen) ;; update the screen!
>>      (play-music (load-music *sound*) nil 255)
>>      (sleep (/ 1 2))
>>      (set-simon :base)
>>      (draw *simon*)))
>>
>> By default PAL updates the screen only once for each iteration of
>> EVENT-LOOP so you need to do it manually. Since PAL::UPDATE-SCREEN is
>> useful in these kinds of situations I'll change it into an exported
>> symbol  in the PAL package.
>>
>> Hope this helps, if you still have problems/questions feel free to ask.
>>
>>
>

Great, nice that you like it :)

-- 
tomppa



More information about the pal-devel mailing list