From f05c988b537fbbf9d232b035e6103a9983d5d5cb Mon Sep 17 00:00:00 2001 From: David Botton Date: Thu, 7 Jan 2021 22:03:04 -0500 Subject: [PATCH] Added further tasking demo --- tutorial/07-tutorial.lisp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tutorial/07-tutorial.lisp b/tutorial/07-tutorial.lisp index 91ca0bc..3238d85 100644 --- a/tutorial/07-tutorial.lisp +++ b/tutorial/07-tutorial.lisp @@ -18,7 +18,7 @@ (create-child body "

KILL Darth's Tie Fighter - Click on it!

") (sleep 2))) t) - (let* ((mover (create-child body "
(-o-)
")) + (let* ((mover (create-div body :content "(-o-)")) bounds-x bounds-y mover-x mover-y) (flet ((set-bounds () @@ -35,6 +35,20 @@ (setf (positioning mover) :fixed) (set-on-click mover #'on-click) + + (bordeaux-threads:make-thread ; In addtion to the main task (the on-new-window) + (lambda () ; and the task created for each event like clicks + (loop ; threads can be created as needed. + (unless (validp body) + (return)) + (when (connection-data-item body "done") + (return)) + + (sleep .5) + (setf (text mover) ")-o-(") + (sleep .2) + (setf (text mover) "(-o-)")) + (setf (inner-html mover) "

GAME OVER

"))) (loop (unless (validp body) @@ -62,8 +76,7 @@ (when (> mover-y bounds-y) (setf mover-y bounds-y)) - (sleep .02))) - (format t "GAME OVER")) + (sleep .02)))) (error (c) (format t "Lost connection.~%~%~A" c))))