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] Help with Room 2 room  (Read 1497 times)

0 Members and 1 Guest are viewing this topic.
[Request] Help with Room 2 room
« on: August 09, 2008, 04:07:57 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 262
I was wondering, we always see engines using several objects for moving between rooms. Some engine even have an object for each different transition. Now I was not planning to use such an amount of objects. I have a very clear idea to do it with 1 object, unfortunatley I don't exactly know how to do it. 
In the next part I will try to explain what I would like to accomplish:

Lets take a random amount of rooms like 30, arranged in 5 rows of 6 rooms.
Each room has the same size.
Each room is named with a number in the end counting from left to right.

The room transition object checks if the player object is :

for moving right a room: between the correct y values and past a certain x value
for moving left a room: between the correct y values and for a certain x value
for moving up a room: between the correct x values and below a certain y value
for moving down a room: between the correct x values and above a certain y value

If the player objects gets at one of those positons the transiton object:

for right: counts up 1 value
for left: counts down 1 value
for up: counts down 6 values
for down: counts up 6 values

Then it moves you the the room corresponding with the just newly calculated value.

How am I to code such an engine? If possible I would like to see a detailed explanation.
Does not have to be an engine, but an example would be appriciated.
« Last Edit: August 11, 2008, 02:55:47 pm by Atomicd1 »
Logged
Re: [Request] Help with Room 2 room
« Reply #1 on: August 12, 2008, 04:24:43 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 262
isn't there anyone feeling like helping me with this? :'(
Logged

Xiphirx

wat
Re: [Request] Help with Room 2 room
« Reply #2 on: August 12, 2008, 07:55:13 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Ok, this is really easy, but please note that I havent used GM in a WHILE...

anyway, here is how it would go.

so basically you have a layout like this
Code: [Select]

R1,  R2,  R3,  R4,  R5,  R6
R7,  R8,  R9,  R10, R11, R12
R13, R14, R15, R16, R17, R18
R19, R20, R21, R22, R23, R24
R25, R26, R27, R28, R29, R30

R stands for a room...

anyway, lets say that we start in room 1 (Top left):

in the room creation code, make it set a global value called global.roomnum to 1
that will indicate that you are indeed in the top left corner

for every other room do the same with room 2, 3, 4, 5...

now in the step event, make a simple script that detects if the player is in one of the designated areas.
example
Code: [Select]

if player.x > 0 && player.x < 20 {
global.leaving = up; // store the direction where the player is going to leave in a variable, this will be used later on.
}

so now
with the players trigger event (when it detects and stores the above variable, make it excecute a script, the script is below
(this is psuedo mostly so don't copy and paste ; D)
Code: [Select]
// ok so the first and foremost thing you want to do is switch on the global roomnum:
switch (global.roomnum) {
case 1: //room 1 (look at diagram)
switch (global.leaving) {
case "top":
// nothing, there is no room on top of this. this is room 1, top left.
case "bottom":
// do a little math
global.roomnum += 6 // this will lead to room 7 : D
global.newx = //set a new x coordinate for the player
global.newy = //set a new y coordinate for the player
case "right":
// do a little math
global.roomnum +=1 // this will lead to room 2
global.newx = //set a new x coordinate for the player
global.newy = //set a new y coordinate for the player
case "left":
// nothing, can't go left.
}
}

go to room global.room num
player.x = global.newx;
player.y = global.newy;
[code]

There is some nasty code that I wrote up in a few minutes... ; D


Good luck.

[/code]
Logged
  • For The Swarm
Re: [Request] Help with Room 2 room
« Reply #3 on: August 15, 2008, 08:47:44 pm »
  • *
  • Reputation: +3/-0
  • Offline Offline
  • Gender: Male
  • Posts: 262
Yes, this I can use, it gives me an idea about how to get things done. However, I do believe that last part can be done more efficiënt and that is what my goal shall be. ( For my overworld is not 30 rooms, but over 200 rooms )  But thank you for the scripts, at least now I know where to start with this.

Logged

Xiphirx

wat
Re: [Request] Help with Room 2 room
« Reply #4 on: August 15, 2008, 09:45:38 pm »
  • Xiphirx
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 3007
Yes, this I can use, it gives me an idea about how to get things done. However, I do believe that last part can be done more efficiënt and that is what my goal shall be. ( For my overworld is not 30 rooms, but over 200 rooms )  But thank you for the scripts, at least now I know where to start with this.



You are welcome, I only answered the length of the question.
Logged
  • For The Swarm
Re: [Request] Help with Room 2 room
« Reply #5 on: August 17, 2008, 10:43:54 am »
  • The Dark Lord is here...
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 29
In fact it is pretty easy:
Let's say you have a variable with the current room number called global.roomnum. Then, when the event it's triggered:
Code: [Select]
var oldnum;
oldnum = global.roomnum;

if (is_moving_to_left) //you state the condition as I don't know how you do it
{
  global.roomnum -= 1;
}

if (is_moving_to_right)
{
  global.roomnum += 1;
}

if (is_moving_down)
{
  global.roomnum += 6;
}

if (is_moving_up)
{
  global.roomnum -= 6;
}

if (max(1, global.roomnum, min(30, global.roomnum)) == global.roomnum)
{
  execute_string("room_goto(room" + string(roomnum) + ")");
}
else
{
  with (o_player)
  {
    x = xprevious;
    y = yprevious;
  }
  global.roomnum = oldnum;
}
Logged
Darth RPG - Feel Dark Side temptation

  • The Legend of Cerda Website
Pages: [1]   Go Up

 


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



Page created in 0.027 seconds with 49 queries.