Got rid of the wolf3d textures and now using 256px textures that are open source. Added a simple portal that can go on the floor.

master
Zed A. Shaw 2 months ago
parent e3596aeaa2
commit 75a33084f8
  1. BIN
      pics/barrel.png
  2. BIN
      pics/bluestone.png
  3. BIN
      pics/chess.png
  4. BIN
      pics/colorstone.png
  5. BIN
      pics/eagle.png
  6. BIN
      pics/greenlight.png
  7. BIN
      pics/greystone.png
  8. BIN
      pics/mossy.png
  9. BIN
      pics/pillar.png
  10. BIN
      pics/portal.png
  11. BIN
      pics/purplestone.png
  12. BIN
      pics/redbrick.png
  13. BIN
      pics/teleporter.png
  14. BIN
      pics/wood.png
  15. 45
      sfmlcaster.cpp

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

@ -11,23 +11,22 @@
using matrix::Matrix;
using namespace fmt;
#define texWidth 64 // must be power of two
#define texHeight 64 // must be power of two
#define texWidth 256 // must be power of two
#define texHeight 256 // must be power of two
#define numSprites 3
#define numSprites 1
#define numTextures 11
struct Sprite {
double x;
double y;
double elevation;
int texture;
};
//parameters for scaling and moving the sprites
#define uDiv 1
#define vDiv 1
#define vMove 0.0
const int RAY_VIEW_WIDTH=1280;
const int RAY_VIEW_HEIGHT=720;
@ -75,9 +74,9 @@ double planeY = 0.66;
#define gray_color(c) rgba_color(c, c, c, 255)
Sprite SPRITE[numSprites] = {
{3.0, 4.5, 8},
{3.4, 1.95, 9},
{7.34, 5.5, 10}
{4.0, 3.55, 0, 8},
// {3.4, 1.95, 9},
// {7.34, 5.5, 10}
};
double ZBuffer[RAY_VIEW_WIDTH];
@ -107,18 +106,15 @@ void load_textures() {
texture[i].resize(texWidth * texHeight);
}
loadImage(texture[0], "pics/eagle.png");
loadImage(texture[1], "pics/redbrick.png");
loadImage(texture[2], "pics/purplestone.png");
loadImage(texture[3], "pics/greystone.png");
loadImage(texture[4], "pics/bluestone.png");
loadImage(texture[5], "pics/mossy.png");
loadImage(texture[6], "pics/wood.png");
loadImage(texture[7], "pics/colorstone.png");
loadImage(texture[8], "pics/barrel.png");
loadImage(texture[9], "pics/pillar.png");
loadImage(texture[10], "pics/greenlight.png");
loadImage(texture[0], "pics/tile16.png");
loadImage(texture[1], "pics/tile02.png");
loadImage(texture[2], "pics/tile03.png");
loadImage(texture[3], "pics/tile32.png");
loadImage(texture[4], "pics/tile05.png");
loadImage(texture[5], "pics/tile17.png");
loadImage(texture[6], "pics/tile10.png");
loadImage(texture[7], "pics/tile01.png");
loadImage(texture[8], "pics/portal.png");
}
void draw_sfml_rect(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, uint8_t color) {
@ -318,9 +314,10 @@ void ray_casting(sf::RenderWindow &window, Matrix& map) {
// after sorting the sprites, do the projection
for(int i = 0; i < numSprites; i++) {
int sprite_index = spriteOrder[i];
double spriteX = SPRITE[sprite_index].x - posX;
double spriteY = SPRITE[sprite_index].y - posY;
int sprite_texture_number = SPRITE[sprite_index].texture;
Sprite& sprite_rec = SPRITE[sprite_index];
double spriteX = sprite_rec.x - posX;
double spriteY = sprite_rec.y - posY;
int sprite_texture_number = sprite_rec.texture;
auto sprite_texture = texture[sprite_texture_number];
//transform sprite with the inverse camera matrix
@ -337,7 +334,7 @@ void ray_casting(sf::RenderWindow &window, Matrix& map) {
int spriteScreenX = int((w / 2) * (1 + transformX / transformY));
int vMoveScreen = int(vMove / transformY);
int vMoveScreen = int(sprite_rec.elevation * -1 / transformY);
// calculate the height of the sprite on screen
//using "transformY" instead of the real distance prevents fisheye

Loading…
Cancel
Save