Revert sprite-based stairs back to tile-based stairs
This commit is contained in:
@@ -9,26 +9,24 @@ SCRIPTS_DIR = scripts
|
||||
BUILD_DIR = build
|
||||
|
||||
# C source files
|
||||
SRCS = $(SRC_DIR)/main.c $(SRC_DIR)/engine.c $(SRC_DIR)/globals.c $(SRC_DIR)/maze.c $(SRC_DIR)/sound.c $(SRC_DIR)/render.c $(SRC_DIR)/player_logic.c $(SRC_DIR)/enemy_logic.c $(SRC_DIR)/tiles.c $(SRC_DIR)/player.c $(SRC_DIR)/enemy.c $(SRC_DIR)/gameover.c $(SRC_DIR)/victory.c $(SRC_DIR)/stamina.c $(SRC_DIR)/title_bg.c $(SRC_DIR)/stairs_sprite.c
|
||||
SRCS = $(SRC_DIR)/main.c $(SRC_DIR)/engine.c $(SRC_DIR)/globals.c $(SRC_DIR)/maze.c $(SRC_DIR)/sound.c $(SRC_DIR)/render.c $(SRC_DIR)/player_logic.c $(SRC_DIR)/enemy_logic.c $(SRC_DIR)/tiles.c $(SRC_DIR)/player.c $(SRC_DIR)/enemy.c $(SRC_DIR)/gameover.c $(SRC_DIR)/victory.c $(SRC_DIR)/stamina.c $(SRC_DIR)/title_bg.c
|
||||
|
||||
all: $(BUILD_DIR)/hello_iso.gb $(BUILD_DIR)/test_gameover.gb $(BUILD_DIR)/test_sprite_stairs.gb
|
||||
all: $(BUILD_DIR)/hello_iso.gb $(BUILD_DIR)/test_gameover.gb
|
||||
|
||||
# Generate image assets
|
||||
generate_images: $(SCRIPTS_DIR)/generate_assets.py $(SCRIPTS_DIR)/generate_enemy.py $(SCRIPTS_DIR)/generate_stairs_sprite.py
|
||||
generate_images: $(SCRIPTS_DIR)/generate_assets.py $(SCRIPTS_DIR)/generate_enemy.py
|
||||
cd $(ASSETS_DIR) && python3 ../$(SCRIPTS_DIR)/generate_assets.py
|
||||
cd $(ASSETS_DIR) && python3 ../$(SCRIPTS_DIR)/generate_enemy.py
|
||||
cd $(ASSETS_DIR) && python3 ../$(SCRIPTS_DIR)/generate_stairs_sprite.py
|
||||
|
||||
# Convert image assets to C source files
|
||||
generate_c_assets: generate_images
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/tiles.png -c $(SRC_DIR)/tiles.c -map -bpp 2 -noflip -keep_palette_order
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/player.png -c $(SRC_DIR)/player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/enemy.png -c $(SRC_DIR)/enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10 -spr8x16
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/gameover.png -c $(SRC_DIR)/gameover.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/victory.png -c $(SRC_DIR)/victory.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/stamina.png -c $(SRC_DIR)/stamina.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/player.png -c $(SRC_DIR)/player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/enemy.png -c $(SRC_DIR)/enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/gameover.png -c $(SRC_DIR)/gameover.c -bpp 2 -noflip -keep_palette_order
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/victory.png -c $(SRC_DIR)/victory.c -bpp 2 -noflip -keep_palette_order
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/stamina.png -c $(SRC_DIR)/stamina.c -bpp 2 -noflip -keep_palette_order
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/title_bg.png -c $(SRC_DIR)/title_bg.c -map -bpp 2 -noflip -keep_palette_order -max_palettes 1
|
||||
$(PNG2ASSET) $(ASSETS_DIR)/stairs_sprite.png -c $(SRC_DIR)/stairs_sprite.c -sw 32 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
|
||||
# Main ROM target
|
||||
$(BUILD_DIR)/hello_iso.gb: generate_c_assets $(SRCS)
|
||||
@@ -40,11 +38,6 @@ $(BUILD_DIR)/test_gameover.gb: generate_c_assets $(SRC_DIR)/test_gameover_render
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(LCC) -Wa-l -Wl-m -Wl-j -o $(BUILD_DIR)/test_gameover.gb $(SRC_DIR)/test_gameover_render.c $(SRC_DIR)/player.c $(SRC_DIR)/enemy.c $(SRC_DIR)/gameover.c $(SRC_DIR)/stamina.c
|
||||
|
||||
# Sprite Stairs Test ROM target
|
||||
$(BUILD_DIR)/test_sprite_stairs.gb: generate_c_assets $(SRCS)
|
||||
mkdir -p $(BUILD_DIR)
|
||||
$(LCC) -DUSE_SPRITE_STAIRS $(LCCFLAGS) -o $(BUILD_DIR)/test_sprite_stairs.gb $(SRCS)
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)/*
|
||||
rm -f $(SRC_DIR)/tiles.c $(SRC_DIR)/tiles.h
|
||||
@@ -54,4 +47,3 @@ clean:
|
||||
rm -f $(SRC_DIR)/victory.c $(SRC_DIR)/victory.h
|
||||
rm -f $(SRC_DIR)/stamina.c $(SRC_DIR)/stamina.h
|
||||
rm -f $(SRC_DIR)/title_bg.c $(SRC_DIR)/title_bg.h
|
||||
rm -f $(SRC_DIR)/stairs_sprite.c $(SRC_DIR)/stairs_sprite.h
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 882 B |
@@ -1,46 +0,0 @@
|
||||
import os
|
||||
from PIL import Image, ImageDraw
|
||||
|
||||
# Standard Game Boy palette
|
||||
# 0: White, 1: Light Gray, 2: Dark Gray, 3: Black
|
||||
PALETTE = [
|
||||
224, 248, 207, # 0
|
||||
134, 192, 108, # 1
|
||||
48, 104, 80, # 2
|
||||
7, 24, 33 # 3
|
||||
] + [0] * (256 * 3 - 12)
|
||||
|
||||
stairs_pattern = [
|
||||
"00000000000000033000000000000000",
|
||||
"00000000000003311330000000000000",
|
||||
"00000000000331111113300000000000",
|
||||
"00000000000003311330000000000000",
|
||||
"00000000000000033000000000000000",
|
||||
"00000000000003300330000000000000",
|
||||
"00000000000330000003300000000000",
|
||||
"00000000000003300330000000000000",
|
||||
"00000000000000033000000000000000",
|
||||
"00000000000003311330000000000000",
|
||||
"00000000000331111113300000000000",
|
||||
"00000000000003311330000000000000",
|
||||
"00000000000000033000000000000000",
|
||||
"00000000000003300330000000000000",
|
||||
"00000000000330000003300000000000",
|
||||
"00000000000003300330000000000000",
|
||||
]
|
||||
|
||||
def generate_stairs_sprite():
|
||||
img = Image.new("P", (32, 16), 0)
|
||||
img.putpalette(PALETTE)
|
||||
|
||||
for py in range(16):
|
||||
for px in range(32):
|
||||
char = stairs_pattern[py][px]
|
||||
if char != '0':
|
||||
img.putpixel((px, py), int(char))
|
||||
|
||||
img.save("stairs_sprite.png")
|
||||
print("stairs_sprite.png generated.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_stairs_sprite()
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /enemy.png -c /enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10 -spr8x16
|
||||
// Conversion args: /enemy.png -c /enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /enemy.png -c /enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10 -spr8x16
|
||||
// Conversion args: /enemy.png -c /enemy.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -sp 0x10
|
||||
|
||||
#ifndef METASPRITE_enemy_H
|
||||
#define METASPRITE_enemy_H
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
#include "victory.h"
|
||||
#include "stamina.h"
|
||||
#include "title_bg.h"
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
#include "stairs_sprite.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Inizializza la schermata del titolo
|
||||
@@ -99,9 +96,6 @@ void engine_init(void) {
|
||||
set_sprite_data(player_TILE_COUNT + enemy_TILE_COUNT, gameover_TILE_COUNT, gameover_tiles);
|
||||
set_sprite_data(player_TILE_COUNT + enemy_TILE_COUNT + gameover_TILE_COUNT, victory_TILE_COUNT, victory_tiles);
|
||||
set_sprite_data(player_TILE_COUNT + enemy_TILE_COUNT + gameover_TILE_COUNT + victory_TILE_COUNT, stamina_TILE_COUNT * 2, stamina_tiles);
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
set_sprite_data(player_TILE_COUNT + enemy_TILE_COUNT + gameover_TILE_COUNT + victory_TILE_COUNT + stamina_TILE_COUNT * 2, stairs_sprite_TILE_COUNT, stairs_sprite_tiles);
|
||||
#endif
|
||||
|
||||
// SPAWN DEL GIOCATORE
|
||||
player_lx = 1;
|
||||
@@ -122,13 +116,6 @@ void engine_init(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
// HARDCODE STAIRS FOR TESTING
|
||||
stairs_lx = player_lx + 1;
|
||||
stairs_ly = player_ly;
|
||||
maze[stairs_ly][stairs_lx] = 2;
|
||||
#endif
|
||||
|
||||
// SPAWN DEL NEMICO
|
||||
// Cerca randomicamente un punto lontano almeno 3 celle dal giocatore
|
||||
while (1) {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /gameover.png -c /gameover.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /gameover.png -c /gameover.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /gameover.png -c /gameover.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /gameover.png -c /gameover.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#ifndef METASPRITE_gameover_H
|
||||
#define METASPRITE_gameover_H
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /player.png -c /player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /player.png -c /player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /player.png -c /player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /player.png -c /player.c -sw 16 -sh 16 -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#ifndef METASPRITE_player_H
|
||||
#define METASPRITE_player_H
|
||||
|
||||
@@ -9,9 +9,6 @@
|
||||
#include "victory.h"
|
||||
#include "stamina.h"
|
||||
#include "maze.h"
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
#include "stairs_sprite.h"
|
||||
#endif
|
||||
|
||||
uint8_t get_tile_state(int8_t cx, int8_t cy, int8_t lx, int8_t ly) {
|
||||
if (lx < 0 || lx >= MAP_SIZE || ly < 0 || ly >= MAP_SIZE) return 0;
|
||||
@@ -121,11 +118,7 @@ void draw_map(uint8_t center_x, uint8_t center_y) {
|
||||
// Passata 1: Pavimenti normali
|
||||
for (int8_t ly = start_y; ly <= end_y; ly++) {
|
||||
for (int8_t lx = start_x; lx <= end_x; lx++) {
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
if (maze[ly][lx] == 1 || maze[ly][lx] == 2) {
|
||||
#else
|
||||
if (maze[ly][lx] == 1) {
|
||||
#endif
|
||||
// Distanza di Chebyshev dal giocatore
|
||||
int8_t dx = lx - center_x;
|
||||
int8_t dy = ly - center_y;
|
||||
@@ -162,7 +155,6 @@ void draw_map(uint8_t center_x, uint8_t center_y) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_SPRITE_STAIRS
|
||||
// Passata 2: Scala della Vittoria (disegnata sempre sopra)
|
||||
for (int8_t ly = start_y; ly <= end_y; ly++) {
|
||||
for (int8_t lx = start_x; lx <= end_x; lx++) {
|
||||
@@ -204,7 +196,6 @@ void draw_map(uint8_t center_x, uint8_t center_y) {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
update_stamina_display();
|
||||
|
||||
@@ -229,27 +220,6 @@ void update_camera(void) {
|
||||
|
||||
// Comando hardware GBDK per scrollare il livello Background
|
||||
move_bkg(scroll_x, scroll_y);
|
||||
|
||||
#ifdef USE_SPRITE_STAIRS
|
||||
// Calcola e posiziona lo sprite delle scale
|
||||
int16_t stairs_px = (stairs_lx - stairs_ly) * 16 + 96;
|
||||
int16_t stairs_py = (stairs_lx + stairs_ly) * 8 + 16;
|
||||
int16_t stairs_screen_x = ((stairs_px - scroll_x) & 255) + 8; // Offset per sprite
|
||||
int16_t stairs_screen_y = ((stairs_py - scroll_y) & 255) + 16;
|
||||
|
||||
int8_t dx = (int8_t)stairs_lx - (int8_t)player_lx;
|
||||
int8_t dy = (int8_t)stairs_ly - (int8_t)player_ly;
|
||||
if (dx < 0) dx = -dx;
|
||||
if (dy < 0) dy = -dy;
|
||||
uint8_t dist = (dx > dy) ? dx : dy;
|
||||
|
||||
// Se le scale sono visibili (dist <= 2), disegnale, altrimenti nascondile
|
||||
if (dist <= 2 && stairs_screen_x >= -32 && stairs_screen_x <= 168 && stairs_screen_y >= -16 && stairs_screen_y <= 152) {
|
||||
move_metasprite(stairs_sprite_metasprites[0], player_TILE_COUNT + enemy_TILE_COUNT + gameover_TILE_COUNT + victory_TILE_COUNT + stamina_TILE_COUNT * 2, 12, stairs_screen_x, stairs_screen_y - 8);
|
||||
} else {
|
||||
move_metasprite(stairs_sprite_metasprites[0], player_TILE_COUNT + enemy_TILE_COUNT + gameover_TILE_COUNT + victory_TILE_COUNT + stamina_TILE_COUNT * 2, 12, 0, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /stairs_sprite.png -c /stairs_sprite.c -sw 32 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
#include <gbdk/metasprites.h>
|
||||
|
||||
BANKREF(stairs_sprite)
|
||||
|
||||
const palette_color_t stairs_sprite_palettes[32] = {
|
||||
RGB8(224,248,207), RGB8(134,192,108), RGB8( 48,104, 80), RGB8( 7, 24, 33),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0),
|
||||
RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0), RGB8( 0, 0, 0)
|
||||
};
|
||||
|
||||
const uint8_t stairs_sprite_tiles[64] = {
|
||||
0x01,0x01,0x07,0x06,0x1f,0x18,0x07,0x06,0x01,0x01,0x06,0x06,0x18,0x18,0x06,0x06,
|
||||
0x01,0x01,0x07,0x06,0x1f,0x18,0x07,0x06,0x01,0x01,0x06,0x06,0x18,0x18,0x06,0x06,
|
||||
0x80,0x80,0xe0,0x60,0xf8,0x18,0xe0,0x60,0x80,0x80,0x60,0x60,0x18,0x18,0x60,0x60,
|
||||
0x80,0x80,0xe0,0x60,0xf8,0x18,0xe0,0x60,0x80,0x80,0x60,0x60,0x18,0x18,0x60,0x60
|
||||
};
|
||||
|
||||
const metasprite_t stairs_sprite_metasprite0[] = {
|
||||
METASPR_ITEM(-8, -8, 0, S_PAL(0)),
|
||||
METASPR_ITEM(0, 8, 2, S_PAL(0)),
|
||||
METASPR_TERM
|
||||
};
|
||||
|
||||
const metasprite_t* const stairs_sprite_metasprites[1] = {
|
||||
stairs_sprite_metasprite0
|
||||
};
|
||||
@@ -1,31 +0,0 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /stairs_sprite.png -c /stairs_sprite.c -sw 32 -sh 16 -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
|
||||
#ifndef METASPRITE_stairs_sprite_H
|
||||
#define METASPRITE_stairs_sprite_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
#include <gbdk/metasprites.h>
|
||||
|
||||
#define stairs_sprite_TILE_ORIGIN 0
|
||||
#define stairs_sprite_TILE_W 8
|
||||
#define stairs_sprite_TILE_H 16
|
||||
#define stairs_sprite_WIDTH 32
|
||||
#define stairs_sprite_HEIGHT 16
|
||||
#define stairs_sprite_TILE_COUNT 4
|
||||
#define stairs_sprite_PALETTE_COUNT 8
|
||||
#define stairs_sprite_COLORS_PER_PALETTE 4
|
||||
#define stairs_sprite_TOTAL_COLORS 32
|
||||
#define stairs_sprite_PIVOT_X 16
|
||||
#define stairs_sprite_PIVOT_Y 8
|
||||
#define stairs_sprite_PIVOT_W 32
|
||||
#define stairs_sprite_PIVOT_H 16
|
||||
extern const metasprite_t* const stairs_sprite_metasprites[1];
|
||||
|
||||
BANKREF_EXTERN(stairs_sprite)
|
||||
|
||||
extern const palette_color_t stairs_sprite_palettes[32];
|
||||
extern const uint8_t stairs_sprite_tiles[64];
|
||||
|
||||
#endif
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /stamina.png -c /stamina.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /stamina.png -c /stamina.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /stamina.png -c /stamina.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /stamina.png -c /stamina.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#ifndef METASPRITE_stamina_H
|
||||
#define METASPRITE_stamina_H
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /victory.png -c /victory.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /victory.png -c /victory.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gbdk/platform.h>
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
//AUTOGENERATED FILE FROM png2asset
|
||||
// Conversion args: /victory.png -c /victory.c -bpp 2 -noflip -keep_palette_order -spr8x16
|
||||
// Conversion args: /victory.png -c /victory.c -bpp 2 -noflip -keep_palette_order
|
||||
|
||||
#ifndef METASPRITE_victory_H
|
||||
#define METASPRITE_victory_H
|
||||
|
||||
Reference in New Issue
Block a user