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

Pages: [1]
1
Graphics / Re: Troubles with sf::renderTexture
« on: October 29, 2019, 11:04:48 am »
Thank You. You are just Amazing!!!

2
Graphics / Troubles with sf::renderTexture
« on: October 29, 2019, 09:17:58 am »
Shortly, I don't really understeand how does it works.

#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window(sf::VideoMode(600, 400), "Tilemap");

        sf::RenderTexture render;
        render.create(600, 400);
        sf::RectangleShape rect(sf::Vector2f(200,50));
        rect.setFillColor(sf::Color::Red);
        render.draw(rect);

        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();


                }
                window.clear(sf::Color::White);
                render.display();
               

                window.display();
               
        }

        return 0;
}
 

What I do wrong?

3
Graphics / Interface trouble
« on: October 21, 2019, 07:55:58 pm »
Ok, so... I have a small trouble with drawing of UI.
I have a map, a character etc... everything is working good. But I can't to draw anyting relative to the coordinates of the window. I need it to draw an interface.
( shortly... how to draw a rectangle it always would be located in the top left corner of the window?)



my main file

#include <SFML/Graphics.hpp>
#include "GraphicsLib.cpp"
#include "character.cpp"
#include <iostream>



int main()
{
        sf::RenderWindow window(sf::VideoMode(720, 480), "Tilemap");

        Hero hero;
        sf::View view;

        view.reset(sf::FloatRect(0, 0, 720, 480));
        TileMap map;

        map.load("testMap.txt");
        hero.setWayMap(map.wayMap, map.height, map.width);


        sf::RectangleShape r(sf::Vector2f(120.f, 50.f));
        r.setPosition(sf::Vector2f(10, 0));

       
       
        while (window.isOpen())
        {
                sf::Event event;
                while (window.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
               
                window.clear();


                window.draw(hero.sprite);
                window.draw(map);
                window.setView(view);
                window.draw(hero.sprite);
                view.setCenter(hero.sprite.getPosition().x + hero.img.getSize().x / 2, hero.sprite.getPosition().y + hero.img.getSize().y / 2);
                hero.move();


                window.draw(r);
                window.display();
        }

        return 0;
}
 

Pages: [1]