C
Ceymoonie
Guest
*way
I'm trying to use views of different sizes in my room, and smoothly zoom in on them.
Like this, but not instantaneous:
gif
My idea was to use stretched objects to mark the different views, like this:
But I only managed to make it kinda work when the player is moving forward:
gif
Using these codes:
oPlayer step event:
Script:
I really have no idea what to do next, can somebody please help me out?
I'm trying to use views of different sizes in my room, and smoothly zoom in on them.
Like this, but not instantaneous:
gif
My idea was to use stretched objects to mark the different views, like this:
But I only managed to make it kinda work when the player is moving forward:
gif
Using these codes:
oPlayer step event:
Code:
///Increase view.
var xdir=0,ydir=1,inview=0;
viewincrease=nearest_instance(oViewIncrease,96);
if instance_exists(viewincrease){
if viewincrease.x>view_xview{
xdir=1;}
if viewincrease.x<view_xview{
xdir=-1;}
if viewincrease.y>view_yview{
ydir=1;}
if viewincrease.y<view_yview{
ydir=-1;}
if (x>viewincrease.x && x<viewincrease.x+viewincrease.image_xscale*12 && y>viewincrease.y && y<viewincrease.y+viewincrease.image_yscale*12){
inview=1;}
else{
inview=0;}
if inview or !distance_to_point(viewincrease.x,y)>0{
goalhview+=(viewincrease.image_yscale*12-goalhview)*.1;
view_yview+=(viewincrease.y-view_yview)*.1;}
else if phy_position_x!=phy_position_xprevious or phy_position_y!=phy_position_yprevious{
goalhview+=(viewincrease.image_yscale*12-goalhview)*(1/(distance_to_point(viewincrease.x,y)))*xdir;
view_yview+=(viewincrease.y-view_yview)*(1/(distance_to_point(viewincrease.x,y)))*ydir;}
}
view_xview+=(oPlayer.x-view_xview-(view_wview/2))*.2;
view_hview+=(goalhview-view_hview)*.2;
view_wview=view_hview/0.5625;
Code:
///nearest_instance(object, max distance)
//returns the instance whose mask is closest to the mask of the object that calls this function, within the given distance
//returns noone if theres no instance within the given distance
var _smallest_distance = argument1;
var _nearest_instance = noone;
with argument0 {
var _dist = distance_to_object(other);
if _dist < _smallest_distance {
_smallest_distance = _dist;
_nearest_instance = id;
};
};
return _nearest_instance;
Last edited by a moderator: