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
Graphics / Re: Black line is not black
« on: May 27, 2023, 08:46:00 pm »
the problem is exactly antialiasing, i believe. a line is exactly 1 pixel wide. anything that tries to smooth it will end up mixing a perfect black with anything close to it. thats the point of antialiasing, mixing and blending colors to make things smooth.

2
Graphics / Re: Access To Default Font.
« on: April 15, 2023, 01:15:52 pm »
if the doc are outdated, probably you're reading from version 1.6 or something like that, when default fonts were a thing

now you need to load a font to use text. some years ago I asked about what to do if users deleted font files (and you couldn't display an error text because you wouldn't have a font), and it was suggested to load a font from memory. its a good approach.

EDIT: here it is:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Font.php#abf2f8d6de31eb4e1db02e061c323e346

more details here:
https://stackoverflow.com/questions/17406710/how-to-integrate-hardcode-a-font-file-into-my-program

basically you put a font in that program from deadnote site (actually there are tons of apps that do that. it's nothing special). it will give you an array, you put that array in your code, and load it with the SFML function font.loadFromMemory(fontChar, fontSize)

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

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

5
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

6
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

7
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

8
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.

9
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

10
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

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

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

13
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

14
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.

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

Pages: [1] 2 3 ... 25