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 - TheUselessGuy

Pages: [1]
1
Graphics / Rendering multiple sprites at once (white square problem)
« on: November 14, 2020, 04:50:49 am »
Hello today I was trying to create class that can create and render multiple objects. Unfortunately when I run my program I'm getting only white square.

main.cpp

#include "SFML/Graphics.hpp"

#include "Icons.hpp"

using namespace sf;
int main() {
        Icons icons;

        Event event;
        RenderWindow window(VideoMode(1280,720), "Test", Style::Close);

        while (window.isOpen()) {
                while (window.pollEvent(event)) {
                        switch (event.type) {
                        case Event::Closed: { window.close(); }
                        }
                }

                window.clear();
                window.draw(icons);
                window.display();
        }
        return EXIT_SUCCESS;
}

Icon.hpp

#pragma once
#include "SFML/Graphics.hpp"
#include <string>

class Icon{
public:
        sf::Texture texture;
        sf::Sprite sprite;
        Icon(std::string path) {
                texture.loadFromFile(path);
                sprite.setTexture(texture);
        }
};

Icons.hpp

#pragma once
#include "SFML/Graphics.hpp"
#include <vector>

#include "Icon.hpp"

class Icons : public sf::Drawable {
        std::vector<Icon> icons;
public:
        Icons() {
                icons.push_back(Icon("test.png"));
        }
private:
        virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const {
                for (const auto & icon : icons) {
                        target.draw(icon.sprite);
                }
        }
};

I'm out of ideas hope someone can help me. Btw I will appreciate any tips cuz I'm still learning how to program :-\

2
General / Pathfinding script
« on: October 24, 2020, 04:22:48 am »
Hello.
Few days ago I tried to create pathfinding script for my game. I wasn't able to find any sfml tutorials for it and every another tutorial made it more confusing. Unfortunetly every single script I have created didn't work properly. At this point in time I surrender. Does anyone here know some good tutorial for sfml pathfinding or have script with good explenation for it?

Pages: [1]
anything