sectors

Game Editor comments and discussion.

sectors

Postby BogdansB » Mon Feb 27, 2012 2:23 pm

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.
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: sectors

Postby Hblade » Mon Feb 27, 2012 3:47 pm

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
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: sectors

Postby BogdansB » Mon Feb 27, 2012 5:39 pm

wow thank you very much :D
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: sectors

Postby Hblade » Mon Feb 27, 2012 5:47 pm

no prob :)

With this code, you dont have to change it if you change the views size.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: sectors

Postby skydereign » Tue Feb 28, 2012 4:22 am

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;
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: sectors

Postby BogdansB » Tue Feb 28, 2012 6:01 am

thank you
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: sectors

Postby foleyjo » Tue Feb 28, 2012 9:14 am

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.
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest