diff options
| author | Gene Pasquet <gene@pacerevenue.com> | 2026-02-26 21:11:54 +0000 |
|---|---|---|
| committer | Gene Pasquet <gene@pacerevenue.com> | 2026-02-26 21:11:54 +0000 |
| commit | 547a085fc4b55260b0000b8b5f9a0bd7791fb6d5 (patch) | |
| tree | 20494bea3239057c9fb3eeea265b2fd7cd1a1afc /src/macroknight/tiles.hy | |
| parent | 1d28f3556a957b4099f12abd4d4645f17f1df3e8 (diff) | |
Improved input handling
Diffstat (limited to 'src/macroknight/tiles.hy')
| -rw-r--r-- | src/macroknight/tiles.hy | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/macroknight/tiles.hy b/src/macroknight/tiles.hy deleted file mode 100644 index 81e72e5..0000000 --- a/src/macroknight/tiles.hy +++ /dev/null @@ -1,53 +0,0 @@ -;;; Copyright (C) 2025 Gene Pasquet -;;; -;;; This program is free software: you can redistribute it and/or modify -;;; it under the terms of the GNU General Public License as published by -;;; the Free Software Foundation, either version 3 of the License, or -;;; (at your option) any later version. -;;; -;;; This program is distributed in the hope that it will be useful, -;;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with this program. If not, see <https://www.gnu.org/licenses/>. - -(import pygame) - -(defclass TileSet [] - (defn __init__ [self image-file scaling tile-w tile-h [padding 0]] - (setv self.tile-w tile-w) - (setv self.tile-h tile-h) - (setv self.scaling scaling) - - (setv self.sheet - (let [surf (pygame.image.load image-file) - map-width (* (.get_width surf) self.scaling) - map-height (* (.get_height surf) self.scaling)] - (if (!= self.scaling 1) - (pygame.transform.scale surf #(map-width map-height)) - surf))) - - (setv self.tiles - (lfor y (range 0 (.get_height self.sheet) (+ tile-h (* padding self.scaling))) - x (range 0 (.get_width self.sheet) (+ tile-w (* padding self.scaling))) - (let [tile (pygame.Surface #(tile-w tile-h))] - (.blit tile self.sheet #(0 0) #(x y tile-w tile-h)) - tile))))) - -(defclass MiniSprite [pygame.sprite.Sprite] - (defn __init__ [self tile tile-size x y [goal False]] - (.__init__ (super)) - (setv self.surf (pygame.Surface #(tile-size tile-size))) - (.blit self.surf tile #(0 0)) - (setv self.rect (.get_rect self.surf - :left (* x tile-size) - :top (* y tile-size))) - (setv self.goal goal))) - -(defn draw-tile [target tileset tile-id #* args #** kwargs] - (let [tile (get tileset.tiles tile-id) - sprite (MiniSprite tile tileset.tile-w #* args #** kwargs)] - (.blit target sprite.surf sprite.rect) - sprite)) |
