sfml ray casting question texturing my walls

by jason12   Last Updated July 12, 2019 02:13 AM

I'm using SFML 2.4.1 or higher to build my raycaster fps game and I want to texture my walls instead of using the SFML Color class with RGB coloring to color the walls here is my code if you all need the rest of my code I can link it I've got my png images for texturing the walls.

here is pic example: enter image description here

My code here:

    sf::Color color;
        switch (worldMap[mapX][mapY])
        case 1:  color = sf::Color::Red;  break; //red
        case 2:  color = sf::Color::Green;  break; //green
        case 3:  color = sf::Color::Blue;   break; //blue
        case 4:  color = sf::Color::White;  break; //white
        default: color = sf::Color::Yellow; break; //yellow

        //give x and y sides different brightness
        if (side == 1) {
            color = sf::Color(color.r / 2, color.g / 2, color.b / 2);

        //draw the pixels of the stripe as a vertical line
        //verLine(x, drawStart, drawEnd, color);

        sf::Vertex line[2] =
                sf::Vertex(sf::Vector2f(x, drawStart), color),
                sf::Vertex(sf::Vector2f(x, drawEnd), color)
        window.draw(line, 2, sf::Lines);

Tags : sfml raycasting

Related Questions

How can I improve my ray casting algorithm

Updated February 20, 2016 01:05 AM

No RenderWindow class in SFML?

Updated May 04, 2015 21:05 PM

How to link sfml to code::blocks in ubuntu?

Updated June 06, 2015 01:05 AM