I didn't like the current one so I editted it a lot.
And now I cannot help myself posting my version up here...
I made my script compatible with every kind of aspect ratio.
It doesn't matter what the room width and height are, this will work.
I've also declared a couple of new variables so the script doesn't look difficult.
Don't pay attention to them. And don't pay attention to anything beneath it.
Just pay attention to the variables minzoom and maxzoom.
Oh, and change objects player1 and player2 to what you like.
minzoom=1 // sets the minimal zoom
maxzoom=2.5 // sets the maximal zoom
min_wview=room_width/maxzoom // sets the minimal width of the view
min_hview=room_height/maxzoom // sets the minimal height of the view
max_wview=room_width/minzoom // sets the maximal width of the view
max_hview=room_height/minzoom // sets the maximal height of the view
// calculates the size and position of the view
xdistance=point_distance(player1.x,0,player2.x,0)
ydistance=point_distance(0,player1.y,0,player2.y)
if xdistance/room_width>ydistance/room_height {
view_wview[0]=xdistance+room_width/4
if view_wview[0]<min_wview {view_wview[0]=min_wview}
if view_wview[0]>max_wview {view_wview[0]=max_wview}
view_hview[0]=view_wview[0]/room_width*room_height
}
else {
view_hview[0]=ydistance+room_height/4
if view_hview[0]<min_hview {view_hview[0]=min_hview}
if view_hview[0]>max_hview {view_hview[0]=max_hview}
view_wview[0]=view_hview[0]/room_height*room_width
}
view_xview[0]=(player1.x+player2.x)/2-view_wview[0]/2
view_yview[0]=(player1.y+player2.y)/2-view_hview[0]/2
// keeps the view inside the room
if view_xview[0]+view_wview[0]>room_width {
view_xview[0]=room_width-view_wview[0]
}
if view_yview[0]+view_hview[0]>room_height {
view_yview[0]=room_height-view_hview[0]
}
if view_xview[0]<0 {
view_xview[0]=0
}
if view_yview[0]<0 {
view_yview[0]=0
}












