• 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!

GameMaker Cameras

K

Kyle Rider

Guest
Hey all another question for you.

Regarding camera Borders. If I go through the trouble of making my own cameras, can I set the vertical borders differently on the top and bottom?

For example, I would like the camera to move if my player is 80 px from the bottom of the screen and 200 from the top.

Any help?

Thanks again.
 
P

PhenomenalDev

Guest
You would have to make a custom border code so that's gonna be hard I have no clue how you would go about that though.
 
K

Kyle Rider

Guest
I don't think it is too hard, just asking if it is possible. I will invest the time into it.
 
A

amusudan

Guest
It's possible, and not complicated at all. But I am not using GMS 2 so hopefully someone who does comes along and points you in the right direction :)
 
K

Kyle Rider

Guest
Well a lot of code from GMS1 works in GMS 2. Want to point me in the right direction?
 
A

amusudan

Guest
Well a lot of code from GMS1 works in GMS 2. Want to point me in the right direction?
I'm not sure how much views have changed in GMS2, but you'd just have a bunch of if statements checking wether the player has moved past the border and then moving the camera until the player is in the screen again.

So something like this (this would work for GMS1):
b_top = 200; //top border
b_horizontal = 50; //horizontal borders (left and right)
b_bottom = 80; //bottom border

if(player.x < view_xview + b_horizontal)
{
view_xview = player.x - b_horizontal;
}else if(player.x > view_xview + view_wview - b_horizontal)
{
view_xview = player.x - view_wview + b_horizontal;
}

if(player.y < view_yview + b_top)
{
view_yview = player.y - b_top);
}

if(player.y > view_yview + view_hview - b_bottom)
{
view_yview = player.y - view_hview + b_bottom);
}
 
Top