Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bondrusiek

Pages: [1]
1
SFML projects / Re: Screenshot Thread
« on: November 14, 2024, 06:06:15 pm »
Analog Clock

Source code: https://gist.github.com/Przemekkkth/3a0c9acae9d8824780a7b9b7bb07fbe2

Additionally I created a function which use Bresenham's line algorithm and help drawing a line between two points with specified width and color:
int drawLine(sf::RenderWindow &window, sf::Vector2i point1, sf::Vector2i point2, int lineWidth, sf::Color lineColor)
{
    int x0 = point1.x;
    int y0 = point1.y;
    int x1 = point2.x;
    int y1 = point2.y;
    int dx = abs(x1 - x0);
    int sx, sy;
    if (x0 < x1) {
        sx = 1;
    }
    else {
        sx = -1;
    }

    int dy = -abs(y1 - y0);
    if (y0 < y1) {
        sy = 1;
    }
    else {
        sy = -1;
    }

    int err = dx + dy;

    while (true) {
        sf::RectangleShape rect(sf::Vector2f(lineWidth, lineWidth));
        rect.setFillColor(lineColor);
        rect.setPosition(x0, y0);
        window.draw(rect);
        if (x0 == x1 && y0 == y1) {
            break;
        }
        int e2 = 2 * err;

        if (e2 >= dy) {
            err += dy;
            x0 += sx;
        }

        if (e2 <= dx) {
            err += dx;
            y0 += sy;
        }
    }
}
 


2
Graphics / Re: How to draw a line between two points ?
« on: November 14, 2024, 05:42:44 pm »
Hi, I created a function which use Bresenham's line algorithm and help drawing a line between two points:
int drawLine(sf::RenderWindow &window, sf::Vector2i point1, sf::Vector2i point2, int lineWidth, sf::Color lineColor)
{
    int x0 = point1.x;
    int y0 = point1.y;
    int x1 = point2.x;
    int y1 = point2.y;
    int dx = abs(x1 - x0);
    int sx, sy;
    if (x0 < x1) {
        sx = 1;
    }
    else {
        sx = -1;
    }

    int dy = -abs(y1 - y0);
    if (y0 < y1) {
        sy = 1;
    }
    else {
        sy = -1;
    }

    int err = dx + dy;

    while (true) {
        sf::RectangleShape rect(sf::Vector2f(lineWidth, lineWidth));
        rect.setFillColor(lineColor);
        rect.setPosition(x0, y0);
        window.draw(rect);
        if (x0 == x1 && y0 == y1) {
            break;
        }
        int e2 = 2 * err;

        if (e2 >= dy) {
            err += dy;
            x0 += sx;
        }

        if (e2 <= dx) {
            err += dx;
            y0 += sy;
        }
    }
}
 

3
SFML projects / Re: Screenshot Thread
« on: July 20, 2024, 07:13:56 pm »
Hi,
I'vs created the Top Down Shooter game.



Source code
Best

4
SFML projects / Re: Screenshot Thread
« on: July 30, 2023, 10:32:27 am »
Hi,
I'vs created Star Pusher. Star Pusher is a Sokoban or “Box Pusher” clone. StartPusherSFML is "Star Pusher" clone written in SFML.



Source code
Best

5
SFML projects / Re: Screenshot Thread
« on: March 05, 2023, 03:24:09 pm »
Hi,
I'vs created next one game. This is Twini Golf



Source code: https://github.com/Przemekkkth/TwiniGolfSFML

6
SFML projects / Re: Screenshot Thread
« on: February 19, 2023, 10:51:26 am »
Hi,
I'vs created Polyomino. This is clone of tetris but you can choose 1,2,3,4,5 blocks.



Source code: https://github.com/Przemekkkth/PolyominoSFML

Pages: [1]