> Could the block drawing routine use bitmap data? I was imagining itty > bitty brick and stone wall effects and different textured floors.
Yep, yep, should be fine. Having quickly searched, I wrote a forward ray casting for Ant Attack thingy in C with Allegro a few years ago, that just loaded an image of the base brick and chopped it up at runtime. Casting into a map in exactly the memory layout as Ant Attack, the relevant C code was less than 100 lines, so I hope I'll be forgiven for regurgitating it at the bottom of this post. Most of the Allegro function names are self explanatory, I hope. Per file dates, I last worked on this during February 2002. A screenshot is at http://members.allegro.cc/ThomasHarte/thumbs/AntAttack.png. It seems to cast out from diamonds and run a single loop searching to fill both the left triangle and the right triangle, not sure if it'd be more efficient to break it up into two... #define GetByte(x, y) ( ((x) < -64) || ((y) < -64) || ((x) > 63) || ((y) > 63) ) ? 0 : map[((x+64) << 7) | (y+64)] void LaunchRay(int mapx, int mapy, int x, int y) { int mask = 0x20; int byte1, byte2, byte3, byte4; int leftempty = 1, rightempty = 1; byte4 = GetByte(mapx, mapy); while(mask && (leftempty || rightempty)) { byte1 = byte4; byte2 = GetByte(mapx + LeftX, mapy + LeftY); //left one byte3 = GetByte(mapx + DownX, mapy + DownY); //up one mapx += LeftX + DownX; mapy += LeftY + DownY; byte4 = GetByte(mapx, mapy); //left & up one if(leftempty) { if(byte1&mask) { draw_sprite(back, ul, x, y); leftempty = 0; } else { if(byte2&mask) { draw_sprite(back, mr, x, y); leftempty = 0; } else if(byte4&mask) { draw_sprite(back, bl, x, y); leftempty = 0; } } } if(rightempty) { if(byte1&mask) { draw_sprite(back, ur, x+left->w, y); rightempty = 0; } else { if(byte3&mask) { draw_sprite(back, ml, x+left->w, y); rightempty = 0; } else if(byte4&mask) { draw_sprite(back, br, x+left->w, y); rightempty = 0; } } } mask >>= 1; } if(leftempty && byte4) draw_sprite(back, shadowl, x, y); if(rightempty && byte4) draw_sprite(back, shadowr, x+left->w, y); } void DrawMap(int offx, int offy) { int x, y, mapx, mapy; clear_to_color(back, 72); for(y = -(back->h >> 1); y < back->h; y += left->h) { mapx = offx; mapy = offy; for(x = -(back->w >> 1); x < back->w; x += (left->w << 1)) { LaunchRay(mapx, mapy, x, y); LaunchRay(mapx-RightVector[1], mapy+RightVector[0], x-left->w, y+(left->h >> 1)); mapx += RightX + DownX; mapy += RightY + DownY; } offx += RightX + UpX; offy += RightY + UpY; } }
