# demon

Member Since 27 May 2007
Offline Last Active Mar 10 2013 04:32 AM

### In Topic: Rotating The World Around The Center Of The Room

01 March 2013 - 08:11 AM

```if (keyboard_check(vk_up))
{
x+=lengthdir_x(spd,player.direction-180);
y+=lengthdir_y(spd,player.direction-180);
}

if (keyboard_check(vk_right) or keyboard_check(vk_left))
{
var angle,X,Y,C,S;
angle = (keyboard_check(vk_left)-keyboard_check(vk_right))*rotspd;
image_angle+=angle;
angle*=pi/180;

C = cos(angle);
S =-sin(angle);
X = x - player.x;
Y = y - player.y;
x=player.x + X*C - Y*S;
y=player.y + X*S + Y*C;
}```

Ah got it working thanks to both of you! All glory to the math god. Here is an example of the code in use if anyone else wants to use it.

### In Topic: Rotating The World Around The Center Of The Room

28 February 2013 - 05:26 AM

```x+=lengthdir_x(spd,player.direction-180);
y+=lengthdir_y(spd,player.direction-180);```
To orbit, I think it'll be something like this:
```if (keyboard_check(vk_right) or keyboard_check(vk_left))
{
var dir,d;
dir=point_direction(player.x,player.y,x,y);
d=point_distance(player.x,player.y,x,y);
dir+=(keyboard_check(vk_left)-keyboard_check(vk_right))*rotspd;
x=o_player.x+lengthdir_x(d,dir);
y=o_player.y+lengthdir_y(d,dir);
}```

That is pretty much on track with what I was doing to solve this but it's not quite there.  Here is a gm81 file that I will show two example of what we have so far (Press the spacebar to switch between examples).  Example1 is the code BBGaming wrote and Example2 is what I want to combine with that.  In Example2 imagine the ship's image_angle is not rotating but instead the planet around the ship like in Example1.

### In Topic: Rotating The World Around The Center Of The Room

28 February 2013 - 04:21 AM

Not quite following what you're trying to do. The player has a direction it's facing, and the orbiting object moves in reference to that? Where does the center of the room come into play? Does the player move around the room?

The player doesn't actually move and is located in the room's center

### In Topic: Rotating The World Around The Center Of The Room

28 February 2013 - 04:19 AM

use lenghtdir_x and lenghtdir_y
:whistle:/>

I have really been struggling making the code to accomplish this.  It's on the tip of my tongue but I was hoping someone could write it out for me.

### In Topic: Add rotation to a sprite then scaling?

25 April 2012 - 08:25 PM

Or you can use transformations:

```d3d_transform_set_rotation_z(image_angle)