Created
September 13, 2025 16:10
-
-
Save marr75/76b586bb02f841cacfb77903fb25de14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pygame | |
| def debug_spritesheet(path, cell_w=32, cell_h=32): | |
| pygame.init() | |
| sheet = pygame.image.load(path).convert_alpha() | |
| screen = pygame.display.set_mode(sheet.get_size()) | |
| clock = pygame.time.Clock() | |
| running = True | |
| while running: | |
| for event in pygame.event.get(): | |
| if event.type == pygame.QUIT: | |
| running = False | |
| screen.fill((0, 0, 0)) | |
| screen.blit(sheet, (0, 0)) | |
| # draw grid | |
| w, h = sheet.get_size() | |
| for x in range(0, w, cell_w): | |
| pygame.draw.line(screen, (255, 0, 0), (x, 0), (x, h)) | |
| for y in range(0, h, cell_h): | |
| pygame.draw.line(screen, (0, 255, 0), (0, y), (w, y)) | |
| pygame.display.flip() | |
| clock.tick(30) | |
| pygame.quit() | |
| debug_spritesheet("spritesheet.png", cell_w=64, cell_h=64) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment