-VPATH=../../sources/vector
+VPATH=../../sources
+
+# Vector tiles
TILE_DIRS=roach
-TILE_SVGS=$(shell find $(patsubst %, $(VPATH)/%, $(TILE_DIRS)) -name "*.svg")
-TILE_PNGS=$(patsubst $(VPATH)/%.svg, %.png, $(TILE_SVGS))
+TILE_SVGS=$(shell find $(patsubst %, $(VPATH)/vector/%, $(TILE_DIRS)) -name "*.svg")
+TILE_PNGS=$(patsubst $(VPATH)/vector/%.svg, %.png, $(TILE_SVGS))
+
+# Bitmap tiles
+
+BTILE_DIRS=wall floor
+BTILE_SRC=$(shell find $(patsubst %, $(VPATH)/bitmap/%, $(BTILE_DIRS)) -name "*.png")
+BTILE_PNGS=$(patsubst $(VPATH)/bitmap/%, %, $(BTILE_SRC))
+
+# Vector images to rasterize without resizing
SIMPLE_DIRS=roach_management
-SIMPLE_SVGS=$(shell find $(patsubst %, $(VPATH)/%, $(SIMPLE_DIRS)) -name "*.svg")
-SIMPLE_PNGS=$(patsubst $(VPATH)/%.svg, %.png, $(SIMPLE_SVGS))
+SIMPLE_SVGS=$(shell find $(patsubst %, $(VPATH)/vector/%, $(SIMPLE_DIRS)) -name "*.svg")
+SIMPLE_PNGS=$(patsubst $(VPATH)/vector/%.svg, %.png, $(SIMPLE_SVGS))
+
+# Aggregate cockroach sprites
ROACH=$(filter roach/%, $(TILE_PNGS))
ROACH_32=$(patsubst roach/%, roach_32/%, $(ROACH))
ROACH_QUARTET=$(patsubst roach/%, roach_quartet/%, $(ROACH))
ROACH_NONET=$(patsubst roach/%, roach_nonet/%, $(ROACH))
-all: $(TILE_PNGS) $(SIMPLE_PNGS)\
+# Default target with everything
+
+all: $(TILE_PNGS) $(BTILE_PNGS) $(SIMPLE_PNGS)\
$(ROACH_32) $(ROACH_21) $(ROACH_QUARTET) $(ROACH_NONET)
-# Tile rules
+# Vector tile rule
define tile
-$(1)/%.png: $(1)/%.svg
+$(1)/%.png: vector/$(1)/%.svg
@mkdir -p `dirname $$@`
@inkscape -z -e $$@ -w 64 -h 64 $$<
endef
$(foreach tiledir,$(TILE_DIRS),$(eval $(call tile,$(tiledir))))
-# Simple rules
+# No resize rule
define simple
-$(1)/%.png: $(1)/%.svg
+$(1)/%.png: vector/$(1)/%.svg
@mkdir -p `dirname $$@`
@inkscape -z -e $$@ $$<
endef
$(foreach simpledir,$(SIMPLE_DIRS),$(eval $(call simple,$(simpledir))))
+# Bitmap tile rule
+
+define btile
+$(1)/%.png: bitmap/$(1)/%.png
+ @mkdir -p `dirname $$@`
+ @convert $$< -resize 64x64 $$@
+endef
+
+$(foreach tiledir,$(BTILE_DIRS),$(eval $(call btile,$(tiledir))))
+
# Smaller roaches
-roach_32/%.png: roach/%.svg
+roach_32/%.png: vector/roach/%.svg
@mkdir -p `dirname $@`
@inkscape -z -e $@ -w 32 -h 32 $<
-roach_21/%.png: roach/%.svg
+roach_21/%.png: vector/roach/%.svg
@mkdir -p `dirname $@`
@inkscape -z -e $@ -w 21 -h 21 $<