Help wit View

Game Editor comments and discussion.

Help wit View

Postby Setokyo » Sun Aug 08, 2010 2:05 pm

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
Laws control the lesser man. Right conduct controls the greater one

"I'd rather be hated for who I am than loved for who I am not
User avatar
Setokyo
 
Posts: 85
Joined: Fri Jul 09, 2010 1:52 am
Location: Holetown barbados
Score: 3 Give a positive score

Re: Help wit View

Postby DilloDude » Sun Aug 08, 2010 2:22 pm

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).
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Re: Help wit View

Postby lcl » Sun Aug 08, 2010 2:27 pm

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
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Help wit View

Postby Setokyo » Sun Aug 08, 2010 10:08 pm

Thank you very much
any more ideas?
Laws control the lesser man. Right conduct controls the greater one

"I'd rather be hated for who I am than loved for who I am not
User avatar
Setokyo
 
Posts: 85
Joined: Fri Jul 09, 2010 1:52 am
Location: Holetown barbados
Score: 3 Give a positive score

Re: Help wit View

Postby Game A Gogo » Mon Aug 09, 2010 12:07 am

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)
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Re: Help wit View

Postby Setokyo » Mon Aug 09, 2010 2:54 am

Thank you again
Laws control the lesser man. Right conduct controls the greater one

"I'd rather be hated for who I am than loved for who I am not
User avatar
Setokyo
 
Posts: 85
Joined: Fri Jul 09, 2010 1:52 am
Location: Holetown barbados
Score: 3 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron