ゲームプログラミング>クオータービュー
クォータービュー
iso view
Copyright (C) 2003 Yuu Fujishima. All rights reserved.
create:031219
// Sprite Buffer Manager
typedef struct { int x,y,z; // position int c; // チップ番号 } SprMbr; void push(int x, int y, int z, int c); void render(void); int comp(const void *a, const void *b);
DDOBJ ChipBMP; DDOBJ CharaBMP; static SprMbr table[400]; static int count;
void push(int x, int y, int z, int c) { table[count].x = (320)+(x-y); table[count].z = (480-32*10)+(y+x)/2; table[count].y = table[count].z+z; table[count].z *= 256; table[count].z -= z; table[count].c = c; ++count; }
void render(void) { int i; qsort(table, (size_t)count, sizeof(SprMbr), comp); for (i=0;i<count;++i) { switch(table[i].c) { case 0: elDraw::Layer( table[i].x-32, table[i].y-32, ChipBMP, 0,0,64,64 ); break; case 1: elDraw::Layer( table[i].x-32, table[i].y-32-12, CharaBMP, 0,0,64,64 ); break; } } }
int comp(const void *a, const void *b) { return ( ((SprMbr*)a)->z - ((SprMbr*)b)->z ); }
http://www008.upp.so-net.ne.jp/matumura/index.htm