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

Pages: [1]
1
Window / Change the View without having the source instance?
« on: December 01, 2011, 04:23:05 pm »
Hey, thanks for your reply.
But how can I change it in SFML 2?
I have setup SFML 2 now, but I don´t get the view changed.

I tried the following:
Code: [Select]
((sf::View) App->GetView()).Zoom(1.5f);

//way number 2
sf::View View(App->GetView());
View.Zoom(1.5f);
App->SetView(View);


But boths methods are not working :(


EDIT: It was my fault. ;)
The second method is working. But my main-loop was resetting it always :D

Thanks for your help ;)

2
Window / Change the View without having the source instance?
« on: December 01, 2011, 02:54:36 pm »
Hello, I have a little poblem with zooming and moving the view.

Normally I would do the following:
Code: [Select]
sf::View CustomView;
App.SetView(CustomView);
CustomView.Zoom(1.5f);


But what if the current Class don´t knows the view?
Do i have to inject it?

I looked into RenderWindow and found the following:
GetView()
So I tried the following:
Code: [Select]
App->GetView().Zoom(1.5f);
But this gave me an error.
I also tried some casting:
Code: [Select]
((sf::View) App->GetView()).Zoom(1.5f);

This doesn´t produce a compiler error, but at runtime nothing happens.

Is there a way to get and change the current View?

Thanks in Advance,

Simon[/code]

3
General / Problem with moving/turning a sprite in cursor direction
« on: December 01, 2011, 02:23:51 pm »
Thanks for your reply :)

I think I remembered something wrong with the 45/PI :D

But PI/2 are working fine I think.

But there still seams to be a problem with the center wenn the Sprite changes his position.

I got the following code:

Code: [Select]
float dx = App->GetInput().GetMouseX() - (playerPos.x - player.GetCenter().x);
float dy =  App->GetInput().GetMouseY() - (playerPos.y - player.GetCenter().y);

angle = atan2(dy, dx) + (PI/2);

player.SetRotation(-angle * 180 / PI);


But dx and dy are 0 when the mouse is far away from the position of the sprite.
Where is my mistake?

I also uploaded a video again, where everyone can see, how far the position is away.


Hope someone can help me :)


Thanks,

Simon

4
General / Problem with moving/turning a sprite in cursor direction
« on: November 30, 2011, 10:44:47 pm »
Thanks for the reply :)
The 45/PI was for adding 90 degress to the angle. It was a quick and dirty hack i tried because the rotation of the sprite had a wrong offset  :D

And the center isn´t the spritepos always the upper left corner?
So with:
Code: [Select]
float dx = App->GetInput().GetMouseX() - playerPos.x;
I would just get the difference from the upper left corner to the cursor, but i want the center to move in the cursors direction.

I hope it was understandable and you can help me better now :)


Thanks,

Simon

5
General / Problem with moving/turning a sprite in cursor direction
« on: November 30, 2011, 09:54:09 pm »
Hello SFML-Communiy,
I have a problem which makes me go crazy.

I try to move and turn a sprite in the direction of the cursor.
But it isn´t working very well.
The turning is almost working. But when i start moving the sprite the turning fails. (I think the center is moving or something like that :()

The code for turning looks like the following:

Code: [Select]
float dx = App->GetInput().GetMouseX() - (playerPos.x - player.GetCenter().x);
float dy =  App->GetInput().GetMouseY() - (playerPos.y - player.GetCenter().y);

angle = atan2(dy, dx) + (45/PI);

player.SetRotation(-angle * 180 / PI );

This works not perfect, because for some reason the cursor is not in the middle of the sprite when I turn it to the left for example.


The code for the moving i use just looks like the following:
Code: [Select]
player.Move(-distance, 0);
So moving doesn´t do anything special yet.

The code I tried for moving in the cursor direction was the following:
Code: [Select]
float dY = sin(angle) * distance;
float dX = cos(angle) * distance;


this->player.Move(dX, dY);

where angle is the rotation of the player an distance the distance the sprite should move in the angle direction.

For a better understanding i also produced a little youtube video ;)




I hope very much that someone can help me.

Thanks in advance,

Simon

6
C / Any easy physics engine you can recommend me?
« on: November 30, 2011, 09:46:07 pm »
Thanks, I will look at it, when I am ready with the rest :D

7
C / Any easy physics engine you can recommend me?
« on: November 30, 2011, 03:55:56 pm »
Thanks for the recommendation. I am going to look at Box2D because I am programming in C++.
I didn´t saw a forum for C++ so I choose the C-Forum.
Is the big help section for C++?

Thanks ;)

Simon

8
C / Any easy physics engine you can recommend me?
« on: November 29, 2011, 09:38:20 pm »
Hello,
I wondered, wheather there is already an easy physics engine for 2d game programming. The best would be, if it already integrateds well with SFML.

It don´t have to be an full-featured engine.

It´s enough if it has some basic functionalities like collision detection and gravity.


Thanks in advance and sorry for my english, I´m from Germany ;)

Simon

Pages: [1]
anything