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

Pages: [1] 2 3 ... 25
1
Window / Re: Not clearing window
« on: March 25, 2023, 03:04:03 am »
what is happening is that you're actually not optimizing it  ;D
modern video cards are able (and made to) handle constant clearing/drawing, so don't be afraid to do that. SFML is built with this concept in mind, but unfortunately I personally don't know the exact techical reasons.

2
General / Re: Whats wrong with my collision detection?
« on: March 24, 2023, 08:59:37 pm »
what do you mean by "its not working"? what happens?
where do you handle collision? what should be colliding?

3
General / Re: White square issue
« on: March 19, 2023, 07:48:07 pm »
this piece of code is too small to know for sure the problem, but my guess is that you are executing it from inside a function, right? if so, the texture is deleted when the function ends, and the sprite loses reference to it.
you need to keep the texture alive. maybe show a bit more of this class code can help

4
General / Re: Jittery movement
« on: March 18, 2023, 11:06:06 pm »
ops, I forgot to tell you to move that line outside the event loop. but you did it yourdelf, so i'm glad it worked  ;D

5
Graphics / Re: Changing vertices
« on: March 17, 2023, 03:01:21 pm »
'line' is an array, so you access its elements by using its indexes. line[0] and line[1], in this case.
inside each element, you made a sf::Vertex. you can access its 'position' and then its 'x' and 'y' values.
so, to change them, you should use something like this:
line[0].position.x = 100;
or, if you want to change the vertex position in one line:
line[0].position = sf::Vector2f(100, 100);

You can create function that takes two vectors as parameters which are start and end of the line.
Then simply pass sf::Vertex array with vertices constructed from provided start and end positions to window's draw method

void draw_line(const sf::Vector2f& a, const sf::Vector2f&b)
{
    sf::Vertex line[]=
        {
            sf::Vertex(a),
            sf::Vertex(b)
        };

    window.draw(line ... )
}
draw_line(sf::Vector2f(0, 0), sf::Vector2f(10, 10));
 

the problem in this case is that you would be creating the line every iteration. may not be much for lines, but for most cases you create shapes and/or sprites just once and then, each iteration, just draw them.
and also the function is missing a reference to the window  ;D

6
Graphics / Re: Keeping the sf::View inside of the map
« on: March 09, 2023, 11:43:55 am »
If I understand correctly what you want, you just need to check if the view corners are outside your map coordinates. we don't have a function to get view corners, so you can use the view center minus (or plus) half of its size, both in the X and in the Y coordinates.

//after this line:
player_view.setCenter(position);
//add:
sf::Vector2f map_start(0, 0); //here im setting the map to start at the (0,0) coord
sf::Vector2f map_end(100, 100); //and to end at the (100, 100) coord

//first, in the X axis:

//you check if the view center minus half of the view size is a number smaller than the map default coordinates. if it is, set it to said coordinate.
if (player_view.getCenter().x - player_view.getSize().x/2 < map_start.x) {
  player_view.setCenter(map_start.x +player_view.getSize().x/2 , player_view.getCenter().y);
}
//if its not below the minimum, it could be above the maximum:
else if (player_view.getCenter().x + player_view.getSize().x/2 > map_end.x) {
  player_view.setCenter(map_end.x - player_view.getSize().x/2, player_view.getCenter().y);
}

//then you do the same for the Y axis.
 


EDIT: there are other ways to do it. you could check if the player is in the correct bounds for the view to follow him, and only then use player_view.setCenter(position);
but the way above should work well.

7
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 27, 2023, 12:43:31 pm »
thats it, we're officially in linker errors now.
first you could try setting SFML_STATIC, as in the tutorials (I believe its the standard for Windows users)

EDIT: oh wait, did it work then?   ;D

8
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 09:05:49 pm »
wow, i see one thing that is wrong. in your search directories, remove the trailing backslash
i.e. change C:\SFML\2.5.1\include\ for C:\SFML\2.5.1\include
(do it for linker and include)

in your linker settings, keep just this:
sfml-graphics-d
sfml-window-d
sfml-system-d

9
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 08:42:55 pm »
it seems right to me... are you using SFML_STATIC?

10
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 07:21:24 pm »
hmm... have you tried building SFML from source?

which SFML version did you download?

and what CodeBlocks version did you download? is it the one that includes MinGW for default?

11
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 06:19:43 pm »
yes, it may be related to incompatible compiled sfml and the compiler you are using.
lets see what G++ compiler you have. open the Windows prompt (cmd) and type g++ -v or g++ --version

12
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 06:01:49 pm »
try removing the audio libs from the linker settings for now. they are not in the right order anyway (the sfml-audio should be on top of window and system; order matters in this case). remove sfml-audio and the openall.dll and testing it again.

13
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 05:33:35 pm »
when that happens, in the tabs in the bottom of Code Blocks you have one called 'build messages'. what is in it?

14
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 05:07:21 pm »
your code is getting to the point it returns 0. i cant be sure in the video, but didn't you typed
while (window.isOpen())}
instead of
while (window.isOpen()){
?
EDIT: NVM, its right. the video quality was confusing me about it.


try changing libsfml-graphics-d for sfml-graphics-d (and also do it for window, audio, and system) in linker settings.

15
General / Re: Fresh Start II / Application Window Doesn't Launch
« on: February 26, 2023, 01:06:21 pm »
doesn't seems to be a big deal. take some printscreens to help finding the problem:
1- your folder containing the lib files
2- in project Build Options, print of "compiler settings", "linker settings", and "search directories"

Pages: [1] 2 3 ... 25