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

Pages: [1]
1
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 04:29:09 pm »
Well whatever, wether you like it or not I HAVEread the post that took you 3 posts to tell me which one it was... In all honesty, you never really tried to answer my original and only question, you only went on about the comma. So I'm not wasting any more time here, I'll move on to somewhere that actually utilises its responses with information that might actually be useful.


2
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 04:00:29 pm »
I didn't know which thread you meant because you didn't specify which once, hence creating unnesisary posts but nevermind.


sf::RectangleShape rec1(sf::Vector2f(20, 5));
 
rec1.setorigin(-100, -300);
rec1.setFillColor(sf::Color::Green);

While (window.isOpen())
{
...

window.clear(sf::Color::Cyan);

window.draw(rec1);
sf::Vector2i mousepos = sf::Mouse::getPosition(window);

...

if (mousepos.x == 550, mousepad.y == 300) //note that this seems to work fine with the comma
{
rec1.rotate(-0.5);
}

}









 

3
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 03:40:51 pm »
Sorry, I'm not sure what you mean by a "complete example". Do you mean of my code? To clarify, I would like to know how to set the origin of which the rotation uses.

4
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 03:07:38 pm »
I now understand that it rotates around the origin, but I already set the shape's origin. How do I set the origin for the rotation?

5
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 02:22:39 pm »
Oh, it was CodingMadeEasy (SFML, not C++) I was following, haha   ;D

My problem is that every time a shape in my game rotates, it also moves to the right slightly, which I don't want to happen. I have no idea why it does this. The shape has had the origin set outside of the while windowIsOpen loop, which isn't the problem. However every time it rotates (triggered by the mouse being on a position), it moves away from it's origin, I want it to stay there but rotate from the shape's center, if you see what I mean.

Edit: From what I can see, the entity rotates around a center (I may be wrong), how do I change it?

6
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 02:00:21 pm »
Well ok ok, I'll investigate that, but I was only following a video tutorial. But please explain how that is causing my entities to move each time?

7
Graphics / Re: Rotation keeps moving entity along X axis
« on: May 03, 2015, 01:47:00 pm »
But if I don't have the comma operator, it doesn't work?  :-\ I set the origin prior to the rotation, and also tried it after the rotation, to no avail.

8
Window / Re: AW: sf::Mouse::getPosition mis-understanding
« on: May 03, 2015, 01:40:52 pm »
Aha, why didn't I think of that xD
Maybe you need to read a bit further in your C++ book ;)

By the way, are you sure you want to check for equality with one position? Clicking a single pixel will be rather difficult and annoying for the user.

I'm still learning, It must of simply been a human error :P

9
Graphics / Rotation keeps moving entity along X axis
« on: May 03, 2015, 01:35:26 pm »
In my game, when the code to rotate a shape is triggered, it rotates a series of sprites. However, because in my game you need to rotate them a lot at the same rotation, each time they rotate the shapes move to the right slightly for no reason of which I can see. Is there a simple soloution to this? I tried to move them back on the x axis and did set position to each after the rotation, but it simply doesn't work and they still move each time. Have I made an obvious mistake?


if (mousepos.x == 550, mousepos.y == 300)
{
si1.rotate(0.1); //rotate the shape
si2.rotate(0.1); //^
si2.rotate(0.1); //^

}
//how do I stop them moving on the x axis each time the mouse gets to that point?



 

10
Window / Re: AW: sf::Mouse::getPosition mis-understanding
« on: May 03, 2015, 11:50:47 am »
You compare it with the comparison operator, that is: ==

Aha, why didn't I think of that xD Thanks

11
Graphics / Re: Sprite help
« on: May 03, 2015, 11:39:30 am »
Ok, I think I got it now thanks  ;)

12
Window / sf::Mouse::getPosition mis-understanding
« on: May 03, 2015, 11:35:59 am »
Hey, I'm making my first game with SFML, and for one part I need to rotate a sprite depending on the position of the mouse (local to window). The bit I dont quite understand is how you compare the position to another position, if ya get what I mean? I know what I have attempted below probablly doesn't make sense and is a bit random, but as I said this is my first game and I'm only a newbie.
sf::Vector2i mousepos = sf::Mouse::getPosition(window); // get the local position if the mouse

if (mousepos = (sf::Vector2i(-500, -100))
{
player.rotate(90);
}


 

13
Graphics / Sprite help
« on: May 03, 2015, 12:12:42 am »
I'm only a newbie, but how could I make a sprite 'jump', where when a key is pressed it goes up then down? I'm not sure how one would do this (maybe theres an obvious method :P). I tried this code but it didn't really work...

if (sf::Keyboard::isKeyPressed(sf::keyboard::Space))
{
sprite.move(0, -0.5);
Sleep(1000);
sprite.move(0, 0.5);
}




 
I know it's obvious what I tried to do wouldnt work, but I'm a bit stuck on this :-/

Pages: [1]
anything