Page 1 of 1

Help wit View

PostPosted: Sun Aug 08, 2010 2:05 pm
by Setokyo
Hi all it's me gain
How to i get use the view wit not making it parent wit the player
any help on that
thanks

Re: Help wit View

PostPosted: Sun Aug 08, 2010 2:22 pm
by DilloDude
Just don't parent it to the player.
It has x, y, xvelocity and yvelocity just like any other actor. Just remember, it's "centre" is the top-left corner (like a region).

Re: Help wit View

PostPosted: Sun Aug 08, 2010 2:27 pm
by lcl
There is many ways to do it. :D

1. You can use function that I've made
Put the following code to Global Code, name it like View Moving, and then click add.
Code: Select all
void ViewFollowActor(char*name, int Fx, int Fy, int speed)
{
    Actor*actor=getclone(name);
    int X=view.width/2;
    int Y=view.height/2;
 
    if(x+X<actor->x-speed && actor->xscreen>xscreen+X+Fx)
    {
        x+=speed;
    }
    if(x+X>actor->x+speed && actor->xscreen<xscreen+X-Fx)
    {
        x-=speed;
    }
    if(y+Y<actor->y-speed && actor->yscreen>xscreen+Y+Fy)
    {
        y+=actor->yvelocity;
    }
    if(y+Y>actor->y+speed && actor->yscreen<xscreen+Y-Fy)
    {
        y-=speed;
    }
}


And then use it in view - draw actor - script editor:
Code: Select all
ViewFollowActor("Player", 50, 50, 5);

This means that view follows actor called Player if he is 50 pixels away from the middle of the screen in x axel and also in y axel.
And the last number is for how fast view will follow actor. Put in it the same value as your player runs. Y axel will follow automatically your
actors yvelocity.


2. You can use wire frame regions
Place wire frame regions like this and main actor in the middle of them:
Screen3.PNG

Make all regions as separate actors. Name them like: left, right, up, down.
Now go to main actor - collision - any side of - left - repeat: yes - script editor:
Code: Select all
view.x -= 5; //Change 5 to be same as the speed your main actor runs

Same for collision any side of right, but put in script editor:
Code: Select all
view.x +=5;

And for going up, ýou can use:
Code: Select all
view.y -= 5;

And for going down, 'cause we have gravity, use this:
Code: Select all
y += Player.yvelocity;


There is also other ways, but these are most simpliest to use. :D
Hope this helps! :D

Re: Help wit View

PostPosted: Sun Aug 08, 2010 10:08 pm
by Setokyo
Thank you very much
any more ideas?

Re: Help wit View

PostPosted: Mon Aug 09, 2010 12:07 am
by Game A Gogo
on your player's draw actor code:
Code: Select all
view.angle=direction(view.x+(view.width/2),view.y+(view.height/2),x,y);
view.directional_velocity=distance(view.x+(view.width/2),view.y+(view.height/2),x,y)/20;


Replace (view.width/2) and (view.height/2) with the actual number since these never change in game (So it's useless processing)

Re: Help wit View

PostPosted: Mon Aug 09, 2010 2:54 am
by Setokyo
Thank you again