[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 286eb99ae0 130/472: Implement prepare phase. Close
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 286eb99ae0 130/472: Implement prepare phase. Close #80 |
Date: |
Thu, 6 Jan 2022 21:59:18 -0500 (EST) |
branch: elpa/pacmacs
commit 286eb99ae0481b24b838d9af80508967723fd638
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Implement prepare phase. Close #80
---
pacmacs.el | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/pacmacs.el b/pacmacs.el
index 1bdd4bb92a..53b9d099b9 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -71,6 +71,7 @@
(defvar pacmacs-board nil)
(defvar pacmacs-track-board nil)
+;;; play death prepare
(defvar pacmacs-game-state 'play)
(defvar pacmacs-lives 3)
@@ -80,6 +81,8 @@
"map04" "map05" "map06"])
(defvar pacmacs-current-level 0)
+(defvar pacmacs-prepare-time-counter 0)
+
(define-derived-mode pacmacs-mode special-mode "pacmacs-mode"
(define-key pacmacs-mode-map (kbd "<up>") 'pacmacs-up)
(define-key pacmacs-mode-map (kbd "<down>") 'pacmacs-down)
@@ -97,6 +100,7 @@
(setq pacmacs-lives 3)
(setq pacmacs-current-level 0)
(pacmacs--load-current-level)
+ (pacmacs--switch-to-play-state)
(unless pacmacs-timer
(setq pacmacs-timer (run-at-time nil (* pacmacs-tick-duration-ms 0.001)
'pacmacs-tick))))
@@ -109,6 +113,7 @@
(defun pacmacs--load-current-level ()
(pacmacs-load-map (aref pacmacs-levels
pacmacs-current-level)))
+
(defun pacmacs--switch-to-next-level ()
(setq pacmacs-current-level
(mod (1+ pacmacs-current-level)
@@ -293,7 +298,9 @@
((equal pacmacs-game-state 'play)
(pacmacs-play-state-logic))
((equal pacmacs-game-state 'death)
- (pacmacs-death-state-logic)))
+ (pacmacs-death-state-logic))
+ ((equal pacmacs-game-state 'prepare)
+ (pacmacs-prepare-state-logic)))
(erase-buffer)
(pacmacs-render-state))))
@@ -343,7 +350,8 @@
(when (equal pacmacs-game-state 'play)
(pacmacs--step-ghosts)))
(pacmacs--switch-to-next-level)
- (pacmacs--load-current-level))))
+ (pacmacs--load-current-level)
+ (pacmacs--switch-to-prepare-state))))
(defun pacmacs-death-state-logic ()
(pacmacs-anim-object-next-frame pacmacs-player-state
@@ -355,6 +363,12 @@
:current-frame))
(pacmacs--switch-to-play-state)))
+(defun pacmacs-prepare-state-logic ()
+ (if (<= pacmacs-prepare-time-counter 0)
+ (pacmacs--switch-to-play-state)
+ (decf pacmacs-prepare-time-counter
+ pacmacs-tick-duration-ms)))
+
(defun pacmacs-render-anim (anim)
(let* ((sprite-sheet (plist-get anim :sprite-sheet))
(current-frame (plist-get (pacmacs-anim-get-frame anim) :frame)))
@@ -383,6 +397,10 @@
(pacmacs--reset-object-position ghost))
(pacmacs--switch-direction pacmacs-player-state 'right))
+(defun pacmacs--switch-to-prepare-state ()
+ (setq pacmacs-game-state 'prepare)
+ (setq pacmacs-prepare-time-counter 1000))
+
(defun pacmacs-render-track-board ()
(plist-bind ((width :width)
(height :height))
@@ -488,9 +506,7 @@
(setq pacmacs-player-state (pacmacs--make-player row
column)))
((char-equal x ?g)
- (add-to-list 'pacmacs-ghosts (pacmacs--make-ghost row
column))))))
-
- (pacmacs--switch-to-play-state)))
+ (add-to-list 'pacmacs-ghosts (pacmacs--make-ghost row
column))))))))
(provide 'pacmacs)
- [nongnu] elpa/pacmacs d637985f0b 095/472: Fix BFS wraparound bug. Close #73, (continued)
- [nongnu] elpa/pacmacs d637985f0b 095/472: Fix BFS wraparound bug. Close #73, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 952801d94a 098/472: UT for pacmacs--fill-board-test (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 428b994240 096/472: Remove debug output stuff, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9614f394e7 106/472: Merge branch 'board-functions-uts-75'. Close #75, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1e29c2f943 101/472: UTs for pacmacs--cell-tracked-p (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0839611f42 108/472: Refactor out pacmacs--make-board function (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8aa9d50dda 102/472: Remove pacmacs--within-of-map-p (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7714743aa8 103/472: UTs for pacmacs--track-point (#75), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2c0bcf993f 107/472: Use two-argumented `<=`. Close #76, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e5bd77740d 119/472: Fix NPEs (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 286eb99ae0 130/472: Implement prepare phase. Close #80,
ELPA Syncer <=
- [nongnu] elpa/pacmacs d14cdd38e3 135/472: Fix last eaten pill visibility. Close #96, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9cb186f10a 137/472: Refactor pacmacs-inversed-direction-table out. Close #103, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 91c317819c 123/472: Implement basic death mechanics (#69), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs be91d566cb 139/472: Implement Game Over state. Close #94, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b8cd22229d 142/472: Introduce pacmacs--anim-object-list-next-frame, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 91e432111b 145/472: Implement basic score table mechnism (#92), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 7058b61e47 146/472: Implement adding entries to score table (#92), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e032089ab4 151/472: Render score table on Game Over screen (#92), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a7b0530f65 152/472: Merge branch 'score-table-92'. Close #92, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1b2ca64cd1 157/472: Merge branch 'resource-packaging-95'. Close #95, ELPA Syncer, 2022/01/06