All pastes #724013 Raw Edit

drawing bmp problem

public text v1 · immutable
#724013 ·published 2007-10-03 07:38 UTC
rendered paste body
/* here are the defines (at top of file) */

#include "amaze_tiles.h"

#define TILE_WIDTH  BMP_amaze_tiles	
#define TILE_HEIGHT (BMP_amaze_tiles/9)

#define t_up 		0
#define t_down		1
#define t_left		2
#define t_right 	3
#define t_visited	4
#define t_obspace	5
#define t_goal 	 	6
#define t_block	 	7
#define t_space		8


/* here's the drawing function */

void drawtilemap(void)
{
	int x,y;
	char map_unit;
	int unit_fmt;

	clearscreen();

	#   define DRAW_TILE( a )                                         \
                    rb->lcd_bitmap_part( amaze_tiles, 0,                   \
                                         a*TILE_HEIGHT, TILE_WIDTH,       \
                                         x * TILE_WIDTH,  \
                                         y * TILE_HEIGHT, \
                                         TILE_WIDTH, TILE_HEIGHT);

	for(y=0; y < umap->maxy; y++)
		for (x=0; x < umap->maxx; x++) {

			map_unit = umap->coords[y][x].chr;
			unit_fmt = umap->coords[y][x].attrib;
			
			switch (map_unit) {
				case '^':
					DRAW_TILE(t_up);
					break;
				case 'v':
					DRAW_TILE(t_down);
					break;
				case '<':
					DRAW_TILE(t_left);
					break;
				case '>':
					DRAW_TILE(t_right);
					break;
				case '.':
					DRAW_TILE(t_visited);
					break;
				case '#':
					DRAW_TILE(t_obspace);
					break;
				case '%':
					DRAW_TILE(t_goal);
					break;
				case ' ':
					if(unit_fmt==A_NORMAL)
						DRAW_TILE(t_space)
					else
						DRAW_TILE(t_block)
					break;
			}
	}

	rb->lcd_update();
}