From acc7bc9f96e528faaba0c97e1f355a5eb0aac371 Mon Sep 17 00:00:00 2001 From: enne2 Date: Wed, 17 Jun 2026 23:05:41 +0200 Subject: [PATCH] fix: redesign game over screen with properly centered creepy ascii rat --- src/main.c | 12 ++++++------ tests/test_gameover.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 tests/test_gameover.py diff --git a/src/main.c b/src/main.c index 4aa21ca..5ec160d 100644 --- a/src/main.c +++ b/src/main.c @@ -85,12 +85,12 @@ void main(void) { // Disegna l'ASCII art e il messaggio di sconfitta! printf("\n\n"); - printf(" GAME OVER!\n\n"); - printf(" /\\_,,,_/\\\n"); - printf(" | ' O O ' |\n"); - printf(" | >w< |\n"); - printf(" \\_/\"v\"\\_/\n\n"); - printf(" L'INVASIONE VINCE!\n"); + printf(" GAME OVER!\n\n"); + printf(" /\\_..._/\\\n"); + printf(" | @ @ |\n"); + printf(" | v |\n"); + printf(" \\_/\"V\"\\_/\n\n"); + printf(" L'INVASIONE VINCE!\n"); // Suono inquietante e fine della traccia allegra play_game_over_music(); diff --git a/tests/test_gameover.py b/tests/test_gameover.py new file mode 100644 index 0000000..a9d4a37 --- /dev/null +++ b/tests/test_gameover.py @@ -0,0 +1,40 @@ +import sys +from pyboy import PyBoy +import cv2 +import numpy as np + +def main(): + pyboy = PyBoy('maze.gb', window='null') + # Run for 400 frames to let the game over screen render and boot sequence finish + for _ in range(400): + pyboy.tick() + + # Save screenshot + img_path = '/tmp/gameover_test.png' + pyboy.screen.image.save(img_path) + + # Draw grid with OpenCV + img = cv2.imread(img_path) + for x in range(0, 160, 8): + cv2.line(img, (x, 0), (x, 144), (0, 255, 0), 1) + for y in range(0, 144, 8): + cv2.line(img, (0, y), (160, y), (0, 255, 0), 1) + cv2.imwrite('/tmp/gameover_grid.png', img) + print("Saved grid image to /tmp/gameover_grid.png") + + print("Screen tilemap:") + for y in range(18): + line = "" + for x in range(20): + tile_id = pyboy.memory[0x9800 + y * 32 + x] + # Default font mapping: Space is 0x20. ASCII maps directly! + if 0x20 <= tile_id <= 0x7E: + line += chr(tile_id) + else: + line += "." + print(f"{y:02d}: '{line}'") + + pyboy.stop() + +if __name__ == '__main__': + main()