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

Pages: [1]
1
Graphics / Re: [SOLVED] White square problem using vector<Texture>
« on: September 27, 2017, 12:34:25 pm »
I'm an idiot, the texture manager was in the wrong scope so the textures got deleted.

2
Graphics / [SOLVED] White square problem using vector<Texture>
« on: September 27, 2017, 12:33:20 pm »
Hi guys,
I've attempted to make a TextureManager class, which loads and stores the textures in a std::vector, however for some reason drawing the textures makes a white square.

Here's the code:

TextureManager
(click to show/hide)

Tile
(click to show/hide)

I use tile.draw(window); and it just makes white squares.
Does the vector change the memory location or something?

3
General / Re: Undefine reference to loadFromFile
« on: September 13, 2017, 05:10:37 pm »
Codeblocks was using the old compiler somewhere in my computer, instead of the compiler in the codeblocks folder.

Sorry...


4
General / Re: Undefine reference to loadFromFile
« on: September 12, 2017, 07:59:50 pm »
Here they are

5
General / Re: Undefine reference to loadFromFile
« on: September 12, 2017, 07:28:20 pm »
@eXpl0it3r:
1. The time dates and sizes are exactly same, so yes.

2. I'd say Dynamid as I have DLL (Dynamically Linked Libraries) in my project files.


6
General / [Solved] Undefine reference to loadFromFile
« on: September 12, 2017, 06:17:57 pm »
Hi guys,
I've tried displaying text or textures on the screen, but it just doesn't work, and when I try I get the following erorr:
||=== Build: Debug in SFMLLOADTEST (compiler: GNU GCC Compiler) ===|
obj\Debug\Source\main.o||In function `main':|
D:\C++\Projects\New folder\Source\main.cpp|13|undefined reference to `_imp___ZN2sf4Font12loadFromFileERKSs'|
||error: ld returned 1 exit status|
||=== Build failed: 2 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

I've reinstalled the correct version of MinGW and SFML already, and checked that they are the correct ones.
But still no success.

Building my own SFML was even worse.

How could I make this work?

I am using Codeblocks, running Windows 64bit, building for 32bit.
SFML version 2.4.2 and MinGW is 6.1.0 (checked with ./gcc.exe -v)

7
In the code you show you are not positioning the tiles so they are all drawn in the same place. The tile that is visible is not necessarily the same one that is modified when clicking.
Thank you very much.

8
Hello,
I've made it so that when I click, I get the closest Tile and use
sf::Color prev = Tile.getFillColor();
Tile.setFillColor(sf::Color(prev.r, prev.g + 32, prev.b, 255));
When printing this using cout, it changes when I click, however, visually nothing happens.
Here is the code snippet:
#include <SFML/Graphics.hpp>

#include <iostream>

using std::vector;
using std::cout;
using std::string;

string nl = "\n";

class Tile : public sf::Drawable
{
        public:
                sf::RectangleShape shape;
                bool canMove;

                Tile(sf::RectangleShape rect, bool can = true) : shape(rect), canMove(can)
                {

                }

        private:
                virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
                {
                        target.draw(shape);

                }
};

int main()
{

        sf::RectangleShape defaultShape(sf::Vector2f(16, 16));
        Tile defaultTile(defaultShape);

        vector<vector<Tile>> tiles(40, vector<Tile>(40, defaultTile));

        sf::RenderWindow window(sf::VideoMode(640, 640), "SFML works!");
        window.setFramerateLimit(30);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
            if(event.type == sf::Event::MouseButtonPressed)
            {
                sf::Vector2i pixel = sf::Mouse::getPosition(window);
                sf::Vector2f world = window.mapPixelToCoords(pixel);
                int tileX = (int) world.x/16;
                int tileY = (int) world.y / 16;
                sf::Color color = tiles[tileX][tileY].shape.getFillColor();
                tiles[tileX][tileY].shape.setFillColor(sf::Color(color.r, color.g + 32, color.b, 255));
                cout << (int) tiles[tileX][tileY].shape.getFillColor().g << nl;
            }
                }
        window.clear(sf::Color::White);

                for(uint32_t x = 0; x < tiles.size(); x++)
                {
                        for(uint32_t y = 0; y < tiles.size(); y++)
                        {
                                window.draw(tiles[x][y]);
                        }
                }

                window.display();
        }

        return 0;
}
 
As you can see, in the console it prints different values per click, but it stays the same on the screen.

Pages: [1]
anything