[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs b5078d2632 141/472: Move most of the rendering stu
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs b5078d2632 141/472: Move most of the rendering stuff to pacman-render |
Date: |
Thu, 6 Jan 2022 21:59:19 -0500 (EST) |
branch: elpa/pacmacs
commit b5078d2632130f4cd782613e89d3bc100c32816b
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Move most of the rendering stuff to pacman-render
---
pacmacs-render.el | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
pacmacs.el | 50 +++-----------------------------
2 files changed, 90 insertions(+), 46 deletions(-)
diff --git a/pacmacs-render.el b/pacmacs-render.el
new file mode 100644
index 0000000000..12c65638e1
--- /dev/null
+++ b/pacmacs-render.el
@@ -0,0 +1,86 @@
+;;; pacmacs-render.el --- Pacman for Emacs
+
+;; Copyright (C) 2015 Codingteam
+
+;; Author: Codingteam <codingteam@conference.jabber.ru>
+;; Maintainer: Alexey Kutepov <reximkut@gmail.com>
+;; URL: http://github.com/rexim/pacmacs.el
+
+;; Permission is hereby granted, free of charge, to any person
+;; obtaining a copy of this software and associated documentation
+;; files (the "Software"), to deal in the Software without
+;; restriction, including without limitation the rights to use, copy,
+;; modify, merge, publish, distribute, sublicense, and/or sell copies
+;; of the Software, and to permit persons to whom the Software is
+;; furnished to do so, subject to the following conditions:
+
+;; The above copyright notice and this permission notice shall be
+;; included in all copies or substantial portions of the Software.
+
+;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+;; NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+;; BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+;; ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+;; SOFTWARE.
+
+;;; Commentary:
+
+;; Routines for working with rendering
+
+;;; Code:
+
+(require 'pacmacs-image)
+(require 'pacmacs-anim)
+
+(defvar pacmacs--empty-cell nil)
+(defvar pacmacs--life-icon nil)
+
+(defun pacmacs--render-empty-cell ()
+ (when (not pacmacs--empty-cell)
+ (setq pacmacs--empty-cell (pacmacs-create-transparent-block 40 40)))
+ (pacmacs-insert-image pacmacs--empty-cell '(0 0 40 40)))
+
+(defun pacmacs--render-life-icon ()
+ (when (not pacmacs--life-icon)
+ (setq pacmacs--life-icon
+ (pacmacs-load-anim "Pacman-Chomping-Right"))
+ (plist-put pacmacs--life-icon :current-frame 2))
+ (pacmacs--render-anim pacmacs--life-icon))
+
+(defun pacmacs--render-anim (anim)
+ (let* ((sprite-sheet (plist-get anim :sprite-sheet))
+ (current-frame (plist-get (pacmacs-anim-get-frame anim) :frame)))
+ (pacmacs-insert-image sprite-sheet current-frame)))
+
+(defun pacmacs--render-object (anim-object)
+ (if anim-object
+ (let* ((anim (plist-get anim-object :current-animation)))
+ (pacmacs--render-anim anim))
+ (pacmacs--render-empty-cell)))
+
+(defun pacmacs--render-track-board (track-board)
+ (plist-bind ((width :width)
+ (height :height))
+ track-board
+ (dotimes (row height)
+ (dotimes (column width)
+ (let ((x (pacmacs--cell-get track-board row column)))
+ (cond
+ ((null x)
+ (insert "."))
+ ((equal x 'left)
+ (insert "<"))
+ ((equal x 'right)
+ (insert ">"))
+ ((equal x 'up)
+ (insert "^"))
+ ((equal x 'down)
+ (insert "v")))))
+ (insert "\n"))))
+
+(provide 'pacmacs-render)
+
+;;; pacmacs-render.el ends here
diff --git a/pacmacs.el b/pacmacs.el
index e109270cab..1fb313b1ec 100644
--- a/pacmacs.el
+++ b/pacmacs.el
@@ -41,6 +41,7 @@
(require 'pacmacs-board)
(require 'pacmacs-image)
(require 'pacmacs-utils)
+(require 'pacmacs-render)
(defconst pacmacs-buffer-name "*Pacmacs*")
(defconst pacmacs-tick-duration-ms 100)
@@ -59,8 +60,6 @@
(defvar pacmacs-wall-cells nil)
(defvar pacmacs-pills nil)
-(defvar pacmacs--empty-cell nil)
-
(defvar pacmacs-board nil)
(defvar pacmacs-track-board nil)
@@ -68,7 +67,7 @@
(defvar pacmacs-game-state 'play)
(defvar pacmacs-lives 3)
-(defvar pacmacs-life-icon nil)
+
(defvar pacmacs-levels ["map01" "map02" "map03"
"map04" "map05" "map06"])
@@ -198,18 +197,6 @@
(plist-put game-object :direction direction)
(plist-put game-object :current-animation (plist-get direction-animations
direction))))
-(defun pacmacs--render-life-icon ()
- (when (not pacmacs-life-icon)
- (setq pacmacs-life-icon
- (pacmacs-load-anim "Pacman-Chomping-Right"))
- (plist-put pacmacs-life-icon :current-frame 2))
- (pacmacs-render-anim pacmacs-life-icon))
-
-(defun pacmacs--render-empty-cell ()
- (when (not pacmacs--empty-cell)
- (setq pacmacs--empty-cell (pacmacs-create-transparent-block 40 40)))
- (pacmacs-insert-image pacmacs--empty-cell '(0 0 40 40)))
-
(defun pacmacs-step-object (game-object)
(plist-bind ((row :row)
(column :column)
@@ -362,16 +349,7 @@
(decf pacmacs-waiting-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)))
- (pacmacs-insert-image sprite-sheet current-frame)))
-(defun pacmacs-render-object (anim-object)
- (if anim-object
- (let* ((anim (plist-get anim-object :current-animation)))
- (pacmacs-render-anim anim))
- (pacmacs--render-empty-cell)))
(defun pacmacs--put-object (anim-object)
(when anim-object
@@ -405,31 +383,11 @@
(setq pacmacs-game-state 'level-beaten)
(setq pacmacs-waiting-counter 1000))
-(defun pacmacs-render-track-board ()
- (plist-bind ((width :width)
- (height :height))
- pacmacs-board
- (dotimes (row height)
- (dotimes (column width)
- (let ((x (pacmacs--cell-get pacmacs-track-board row column)))
- (cond
- ((null x)
- (insert "."))
- ((equal x 'left)
- (insert "<"))
- ((equal x 'right)
- (insert ">"))
- ((equal x 'up)
- (insert "^"))
- ((equal x 'down)
- (insert "v")))))
- (insert "\n"))))
-
(defun pacmacs-render-state ()
(insert (format "Score: %d\n" pacmacs-score))
(when pacmacs-debug-output
- (pacmacs-render-track-board))
+ (pacmacs--render-track-board pacmacs-track-board))
(pacmacs--fill-board pacmacs-board nil)
@@ -450,7 +408,7 @@
(dotimes (row height)
(dotimes (column width)
(let ((anim-object (pacmacs--cell-get pacmacs-board row column)))
- (pacmacs-render-object anim-object)))
+ (pacmacs--render-object anim-object)))
(insert "\n")))
(insert "\n")
(dotimes (i pacmacs-lives)
- [nongnu] elpa/pacmacs 0f4eb7aebf 452/472: Decouple score page render from sign render (#203), (continued)
- [nongnu] elpa/pacmacs 0f4eb7aebf 452/472: Decouple score page render from sign render (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs a12795e835 455/472: Introduce pacmacs-scores-mode (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs cdae42dba5 461/472: Replace too specific function with composition, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 864fe2b02e 465/472: Bump the copyright year for all the files, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs edadbe5e53 469/472: Bump version to 0.1, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs db16fba9cd 470/472: Add missing license statement, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 98ce700143 023/472: Hide cursor in the game's buffer. Close #12, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 3070cf0e6a 063/472: Merge branch 'refactor-image-resource-51'. Close #51, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 1a678dfee7 110/472: Refactor out pacmacs--object-at-p (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 5492ed0a87 118/472: Refactor pacmacs-render-state (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs b5078d2632 141/472: Move most of the rendering stuff to pacman-render,
ELPA Syncer <=
- [nongnu] elpa/pacmacs a460cd8b06 148/472: Merge pull request #107 from rexim/feature/new-maps, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs c426f6ac91 078/472: Fix some accidental paredit typo, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 4341b23d87 094/472: Implement wraparound. Close #67, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 12942ddeff 113/472: Refactor out pacmacs--fill-board (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 91408c074d 115/472: Refactor pacmacs--track-object (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ed40addf95 116/472: Refactor pacmacs--put-object (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs eac9d47c62 117/472: Refactor pacmacs-render-track-board (#74), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs d763bd0f82 121/472: Fix the UTs, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9527a965e1 134/472: Merge branch 'switch-game-state-in-logic-functions-97'. Close #97, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 86f76c4bef 129/472: Implement switching level mechanics. Close #79, ELPA Syncer, 2022/01/06