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.


Topics - Szustarol

Pages: [1]
1
General / Problem with drawing text from inherited class
« on: February 16, 2018, 02:28:41 pm »
Hello
this is my modified RectangleShape class:
(click to show/hide)
I have also modified RenderWindow class to draw it:
(click to show/hide)

Sadly, when I try to draw my ClickableButton, the Rectangleshape draws fine, but the text is not displayed. What could be the cause?
Font loads nice because other text displays just fine

2
General / How to measure which border will the ray "hit"
« on: September 26, 2017, 05:52:39 pm »
I think the image explains it all, Is it possible to measure which border will a ray "hit" if it was longer without using complex trigonometry?

3
General / Problem with linking
« on: November 05, 2016, 10:24:35 pm »
Hi!
On linux i just go -lsfml-<part> when i try to link something, on windows i did what is on screenshot, and i get
undefined reference to sf::err() linker errors
pic attached my linker list, Im not sure why it is not working

4
General / Problem with moving several object
« on: October 27, 2016, 07:24:48 pm »
Hi!
I want to make animated road using sfml, so I made objects that represent lines on the street.
There are 2 functions, init and move, while move is casted everytime, init is only used once.
These are the functions, along with function to draw them on window.
Code: [Select]
void lines::initialise(sf::RenderWindow &window){
    std::vector<sf::RectangleShape> temp;
    temp.resize(ammount);
    siz = window.getSize().y/40;
    for(int i = 0; i < ammount; i++){
        temp[i].setSize(sf::Vector2f(6, siz));
        temp[i].setFillColor(sf::Color(255,255,255));
    }
    for(int i = 0; i < ammount; i++){
        temp[i].setPosition(0, siz*2*i);
    }
    line = temp;
}

void lines::drawintargetwindow(sf::RenderWindow &window){
    int temp;
    temp = window.getSize().x*0.4-3;
    for(int i = 0; i < ammount; i++){
        line[i].setPosition(temp, line[i].getPosition().y);
        window.draw(line[i]);
    }
    temp = window.getSize().x*0.6-3;
    for(int i = 0; i < ammount; i++){
        line[i].setPosition(temp, line[i].getPosition().y);
        window.draw(line[i]);
    }
}

void lines::move(){
    time=clock.getElapsedTime();
    clock.restart();
    for(int i = 0; i < ammount; i++){
        line[i].move(sf::Vector2f(0, speed*time.asSeconds()));
        if(line[i].getPosition().y > siz*40)
            line[i].setPosition(0, 0-siz);
    }
}

so the problem is, there is a gap between these lines, screen will demonstrate, second attachement shows what happens if i comment out whole content of move function (while move is still called, it is just commented out so does nothing)

5
General / How to properly resize sf::Rectangleshape
« on: July 06, 2016, 07:42:25 pm »
Hi
I have a texture lets name it texutre one.
So texture one's resolution is 500x250
I also have a RectangleShape
I want to:
set the texture to Rectangle shape, then rotate it by 90 degrees
for example
XXXXXXXXX
XXXXXXXXX
XXXXXXXXX
to:
XXXX
XXXX
XXXX
XXXX
XXXX

thats kinda easy to do, i have a problem later

i want to set the width of already rotated Rectangleshape to 30% of the overall screen width which i something managed to do.
now the hardest part i dont know how to do (i tried every possilbe way i can think of)
i want to set the lenght (or actually the height of  already rotated element) so it keeps the proportion;
for example if texture is 500x250 the proportion is 2
so i want the lenght (height) of the shape to be 2 times longer than its width, of course these values change some texture can be 500x100, some can be 500x200
i have tried something like this
shape.setsize(texture.getsize().x/texture.getsize.()y*screenwidth*0.3, screenwidth*0.3);
but it doesnt work, im not sure why (the textures indeed show, but they are flattened)
can anyone explain why it is not working and give me a better idea?

The exact order of things being done is:
loadfile to texture
set texture to rectangleshape
set size of rectangleshape
set its origin (it has to be changed by its height because it will be rotated 90 degree and i want upper left corner be 0,0 not 0, -height)
set its position on screen (not mportant here i guess)
rotate it

6
General / Displaying text previously get by winapi [crash]
« on: June 21, 2016, 12:16:38 pm »
Hi i get a text from text field to wstring (text contains polish chars)
GetWindowTextW(g_name, (LPWSTR)g_namestr.c_str(), GetWindowTextLength(g_name) + 1);

sadly, this:
                  text.setString(g_namestr);
or this:
                  text.setString(g_namestr.c_str());

causes the app to crash.
I need it to be wide string (displaying polish chars is a must), i know i can manually set a wide string to text by
text.setString(L"Wide text");
but how do i do it with predefined text string?

7
General / Problem with a class with texture element
« on: June 02, 2016, 10:57:51 pm »
Hi!
I have a class like:
someclass name{
public:
 sf::Texture sometexture;
 sf::Sprite somesprite;
void settexture(){
somesprite.settexture(sometexture);
}
void loadtxt(std::string path){
sometexture.loadfromfile(path);
}
};

and then somewhere in code  i have;
std::vector <name> arrayofclasses;
...
arrayofclasses[i].loadtxt("Files/file.bmp");
arrayofclasses[i].settexture();
 
and i get compiler error:
'void sf::Shape::setTexture(const sf::Texture *,bool)': cannot convert argument 1 from 'sf::Texture' to 'const sf::Texture *'


ofc the code up there is just sample i wanted to explain what i have in a simple way, but it looks like this: array of classes, in one of them i want to set texture and then load them to sprite.

im using visual studio

why does it happen?
what is wrong?
would appreciate any help :)

Pages: [1]
anything