Page 1 of 1

A question about doors

PostPosted: Fri Sep 17, 2010 5:59 pm
by olly2000
I try to create my first game with game editor and there 's one thing that I want to know: can I make a door without using the LoadVars variable. :?:
I don't want to use a lot of files.

Thank for answers

Re: A question about doors

PostPosted: Fri Sep 17, 2010 11:56 pm
by zxcvbnm
Yes you can make doors without using load vars. Do you have a demo of the project your working on ?

Re: A question about doors

PostPosted: Sat Sep 18, 2010 10:45 am
by savvy
what sort of door? ive never used loadvars for doors :S

Re: A question about doors

PostPosted: Sat Sep 18, 2010 6:14 pm
by DST
To make doors, is actually quite simple.

First you create the door, and start cloning it, then make a variable for player to enter door, and a variable to store the doornumber. Then arrange your doors so that they are sequential cloneindexes.
That is, door 0 and door 1 lead to each other, door 2 and door 3 lead to each other, etc. etc.

Player>Collision>Any Side>Door>
Code: Select all
doorvar=1;
doornum=collide.cloneindex;


player> collisionfinish>door>
Code: Select all
doorvar=0;


player>key down>up (or whatever key enters door){

Code: Select all
Actor*this;
int i;
int newdoornum;
if(doorvar==1){  //if player is touching a door
int i=doornum%2; //figure out even/odd door cloneindex
if(i==0){  //if door cloneindex is a multiple of 2 (0, 2, 4, 6, 8, etc etc)
newdoornum=doornum+1; }  //then get next door (0 leads to 1, 2 leads to 3)
else { //if door is not multiple of 2
newdoornum=doornum-1;} //then get previous door (1 leads to 0, 3 leads to 2)
this=getclone2("door", newdoornum);  //get the new door to warp to using getclone2
player.x=this->x;
player.y=this->y; //move to new door coordinates.
} //end if doorvar check.