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

Pages: [1] 2
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 / Re: How to measure which border will the ray "hit"
« on: September 27, 2017, 03:11:43 pm »
IF i know which side it hits calculating where it hits is really simple so i jest need to know which side

3
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?

4
General / Re: Problem with linking
« on: November 05, 2016, 11:31:43 pm »
refresh
something is seriously bad
when i run game in dynamic linking mode, everything is fine
when i run in static, things mess up, this is kind of big project which i started on linux and everything was fine, now on static linking things just mess up (wrong sprite is drown and things like this)

5
General / Re: Problem with linking
« on: November 05, 2016, 11:11:23 pm »
uh, i link them statically and i get error that libopenal32.dll is missing
what the actuall hell

6
General / Re: Problem with linking
« on: November 05, 2016, 11:00:38 pm »
still getting erros :/

7
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

8
General / Re: Problem with moving several object
« on: October 30, 2016, 07:07:03 pm »
If this d help i have reproduced the error with as small code as possible
Code: [Select]
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
using namespace sf;
int main() {
    Clock zegar;
    Time time;
    RenderWindow okno( VideoMode( 800, 600 ), "test" );
    RectangleShape pasek[ 20 ];
    int siz = 600 / 40;
    for( int i = 0; i < 20; i++ ) {
        pasek[ i ].setSize( sf::Vector2f( 6, siz ) );
        pasek[ i ].setFillColor( sf::Color( 255, 255, 255 ) );
    }
    for( int i = 0; i < 20; i++ ) {
        pasek[ i ].setPosition( 0, siz * 2 * i );
    }
    int temp;
    int speed = 100;
    while( okno.isOpen() ) {
        time = zegar.restart();
        for( int i = 0; i < 20; i++ ) {
            pasek[ i ].move( sf::Vector2f( 0, speed * time.asSeconds() ) );
            if( pasek[ i ].getPosition().y > siz * 40 )
                 pasek[ i ].setPosition( 0, 0 - siz );
           
        }
        okno.clear();
        temp = 800 * 0.4;
        for( int i = 0; i < 20; i++ ) {
            pasek[ i ].setPosition( temp, pasek[ i ].getPosition().y );
            okno.draw( pasek[ i ] );
        }
        temp = 800 * 0.6;
        for( int i = 0; i < 20; i++ ) {
            pasek[ i ].setPosition( temp, pasek[ i ].getPosition().y );
            okno.draw( pasek[ i ] );
        }
        okno.display();
    }
}

9
General / Re: Problem with moving several object
« on: October 30, 2016, 12:47:21 pm »
sadly the gap appears instantly so i guess it is not caused by wrong replacing of position, also i have noticed one strange thing
if i place the move method at the start of while window is open the gap seems smaller (but is  still there)
if i place it right after window.clear gap is bigger, maybe that is somehow connected with the problem

10
General / Re: Problem with moving several object
« on: October 28, 2016, 11:12:40 pm »
bump

11
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)

12
General / Re: How to properly resize sf::Rectangleshape
« on: July 06, 2016, 08:49:31 pm »
you mean like static_cast<texture.getsize().x>(float)?

(It works when i changed the order just asking how should i cast it)

13
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

14
General / Re: Displaying text previously get by winapi [crash]
« on: June 21, 2016, 12:35:54 pm »
thanks a lot!
it works
i kinda noticed c_str() is the problem here but i hat no idea how to get through it without using this method.

15
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?

Pages: [1] 2
anything