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

Pages: 1 ... 3 4 [5]
61
Graphics / Re: Do these three features exist?
« on: March 25, 2020, 01:49:49 am »
An easy way to do this is with a matrix:
let's say you have a center of rotation, C, and an angle of rotation, A.
your shape is made of a bunch of little shapes - you can just apply this transformation to each one.
let's say your shape's vertices are {(x,y), (x1, y1), (x2,y2)}
create a new shape with vertices at {(x-C, y-C), (x1-C, y1-C), (x2-C, y2-C)}
apply the 2D rotation matrix (oh boy how do I format this):
[cos(A)     -sin(A)]
[sin(A)      cos(A)]
to each one of the new shape's vertices and then just add C back to each one.

Apply this to every one of your shapes and they will rotate exactly!

Hello, sorry i am trying to use this only today (i have been busy),
Whay do you mean by the 2D rotation matrix?
Yoo described three vertices and then showed a matrix containing 4 operations,
I see on the documentation : https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Transformable.php
only one 2 rotation functions : setRotation (float angle) and rotate (float angle), both have only one argument. Could you expand please?
If anyone has the answer, feel free.. since A_Sentient_Tomato is nota regular user he might not see this.

(Remember i know some math but mostly i am a free c++ learner.)

62
Graphics / Re: Do these three features exist?
« on: March 25, 2020, 01:44:46 am »
Some community members have written libraries for certain things.

Thor: https://bromeon.ch/libraries/thor/
SelbaWard: https://github.com/Hapaxia/SelbaWard/wiki
Plinth: https://github.com/Hapaxia/Plinth
RichText: https://github.com/skyrpex/RichText
ImGui-SFML: https://github.com/eliasdaler/imgui-sfml

If you google a bit, you can find lots of related code.
It's really great to all this to dive in. SFML is really great.

63
It's there:

     union
     {
         SizeEvent             size;              
         KeyEvent              key;              
         TextEvent             text;              
         MouseMoveEvent        mouseMove;        
         MouseButtonEvent      mouseButton;      
         MouseWheelEvent       mouseWheel;        
         MouseWheelScrollEvent mouseWheelScroll;  
         JoystickMoveEvent     joystickMove;      
         JoystickButtonEvent   joystickButton;    
         JoystickConnectEvent  joystickConnect;  
         TouchEvent            touch;            
         SensorEvent           sensor;            
     };

An instance of the MouseWheelScrollEvent structure, and member of the sf::Event type.

Above is an anonymous union, in case you want to read more about that kind of structure.

Thank you.

64
General / How to be more efficient and faster in coding?
« on: March 16, 2020, 11:37:14 am »
Hello,
Since the coronavirus outbreak, and even before, i tried to spend some time to try to make my first game, and  it made me realize that i had to relearn all of SFML through tutorials since i am pretty new to SFML and the only free courses i took on SFML were not enough to cover everything.

But i find myself very slooww, what i thought finishing in one night, i found myself doing it in many days.

I tried to ask myself the question, how to get things done and be efficient in coding and code learning? i tried to see my patterns and see what "distracted" me.

I am curious about your experiences and your solutions. How do you learn a new langage fast? How do you code and focus and get things done fast with no distractions? What's your best and more efficient methods.

Thanks,
P~

65
SFML wiki / Confusion while Reading the documentation on : Events
« on: March 09, 2020, 07:59:52 pm »
Hello,

(I am still new to c++, but i made quite lot of progress, i am not a computer science student although.)

I have a question that could appear "non intelligent" but it kinda confused me. Here it is:
While using the "window" module, its functions were easy to use and pretty straighforward (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Window.php)
The "Public Member Functions" section contains all the functions at one glance, for instance i can use window1.isOpen() if i created and object called window1 from the classe Window.

But then i went to the event page (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Event.php)
because i wanted to check an example that i had read from here : https://www.sfml-dev.org/tutorials/2.5/window-events.php which is below:
         
  if (event.type == sf::Event::MouseWheelScrolled)

 {
 if (event.mouseWheelScroll.wheel == sf::Mouse::VerticalWheel)
   cout << "wheel type: vertical" << endl;
else if (event.mouseWheelScroll.wheel == sf::Mouse::HorizontalWheel)
 cout << "wheel type: horizontal" << endl;
else
 cout << "wheel type: unknown" << endl;
 cout << "wheel movement: " << event.mouseWheelScroll.delta << endl; // this line
 cout << "mouse x: " << event.mouseWheelScroll.x << endl;
   cout << "mouse y: " << event.mouseWheelScroll.y << endl;
                }
I got confused when i read this part "  event.mouseWheelScroll.delta",

What is : "mouseWheelScroll"?
It can neither be found on the classes section of the Event pages nor the public types, i can see it on the public Attributes somehow.
Checking the Event.hpp page : https://www.sfml-dev.org/documentation/2.5.1/Event_8hpp_source.php, i don't find "mouseWheelScroll", only "MouseWheelScrollEvent" and "MouseWheelEvent" which are different from "mouseWheelScroll".
As for the "delta" in "event.mouseWheelScroll.delta" no confusion, it's one of variables of the structures i found on the "Event.hpp" page.

Sorry if the answer is obvious, maybe i miss something in c++ that i still need to learn. If yes, please do enlighten me.
Thank you

66
Graphics / Re: Do these three features exist?
« on: March 08, 2020, 09:52:59 pm »
An easy way to do this is with a matrix:
let's say you have a center of rotation, C, and an angle of rotation, A.
your shape is made of a bunch of little shapes - you can just apply this transformation to each one.
let's say your shape's vertices are {(x,y), (x1, y1), (x2,y2)}
create a new shape with vertices at {(x-C, y-C), (x1-C, y1-C), (x2-C, y2-C)}
apply the 2D rotation matrix (oh boy how do I format this):
[cos(A)     -sin(A)]
[sin(A)      cos(A)]
to each one of the new shape's vertices and then just add C back to each one.

Apply this to every one of your shapes and they will rotate exactly!
Amazing. I am going to try this then, i hope it works.

If u want to move multiple items together, just have all the related items stored somewhere, and when moving one of them, move everyone. The same for rotation. I think I know what u mean that the shape after rotation is not the right one. It has to do with rotation origin. If I'm not wrong, SFML allows u to set origins outside of sprite boundaries, which means u need to set child items origins to the main one. If SFML doesn't allow it, but I doubt, after every rotation u have to reposition the items (which probably is what Sentinent said)
Yes as i am just learning SFML, i did not know about these details.
Thank you
I might give an update when i do it.

67
Graphics / Re: Do these three features exist?
« on: March 08, 2020, 07:27:02 pm »
This is what i was going for before making this thread, i wanted to make the item shown in my profile picture, and make it :
1) Rotate
2) Make the item not like a full rectangle, it means its boundaries must be like the picture

So i thought about making multiple little rectangle/triangles and bind them to make the item, but then how can i rotate all the binded items at once without losing exact shape of the item, this is where i am stuck right now.

68
Graphics / Re: Do these three features exist?
« on: March 08, 2020, 07:09:59 pm »
I did not know about 2dBox. Thanks

I understand,

question for you though, is there a place/list somewhere where people share their more complexe functions/objects made with simpler SFML functions?

Not that i don't want to try making my own more complicated fonctions it's part of the fun of course.

69
Graphics / Re: Do these three features exist?
« on: March 08, 2020, 01:14:33 pm »
Hi,
1) Yes that's i thought, so every item i draw will be a rectangle, i wondered with there was a program that could transform any drawing, by looking at the pixels valors (0 or different from 0), into a script describing multiple items (triangles and rectangles) that form in the end one final complicated item similar to the one i draw in paint.

2) Fx8qkaoy, well i wanted to make it happen inside the program, let's say we have an item that collects other items, first item can be moved using keyboard, other items cant, until they are touched by first item, first item becomes bigger  and thus the played can now move first item+ new item attached to it.
That was the plan.

3) Yes i see, thank you.

I am just starting SFML after folowwing a tutorial, but i realise a lot of research and experimentation has to be done. It's great to have this anyways.
I am prety sure there is still a lot i don't know

70
Graphics / Do these three features exist? [Solved]
« on: March 08, 2020, 08:42:14 am »
Hello,
I was very exciting to discover SFML and the world of programming,
Now i have few quick questions if someone expert knows the answer

1) Is it possible to draw an object (with paint) and use some kind of tool/programm to transform it into a real in game item with the exact shape you have drawn?  (meaning the item will have the collision area you have drawn)

2) Is there a function to merge items/objects into 1 item? (example : 2 circles meet each other (one circle hits the other), resulting in making one single item with a shapre of "8")

3) Is it possible to give an item, let's say a rectangle, 4 different kind of interactions with other items depending on which side of the rectangle was hit by another item? (So if a user rotated the rectangle to make it hit with the side number 2 or 3, the result would change, my question is, can SFML differenciate between the 4 sides of the rectangle?)

Thank you
And a have a good day
P-

Pages: 1 ... 3 4 [5]