[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/pacmacs 95cce606fd 024/472: Support for Aseprite animation
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/pacmacs 95cce606fd 024/472: Support for Aseprite animation format. Close #16 |
Date: |
Thu, 6 Jan 2022 21:59:02 -0500 (EST) |
branch: elpa/pacmacs
commit 95cce606fd2661e762abfe45fc58a577862aa8ef
Author: rexim <reximkut@gmail.com>
Commit: rexim <reximkut@gmail.com>
Support for Aseprite animation format. Close #16
---
pacman-anim.el | 32 ++++++++++++++++++++++++++++++++
pacman.el | 8 ++------
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/pacman-anim.el b/pacman-anim.el
index 82418f7204..6d348936dc 100644
--- a/pacman-anim.el
+++ b/pacman-anim.el
@@ -1,3 +1,35 @@
+
+(defun pacman-make-anim (frames)
+ (list :frames frames
+ :current-frame 0))
+
+(defun pacman-load-anim (aseprite-json-file)
+ (let* ((aseprite-json (json-read-file aseprite-json-file))
+ (aseprite-frames (cdr (assoc 'frames aseprite-json))))
+ (pacman-make-anim
+ (mapcar 'pacman-convert-aseprite-frame
+ (pacman-aseprite-sort-frame-hack aseprite-frames)))))
+
+(defun pacman-aseprite-frame-get-order (aseprite-frame)
+ (let ((frame-name (symbol-name (car aseprite-frame))))
+ (string-match "\\([0-9]+\\)\\.ase$" frame-name)
+ (string-to-number (match-string 1 frame-name))))
+
+(defun pacman-aseprite-sort-frame-hack (aseprite-frames)
+ (sort aseprite-frames
+ '(lambda (f1 f2)
+ (let ((o1 (pacman-aseprite-frame-get-order f1))
+ (o2 (pacman-aseprite-frame-get-order f2)))
+ (< o1 o2)))))
+
+(defun pacman-convert-aseprite-frame (aseprite-frame)
+ (let* ((frame (cdr (assoc 'frame (cdr aseprite-frame))))
+ (x (cdr (assoc 'x frame)))
+ (y (cdr (assoc 'y frame)))
+ (w (cdr (assoc 'w frame)))
+ (h (cdr (assoc 'h frame))))
+ (list x y w h)))
+
(defun pacman-anim-get-frame (anim)
(let ((frames (plist-get anim :frames))
(current-frame (plist-get anim :current-frame)))
diff --git a/pacman.el b/pacman.el
index fd57777c72..f7b0325bbd 100644
--- a/pacman.el
+++ b/pacman.el
@@ -42,15 +42,11 @@
(list :row 0
:column 0
:direction 'right
- :animation (list :frames (list '(0 0 40 40)
- '(40 0 40 40)
- '(80 0 40 40)
- '(120 0 40 40))
- :current-frame 0)))
+ :animation (pacman-load-anim "sprites/Red-Ghost-Down.json")))
(defvar pacman-resource nil)
(setq pacman-resource
- (pacman-load-resource "sprites/Pacman-Chomping-Right.png"))
+ (pacman-load-resource "sprites/Red-Ghost-Down.png"))
(define-derived-mode pacman-mode special-mode "pacman-mode"
(define-key pacman-mode-map (kbd "<up>") 'pacman-up)
- [nongnu] elpa/pacmacs a5583b6255 377/472: Fix wall-tile-to-xpm UT (#138), (continued)
- [nongnu] elpa/pacmacs a5583b6255 377/472: Fix wall-tile-to-xpm UT (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 93f031ae4e 382/472: Fix create-wall-tile UT (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 2c7e23070b 380/472: Fix put-vertical-bar UT (#138), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs dc14097468 400/472: Add emacs mode for game over (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 98816141d5 398/472: Merge pull request #189 from codingteam/remove-make-terrified-ghost, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 30442797d3 404/472: Add consts for nick and table sizes (#134), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0eeb82ebc9 425/472: Merge pull request #193 from codingteam/rework-nick-after-death-134, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ce1054fab3 433/472: Remove redundant find-resource-file call (#191), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 21a99294ad 440/472: Add score sign (#203), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 9fd3009e5a 442/472: Merge pull request #206 from codingteam/bug/quit-game-over-with-q-202, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 95cce606fd 024/472: Support for Aseprite animation format. Close #16,
ELPA Syncer <=
- [nongnu] elpa/pacmacs 09aa49c6b0 065/472: UTs for pacman-image. Close #52, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs ee893d28bd 180/472: Add module for recording action (#115), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 95c046205a 187/472: Compilation warnings as errors (#123), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs fe40eb20c7 190/472: Merge branch 'coverage-dropped-124' (#124), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 8e36b66a6f 199/472: Make object-board contain list of object (#126), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 6b43cde65d 223/472: Add big pill game object (#81), ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 0546e964b1 222/472: Connected walls proof of concept for #131, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 19ffa64f7e 230/472: Merge branch 'master' into connecte-walls, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs e0856fc881 244/472: Refactor wall tiles functions (#131):, ELPA Syncer, 2022/01/06
- [nongnu] elpa/pacmacs 79aa80e1d2 245/472: Merge branch 'connecte-walls'. Close #131, ELPA Syncer, 2022/01/06