How do you make the map rotate instead of the player?

S

sloodger

Guest
Goooooood afternoon! I'm here trying to make a topdown shooter where rather than the character rotating in endless circles, he stays facing up and the ground beneath him rotates, using 8 directions with his movements. I've been looking all over the place for a good couple hours, any suggestions?
 

Xer0botXer0

Senpai
Based on my half assed attempt at understanding how to do this, you should consider the dimensions( x/width/y/height) of your game world within a room, then you want the room to be large enough to simulate rotation of your game world else the corners will get cut.

And then I'm not sure if this is possible or not but using draw_surface_ext you could draw the application surface and rotate it.
That's one idea, if that doesn't work then you could create a sprite from the application surface then draw the sprite and rotate that

But my best guess is using a combination of point_direction and length_dirx/y and vk_left/vk_right to move objects around you like a clock.
 
S

sloodger

Guest
Based on my half assed attempt at understanding how to do this, you should consider the dimensions( x/width/y/height) of your game world within a room, then you want the room to be large enough to simulate rotation of your game world else the corners will get cut.

And then I'm not sure if this is possible or not but using draw_surface_ext you could draw the application surface and rotate it.
That's one idea, if that doesn't work then you could create a sprite from the application surface then draw the sprite and rotate that

But my best guess is using a combination of point_direction and length_dirx/y and vk_left/vk_right to move objects around you like a clock.
my knowledge of this program is slim to none. the only issue I'm having, is that there are objects within the room that I need to move with the room. would the code for the rotation of the room be virtually the same if added to the objects?
 

Xer0botXer0

Senpai
Regarding rotating the view, that means the whole game view will rotate the same as rotating your monitor, from what I understand you want the view to rotate around your player so you'd have to counteract it by changing your player objects image_angle in the opposite direction.

The alternative method with rotating objects around your character would have a higher cpu load. And your background wont rotate with it.
 
S

sloodger

Guest
Regarding rotating the view, that means the whole game view will rotate the same as rotating your monitor, from what I understand you want the view to rotate around your player so you'd have to counteract it by changing your player objects image_angle in the opposite direction.

The alternative method with rotating objects around your character would have a higher cpu load. And your background wont rotate with it.
there has to be a way for me to snap the camera angle to the player so I don't have to go Tony Hawk Pro Skater 2 on other objects and animations code for rotation.
 
W

Wraithious

Guest
there has to be a way for me to snap the camera angle to the player so I don't have to go Tony Hawk Pro Skater 2 on other objects and animations code for rotation.
If your other objects don't move just put a check in the step event using
Code:
x= view_xview[ i ]+ theXValue;
y=view_yview[ i ]+ theYValue;
Or if they do move, use a movement format like
Code:
x= view_xview[ i ]+ theXValue;
theXValue+=hspeed;
y= view_xview[ i ]+ theyValue;
theyValue+=vspeed;
To get the non player objects to stay facing the correct image_angle you'd have to use some combination of the view_angle and the hspeed and vspeed variables and their resulting image_angle, not sure what the formula is for that but it shouldn't be too hard to come up with one.

EDIT:
I just messed around with this and you don't need to do anything with image_angle of non player objects if they aren't moving but you do if they are, so this is what I came up with inside a non player object
create event:
Code:
x=100;
y=100;
trackdir=0;
theXValue=100;
theYValue=100;
step event:
Code:
if(hspeed=0 && vspeed=0)
{x= view_xview[0]+ theXValue;
y=view_yview[0]+ theYValue;
}
if(hspeed !=0 || vspeed !=0)
{x= view_xview[0]+ theXValue;
theXValue+=hspeed;
y= view_xview[0]+ theYValue;
theYValue+=vspeed;
image_angle=view_angle-trackdir
}
if hspeed<0 && vspeed=0 trackdir=view_angle-180;
if hspeed>0 && vspeed=0 trackdir=view_angle;
if hspeed=0 && vspeed<0 trackdir=view_angle-90;
if hspeed=0 && vspeed>0 trackdir=view_angle-270;
if hspeed<0 && vspeed<0 trackdir=view_angle-135;
if hspeed<0 && vspeed>0 trackdir=view_angle-225;
if hspeed>0 && vspeed<0 trackdir=view_angle-45;
if hspeed>0 && vspeed>0 trackdir=view_angle-315;

if( !keyboard_check(ord('A')) && !keyboard_check(ord('W')) && !keyboard_check(ord('S')) && !keyboard_check(ord('D'))){hspeed=0;vspeed=0;} 
if keyboard_check(ord('A')) hspeed=-5;
if keyboard_check(ord('W')) vspeed=-5;
if keyboard_check(ord('S')) vspeed=5;
if keyboard_check(ord('D')) hspeed=5;
if keyboard_check(vk_left) view_angle+=1;
if view_angle>359 view_angle=0;
if keyboard_check(vk_right) view_angle-=1;
if view_angle<0 view_angle=359;
 
Last edited by a moderator:
Top