• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows Odd Camera movement

S

Silt

Guest
I am trying to program a top-down 2D game, where the camera is always facing the same way the player is (up). You move with W and S (increcing and decrecing velocity), and rotate with A and D, if I rotate while moving, my obj_player goes further away from the center and starts rotating around it. When I reset the speed with space it goes back to normal.

Code:
x = 512;
y = 640;
direction = 270

Code:
//movement
if (keyboard_check(ord("D")))
{
    direction -= 4;
}
if (keyboard_check(ord("A")))
{
    direction += 4;
}
if (keyboard_check(ord("W")))
{
    speed -= 1;
}
if (keyboard_check(ord("S")))
{
    speed += 1;
}
image_angle = direction

//Camera
camera_set_view_pos(view_camera[0],x-512,y-384+speed);   //Center the Player
view_set_camera(0,view_camera[0]);
camera_set_view_size(view_camera[0],1024,720);
camera_set_view_target(view_camera[0],-1);
camera_set_view_speed(view_camera[0],-1,-1);
camera_set_view_border(view_camera[0],32,32);
camera_set_view_angle(view_camera[0],-image_angle-90);

//debug
if (keyboard_check_pressed(vk_space))
{
    speed = 0;
}

Thanks for any help or advice you can give me, I'm still pretty new. : )
 
Top