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

Pages: [1]
1
Graphics / Re: How to change view based on mouse position?
« on: December 20, 2016, 05:29:21 pm »
If the latter, you get the difference between the current mouse position and the centre, then you can use that amount to offset the current view centre (move the view). This difference can be multiplied to scale the amount you want it to affect the speed. You could also use a specific view for this - one with a lower range. Then use this view to find the mouse position. This can reduce the need for scaling the result. If this view's centre is at zero, there would also be no need for any "difference" calculations.
I wanted it to move similar to the way you explained it, except I want the view to move at the same speed regardless of the amount of distance between the cursor and the circle, similar to a game like "agar.io". Can you maybe give to me an example of this to get started? :'(

2
Graphics / Re: How to change view based on mouse position?
« on: December 20, 2016, 01:16:35 am »
Try setting the circle's position to the view's centre after you've correctly set the view's centre. ;)
I tried this, but now it does the same thing as before, just moving the view around super quick. Is there a way to fix this? Here is a copy of my messy code so you can test it out for yourself; if you press the mouse then it will show the coordinates.
(click to show/hide)

3
Graphics / How to change view based on mouse position?
« on: December 19, 2016, 10:41:12 pm »
I want to make a circle always in the middle of the window, but I want the view to change based on the mouse position. For example, if I move the cursor above the circle, the view will change, but the circle will still be fixed in the middle of the window.

                sf::Vector2i pixelPos = sf::Mouse::getPosition(window);
                sf::Vector2f worldPos = window.mapPixelToCoords(pixelPos);

                playerCircle.setPosition(view.getCenter());
                view.setCenter(worldPos);
 
I tried this, but it doesn't work

4
Graphics / Re: How to make a vector of circles?
« on: December 18, 2016, 09:07:29 pm »
Oh, OK. Thanks

5
Graphics / How to make a vector of circles?
« on: December 18, 2016, 08:46:49 pm »
I'm trying to make a game in which a bunch of circles spawn and the "player" needs to eat them up. I figured that the best way to do this would be by using a vector, instead of defining them all individually. How do I do this?

I know that I need to do something like this:
        vector<sf::CircleShape> circles;
        circles.resize(10);

How do I add new circles in it, though; and how do I set the properties of the circles

Pages: [1]