From ab2c9cfaed47c56ed213e1efbbde6fe9bae5a86e Mon Sep 17 00:00:00 2001 From: Dieter Deyke Date: Sat, 27 May 2017 12:43:34 +0200 Subject: [PATCH] allow for player to start on a target, allow for wider and higher levels --- packages/sokoban/sokoban.el | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/sokoban/sokoban.el b/packages/sokoban/sokoban.el index 3575d2818..d59de952c 100644 --- a/packages/sokoban/sokoban.el +++ b/packages/sokoban/sokoban.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1998, 2013, 2017 Free Software Foundation, Inc. ;; Author: Glynn Clements -;; Version: 1.4.2 +;; Version: 1.4.3 ;; Created: 1997-09-11 ;; Keywords: games ;; Package-Type: multi @@ -45,6 +45,8 @@ ;; caused on-screen score to be truncated ;; Modified: 2017-05-27, save sokoban-level when a level is completed, ;; restore sokoban-level when game is started +;; Modified: 2017-05-27, allow for player to start on a target, +;; allow for wider and higher levels ;; Tested with XEmacs 20.3/4/5 and Emacs 19.34 @@ -87,14 +89,14 @@ (and (file-exists-p file) file)) (expand-file-name "sokoban.levels" data-directory)))) -(defvar sokoban-width 20) -(defvar sokoban-height 16) +(defvar sokoban-width 27) +(defvar sokoban-height 20) -(defvar sokoban-buffer-width 20) -(defvar sokoban-buffer-height 20) +(defvar sokoban-buffer-width sokoban-width) +(defvar sokoban-buffer-height (+ 4 sokoban-height)) (defvar sokoban-score-x 0) -(defvar sokoban-score-y 17) +(defvar sokoban-score-y (+ 1 sokoban-height)) (defvar sokoban-level-data nil) @@ -309,13 +311,14 @@ static char * player_xpm[] = { }; ") -(defconst sokoban-floor ?\+) +(defconst sokoban-floor ?\&) ;; note - space character in level file is also allowed to indicate floor (defconst sokoban-target ?\.) (defconst sokoban-wall ?\#) (defconst sokoban-block ?\$) (defconst sokoban-player ?\@) (defconst sokoban-block-on-target ?\*) +(defconst sokoban-player-on-target ?\+) ;; ;;;;;;;;;;;;; display options ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -488,7 +491,8 @@ static char * player_xpm[] = { (dotimes (x sokoban-width) (let ((c (aref (aref sokoban-level-map y) x))) (cond - ((= c sokoban-target) + ((or (= c sokoban-target) + (= c sokoban-player-on-target)) (incf sokoban-targets)) ((= c sokoban-block-on-target) (incf sokoban-targets) @@ -499,7 +503,8 @@ static char * player_xpm[] = { (defun sokoban-get-floor (x y) (let ((c (aref (aref sokoban-level-map y) x))) (if (or (= c sokoban-target) - (= c sokoban-block-on-target)) + (= c sokoban-block-on-target) + (= c sokoban-player-on-target)) sokoban-target sokoban-floor))) @@ -513,6 +518,10 @@ static char * player_xpm[] = { (if (= c sokoban-player) (setq sokoban-x x sokoban-y y)) + (if (= c sokoban-player-on-target) + (setq sokoban-x x + sokoban-y y + c sokoban-player)) (if (= c sokoban-block-on-target) (setq c sokoban-block)) (gamegrid-set-cell x y c))))) -- 2.11.0