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] 5 6 ... 63
46
Network / Re: Sending Custom Class by packet (to different program)
« on: December 07, 2021, 08:09:21 pm »
I don't really get it.

You overload >> and << for your Character class.
Inside these 2 functions is where you want to put/retrieve the data to/from the packet.
Then you simply send your Character john with
packet << john
and retrieve it with
Character john; // creates john
packet >> john; // fills john with data from the packet

You don't extract every data of your character individually (well you can, but what's the point) you directly extract a character and the overloaded >> operator function takes care of extracting the individual data.

47
General / Re: Font or Text render exception
« on: November 16, 2021, 09:54:51 pm »
Are you linking release libraries in debug mode? (linking sfml-graphics.lib instead of sfml-graphics-d.lib)

48
General / Re: Texture wont load
« on: October 30, 2021, 09:54:39 pm »
Your clear/draw/display NEEDS to be inside your main loop (the while (Window.isOpen()) loop)

49
You'd have to compute it yourself. Using cosine and sine. (Or maybe a lookup table if you only have a few fixed angles)

50
If you don't know what's happening, how could we? Maybe describe a little bit more your problem if you want people to help you...  ???
It doesn't even look like real code

51
Window / Re: will this random terrain generator work?
« on: October 10, 2021, 07:31:04 am »
It depends of your definition of "work" and since it's only a vague idea it will probably work

52
General / Re: i need help with sfml setup on code::block
« on: September 26, 2021, 03:22:42 pm »
https://www.sfml-dev.org/tutorials/2.5/start-cb.php
Don't forget to add the path to your lib and include directories

53
Graphics / Re: sf::RectangleShape.setFillColor() is not working
« on: September 25, 2021, 07:23:12 pm »
What do you mean "it doesn't work"?
You don't notice any visual color change?
The rectangle isn't displayed?
Are you sure your IsMouseOver function is correct and you enter the first part of your "if"?
The color in your printf is properly modified but you don't notice any visual color change?

54
Graphics / Re: Rendering quads show nothing if texture is ussed
« on: September 14, 2021, 01:58:16 am »
Don't set your vertex color to the default color constructor, it's black. Set it to white.
Or use the vertex constructor that only takes position and texture coordinates, its color will be white by default.

55
General / Re: Trouble with window resizing
« on: September 10, 2021, 05:53:48 am »
Not sure what you mean. The function takes a reference to a point. (references are an essential C++ concept)
sf::Vector2i mousePosition = sf::Mouse::getPosition(*this->window);
sf::Vector2f mouseCoords = this->window->mapPixelToCoords(mousePosition);
Then use the mouse coords to set the position of your player.

56
General / Re: Trouble with window resizing
« on: September 09, 2021, 09:49:56 am »
If your sf::View moves or isn't the same size as the window, then the pixel position of your mouse doesn't match anymore with the coordinates of entities inside your world.
You should use mapPixelToCoords to convert the position of your mouse to world coordinates.
(you may think you don't use any view, but there's always a default view)

57
Window / Re: Prolonged key press timeout
« on: August 30, 2021, 09:45:07 pm »
No, it's user preferences dependent. For example in windows 10:


You can disable key repeat with window.setKeyRepeatEnabled if you only want the first keypressed event.
Or you can set a boolean to true when the key pressed event is triggered and set it back to false when key released is triggered.
You can also always check the state of key with sf::Keyboard::isKeyPressed

58
Window / Re: How to move a rectangle with two clicks in SFML?
« on: August 30, 2021, 05:45:03 pm »
If you set mouse_pressed in your first if, and the condition of your second if is "mouse_pressed == true" then of course the condition will be verified immediately, use an "else if" ;)

59
Graphics / Re: Problems with menu.h
« on: August 16, 2021, 12:32:33 am »
There is no menu.h in SFML.

60
You can use atan2 to compute the angle of rotation between your (center) sprite and position of your mouse.
You can use a transform to rotate around a point.
Create a transform, rotate around the center of your  (center) sprite, use transformPoint to apply the rotation to the center of your revolving sprite. Then move your sprite to the resulting point.

Alternatively you could also compute the vector between your (center) sprite and mouse, normalize it, multiply it by the radius of your revolution, then add it to the center of your (center) sprite to get the position of your revolving sprite.

Pages: 1 2 3 [4] 5 6 ... 63