Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: Request: Zelda Room Changing  (Read 2213 times)

0 Members and 1 Guest are viewing this topic.
Request: Zelda Room Changing
« on: July 09, 2011, 11:42:22 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 5
Hi at First!
Im New to the Forum, it`s awsome ; )
I'm from Austria, so my main language is German, but i hope
my english is good enough to be readable XD

I'm an advanced GML Coder and have my own Zelda-Fangame in progress.
So if anyone does explain me only the idea for a solution for my problem,
i should be able to code that myself ; )

But at the moment im Stuck at one point: room changing and houses.
I do have solutions but i do not really like them...
So far, i solved it how to move to the next (correct) room if you leave the room to the left/right/top/bottom.
I do this by creating a array with lets say with a range of 3x3. in every field i do store the name of the room
which would be located there like on a physical map. so if my "map-coordinates" are 2,2 and i do leave the room
to the right the script increases the x coordinate to 3,2. then i can read out the room-destination out of my
predefined array. I also got it to work that Links-position is also taken correctly to the next room.
For going into/out of houses i was using "teleport-objects" which are invisble and placed in the doors.
if you collide with them, your are teleported to the room, where you should be. What i dont like is:
i do need to make for every house new teleport objects. this is so annoying.

I hope i could explain what im doing^^

So my questions are:
1) For general map changing on the field, what are your systems?
2) The point im totaly stuck: if i want to make houses, do i really need to make an collision/telport object for every house?
  Isn't there any, lets say, "more economic" way to do this?

with best regards
KillerLink
Logged

.

Re: Request: Zelda Room Changing
« Reply #1 on: July 10, 2011, 03:30:52 am »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Posts: 143
In the GM room editor, you can right-click on an instance (if it is a version below 8.1, you must hold control and right-click) and click on "Creation Code". This is a code to be performed in the create event of that particular instance of that object only. You can use it to set a variable such as "rm" to the desired room and you can then use "room_goto(rm)" in the collision event.
Logged
Re: Request: Zelda Room Changing
« Reply #2 on: July 10, 2011, 10:40:32 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 5
Hm, a good idea.
I think i will do this.
Thanks a lot, jimn346!
But i am still happy to recive other's opinions and advices ; )
Logged
Re: Request: Zelda Room Changing
« Reply #3 on: July 10, 2011, 11:07:49 am »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 262
For the overworld I use a simple system much like what you are using. I'm not using vieuws so each time a new background appears a new room is entered.

in each room create event I have a global that indicates the roomnum :
Code: [Select]
global.roomnum=83 // the room ID
My map is numbered 28 width, so if you go up or down it counts + or - 28 rooms.
going to left or right counts - or + 1 room. The information about my room2room object ( which has to be placed in each room ):

Code: [Select]
Information about object: obj_r2r
Sprite:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Mask:

Create Event:

execute code:

oldnum = global.roomnum;



Alarm Event for alarm 1:

execute code:


var oldnum;

if (max(1, global.roomnum, min(16, global.roomnum)) == global.roomnum)
{
with obj_link {visible=0}
  execute_string("room_goto(room" + string(global.roomnum) + ")");
}
else
{
  with (obj_link)
  {
    x = xprevious;
    y = yprevious;
  }
  global.roomnum = oldnum;
}


Step Event:

execute code:

var oldnum;

if (obj_link.x<1)
{
tr_set_transition(tr_create_right )
  global.roomnum -= 1;
  alarm[1]=1
  global.createlink_x=144
  global.createlink_y=obj_link.y
}

if (obj_link.x>145)
{
tr_set_transition(tr_create_left )
with obj_link { visible=0}
  global.roomnum += 1;
  alarm[1]=1
  global.createlink_x=1
  global.createlink_y=obj_link.y
}

if (obj_link.y>144)
{
tr_set_transition(tr_create_top )
  global.roomnum += 28;
  alarm[1]=1
  global.createlink_x=obj_link.x
  global.createlink_y=32
}

if (obj_link.y<31)
{
tr_set_transition(tr_create_bottom )
  global.roomnum -= 28;
  alarm[1]=1
  global.createlink_x=obj_link.x
  global.createlink_y=142
}





for going to houses and caves I only use 3 items, below is the information for one of them:
( all these 3 objects work the same, but I need 3 different ones because I have one room with 3 cave/house entrances. )

Code: [Select]
Information about object: obj_roomer2
Sprite: spr_roomer
Solid: false
Visible: false
Depth: 0
Persistent: false
Parent:
Mask:

Create Event:

execute code:

passive=1

Alarm Event for alarm 0:

execute code:

if global.roomnum=31
{
global.createlink_x=80
global.createlink_y=131
room_goto(room478)
}

if global.roomnum=58
{
global.createlink_x=79
global.createlink_y=133
room_goto(room506)
}

if global.roomnum=185
{
global.createlink_x=47
global.createlink_y=109
room_goto(room487)
}

if global.roomnum=314
{
global.createlink_x=72
global.createlink_y=139
room_goto(room592)
}

if global.roomnum=336
{
global.createlink_x=79
global.createlink_y=133
room_goto(room555)
}

if global.roomnum=394
{
global.createlink_x=72
global.createlink_y=139
room_goto(room594)
}

if global.roomnum=493
{
global.createlink_x=62
global.createlink_y=126
room_goto(room221)
}

if global.roomnum=535
{
global.createlink_x=96
global.createlink_y=108
room_goto(room590)
}

if global.roomnum=578
{
global.createlink_x=32
global.createlink_y=107
room_goto(room493)
}

if global.roomnum=300
{
global.createlink_x=115
global.createlink_y=50
room_goto(room462)
}

Collision Event with object obj_link:

execute code:

if passive=1
{
tr_set_transition(tr_fade_outin)
alarm[0]=1
with obj_r2r { instance_destroy() }
passive=0
}


Logged

.

Re: Request: Zelda Room Changing
« Reply #4 on: July 10, 2011, 05:16:33 pm »
  • *
  • Reputation: +1/-0
  • Offline Offline
  • Posts: 143
For the overworld, you could use a ds_list or ds_grid.
Logged
Re: Request: Zelda Room Changing
« Reply #5 on: July 11, 2011, 08:41:28 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 5
To Atomicd1:
To adress all rooms with on variable by counting left/right as +/- 1 and up/down as +/- map-width is pretty cool idea ; )
I wouldnt ever think so far ^^

I think im inspired by your advices now and will try to make it work ; )
Thanks alot!
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.052 seconds with 46 queries.