Page 1 of 1

sectors

PostPosted: Mon Feb 27, 2012 2:23 pm
by BogdansB
hi everybody,
I have a room in my game where a player is. the camera doesn't move.
how can i make, when the player goes to the right, at the and of the view, the view changes and the player seems to be left and there is another room.

Re: sectors

PostPosted: Mon Feb 27, 2012 3:47 pm
by Hblade
Like this:

Player - Draw Actor
Code: Select all
if(xscreen>(view.width)) {
    view.x+=(view.width);
}
if(xscreen<0) {
    view.x-=(view.width);
}
if(yscreen>(view.height)) {
    view.y+=(view.height);
}
if(yscreen<0) {
    view.y-=(view.height);
}










There is a much better way though, sky would know a way to shorten the code :P

Re: sectors

PostPosted: Mon Feb 27, 2012 5:39 pm
by BogdansB
wow thank you very much :D

Re: sectors

PostPosted: Mon Feb 27, 2012 5:47 pm
by Hblade
no prob :)

With this code, you dont have to change it if you change the views size.

Re: sectors

PostPosted: Tue Feb 28, 2012 4:22 am
by skydereign
You can use out of vision event instead of draw actor. Also you can do this if you want shorter.
Code: Select all
view.x += ((xscreen>view.width) - (xscreen<0))*view.width;
view.y += ((yscreen>view.height) - (yscreen<0))*view.height;

Re: sectors

PostPosted: Tue Feb 28, 2012 6:01 am
by BogdansB
thank you

Re: sectors

PostPosted: Tue Feb 28, 2012 9:14 am
by foleyjo
Be careful if you have some kind of score bar in your game as you may need to change the code slightly to account for it.