|
|
@ -57,8 +57,8 @@ double planeY = 0.66; |
|
|
|
#define gray_color(c) rgba_color(c, c, c, 255) |
|
|
|
#define gray_color(c) rgba_color(c, c, c, 255) |
|
|
|
|
|
|
|
|
|
|
|
std::vector<uint32_t> texture[8]; |
|
|
|
std::vector<uint32_t> texture[8]; |
|
|
|
#define texWidth 64 // must be power of two
|
|
|
|
#define texWidth 256 // must be power of two
|
|
|
|
#define texHeight 64 // must be power of two
|
|
|
|
#define texHeight 256 // must be power of two
|
|
|
|
|
|
|
|
|
|
|
|
#define pixcoord(X, Y) ((Y) * SCREEN_HEIGHT) + (X) |
|
|
|
#define pixcoord(X, Y) ((Y) * SCREEN_HEIGHT) + (X) |
|
|
|
|
|
|
|
|
|
|
@ -80,14 +80,14 @@ void load_textures() { |
|
|
|
texture[i].resize(texWidth * texHeight); |
|
|
|
texture[i].resize(texWidth * texHeight); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
loadImage(texture[0], "pics/eagle.png"); |
|
|
|
loadImage(texture[0], "pics/tile16.png"); |
|
|
|
loadImage(texture[1], "pics/redbrick.png"); |
|
|
|
loadImage(texture[1], "pics/tile02.png"); |
|
|
|
loadImage(texture[2], "pics/purplestone.png"); |
|
|
|
loadImage(texture[2], "pics/tile03.png"); |
|
|
|
loadImage(texture[3], "pics/greystone.png"); |
|
|
|
loadImage(texture[3], "pics/tile32.png"); |
|
|
|
loadImage(texture[4], "pics/bluestone.png"); |
|
|
|
loadImage(texture[4], "pics/tile05.png"); |
|
|
|
loadImage(texture[5], "pics/mossy.png"); |
|
|
|
loadImage(texture[5], "pics/tile17.png"); |
|
|
|
loadImage(texture[6], "pics/wood.png"); |
|
|
|
loadImage(texture[6], "pics/tile10.png"); |
|
|
|
loadImage(texture[7], "pics/colorstone.png"); |
|
|
|
loadImage(texture[7], "pics/tile01.png"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void draw_sfml_rect(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, uint8_t color) { |
|
|
|
void draw_sfml_rect(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, uint8_t color) { |
|
|
@ -274,7 +274,6 @@ void ray_casting(sf::RenderWindow &window, Matrix& map) { |
|
|
|
double texPos = (drawStart - PITCH - h / 2 + lineHeight / 2) * step; |
|
|
|
double texPos = (drawStart - PITCH - h / 2 + lineHeight / 2) * step; |
|
|
|
|
|
|
|
|
|
|
|
for(int y = drawStart; y < drawEnd; y++) { |
|
|
|
for(int y = drawStart; y < drawEnd; y++) { |
|
|
|
// BUG? Why bitwise and here?
|
|
|
|
|
|
|
|
int texY = (int)texPos & (texHeight - 1); |
|
|
|
int texY = (int)texPos & (texHeight - 1); |
|
|
|
texPos += step; |
|
|
|
texPos += step; |
|
|
|
uint32_t color = texture[texNum][texHeight * texY + texX]; |
|
|
|
uint32_t color = texture[texNum][texHeight * texY + texX]; |
|
|
@ -315,9 +314,7 @@ void draw_ceiling_floor(sf::RenderWindow &window) { |
|
|
|
floorX += floorStepX; |
|
|
|
floorX += floorStepX; |
|
|
|
floorY += floorStepY; |
|
|
|
floorY += floorStepY; |
|
|
|
|
|
|
|
|
|
|
|
int checkerBoardPattern = int(cellX + cellY) & 1; |
|
|
|
int floorTexture = 3; |
|
|
|
int floorTexture = checkerBoardPattern == 0 ? 3 : 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ceilingTexture = 6; |
|
|
|
int ceilingTexture = 6; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t color; |
|
|
|
uint32_t color; |
|
|
|