Author: junrue Date: Thu Jun 8 17:35:25 2006 New Revision: 156
Modified: trunk/src/demos/unblocked/tiles.lisp trunk/src/demos/unblocked/unblocked-model.lisp trunk/src/uitoolkit/widgets/dialog.lisp Log: updated unblocked model code based on some loop style feedback; set a variable to create new random state when game starts
Modified: trunk/src/demos/unblocked/tiles.lisp ============================================================================== --- trunk/src/demos/unblocked/tiles.lisp (original) +++ trunk/src/demos/unblocked/tiles.lisp Thu Jun 8 17:35:25 2006 @@ -35,8 +35,13 @@
(defstruct tile (kind 0) (location (gfs:make-point)))
+(defvar *unblocked-random-state* nil) + (defun init-tiles (width height kinds) - (let* ((tiles (make-array width :initial-element nil))) + (if (null *unblocked-random-state*) + (setf *unblocked-random-state* (make-random-state))) + (let ((tiles (make-array width :initial-element nil)) + (*random-state* *unblocked-random-state*)) (dotimes (i width) (let ((column (make-array height :initial-element 0))) (setf (aref tiles i) column)
Modified: trunk/src/demos/unblocked/unblocked-model.lisp ============================================================================== --- trunk/src/demos/unblocked/unblocked-model.lisp (original) +++ trunk/src/demos/unblocked/unblocked-model.lisp Thu Jun 8 17:35:25 2006 @@ -43,11 +43,10 @@ collect (* 250 level level)))
(defun lookup-level-reached (score) - (let ((level 1)) - (loop for entry in *points-needed-table* - until (> entry score) - do (incf level)) - level)) + (loop for entry in *points-needed-table* + until (> entry score) + for level from 1 + finally (return level)))
(cells:defmodel unblocked-game-model () ((level @@ -69,9 +68,9 @@ +vert-tile-count+ (1- +max-tile-kinds+)))) (data - (let ((tmp (clone-tiles cells:.cache))) - (loop for pnt in data do (set-tile tmp pnt 0)) - (collapse-tiles tmp))) + (loop with tmp = (clone-tiles cells:.cache) + for pnt in data do (set-tile tmp pnt 0) + finally (return (collapse-tiles tmp)))) (t cells:.cache)))))))
Modified: trunk/src/uitoolkit/widgets/dialog.lisp ============================================================================== --- trunk/src/uitoolkit/widgets/dialog.lisp (original) +++ trunk/src/uitoolkit/widgets/dialog.lisp Thu Jun 8 17:35:25 2006 @@ -174,12 +174,6 @@ ;; (init-window self +dialog-classname+ #'register-dialog-class owner text))
-#| -(defmethod event-close ((self event-dispatcher) (dlg dialog) time) - (declare (ignore time)) - (show dlg nil)) -|# - (defmethod show ((self dialog) flag) (let ((app-modal (find :application-modal (style-of self))) (owner-modal (find :owner-modal (style-of self)))
graphic-forms-cvs@common-lisp.net