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

Pages: 1 [2] 3 4 ... 63
16
Graphics / Re: Can't load texture from file
« on: April 30, 2023, 09:57:37 pm »
Trash symbol in the console when you load a texture is most likely that you're mixing release library with debug compilation. (or vice versa)

If you want to compile in release mode, use the release version of the lib (sfml-graphics etc.)
If you want to compile in debug mode, use the debug version of the lib (sfml-graphics-d etc.)
As written in the VS tutorial

17
Graphics / Re: Access To Default Font.
« on: April 15, 2023, 12:12:36 pm »
There isn't any default font in SFML.

18
General discussions / Re: Taking On the Role As BDFL
« on: April 13, 2023, 11:18:04 pm »
Congrats... I guess?  :D

19
Audio / Re: Sound playing the moment the key is pressed
« on: March 13, 2023, 11:44:27 pm »
...restarts it from beginning if it was it already playing
Don't call play() if it's already playing, you won't hear anything if you restart the sound every frame.

May want to use an event like the KeyPressed Event instead.

20
Of course it depends on what computer runs the program. ;)

21
General / Re: Loading new images into textures causes strange effects.
« on: February 28, 2023, 10:22:48 am »
I'm not sure because I've never replaced a texture this way. I think it may be because the initial TextureRect of your sprite is set to 650 650 when you call the first setTexture and you never change it despite loading a new texture to the same variable.
Maybe try using setTextureRect with the size of your new texture after you load a new one, or call setTexture with your new texture and the resetRect argument set to true after you load a new one

22
General / Re: Changing the name variable in a loop for
« on: February 13, 2023, 11:20:59 am »
From the link above
passing a window bigger than the texture will lead to an undefined behavior
This function does nothing if either the texture or the window was not previously created
Use create to create a texture of the correct size.

23
Only use the .key.code value of your event when it is relevant: after you have checked that your event type is KeyPressed or KeyReleased, like in the tutorial.

If you don't use curly brackets around your if, only the first instruction following the if will be dependent of the result of your condition.
if (event.key.code == 100)
     accelRight = true;
     std::cout << "accelRight is now true";
This thing you wrote is equivalent to:
if (event.key.code == 100) {
     accelRight = true;
}
std::cout << "accelRight is now true";
Your std::cout will always be called, whether the if is true or false...


if (sf::Event::KeyReleased)
This doesn't mean anything  ??? It's literally like if (6) or whatever the value of the KeyReleased enum is.

24
Graphics / Re: Convert mouse coordinates to world coordinates.
« on: October 25, 2022, 10:46:50 pm »
If you want to convert your mouse position (in pixels) into coordinates in your game world then it's mapPixelToCoords.

As you can see in the documentation it is not a static function, you have to call that method on an instance of RenderTarget.
You have to pass a Vector2i (it will be passed as a reference, don't try nonsensical things like Position2&) to that function, and the sf::View (not a RenderWindow) you want to convert your position in (you may (or will, eventually) have multiple sf::View). If you don't pass an sf::View then it will use the current view of your window, which may be ok.
Note that it returns a Vector2f (floats), not a Vector2i (ints), so if you store the result in an sf::Vector2i you may lose precision.

There is an example of what you're trying to do at the end of the view tutorial.

25
System / Re: joystick detection
« on: October 17, 2022, 01:35:01 am »
Probably because you're not flushing your output.
End your cout with << std::flush or << std::endl (endl outputs a newline and flushes)

26
System / Re: joystick detection
« on: October 17, 2022, 12:24:19 am »
Hey
Unlike the keyboard or mouse, the state of joysticks is sometimes not directly available (depending on the OS), therefore an update() function must be called in order to update the current state of joysticks. When you have a window with event handling, this is done automatically, you don't need to call anything. But if you have no window, or if you want to check joysticks state before creating one, you must call sf::Joystick::update explicitly.
Try calling sf::Joystick::update() once before querying the states of your joysticks.

By the way, all sf::Joystick functions are static, you don't have to (and probably shouldn't) instantiate one.

27
Graphics / Re: Check collisions on certain part sf::RectangleShape
« on: October 15, 2022, 04:25:04 pm »
Hey.

Not necessarily an exact answer to your question, but I'd compute the position of the middle of the paddle, the position of the center of the ball, the distance between the two (= how far from the middle it hit), then react according to the ratio "length from the middle" / "half length of the paddle"

28
General discussions / Re: New game development ...
« on: October 07, 2022, 09:25:23 pm »
What does SSI mean?

29
Window / Re: Problem with mouse position
« on: August 26, 2022, 07:28:17 pm »
Your cursor has a position in pixels, relative to the screen or the window. Entities inside your game have coordinates in "world units".
If you want to convert your mouse position in pixels to its corresponding coordinates in the game world, use the mapPixelsToCoords function
https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#coordinates-conversions

30
General / Re: How do i read keyboard keys for every kind of keyboard?
« on: August 15, 2022, 02:32:12 am »
Text editor? Probably want to use the sf::TextEntered event instead, it is made to read text input.

Pages: 1 [2] 3 4 ... 63
anything