Velocity
Member
Hey,
So I made a fake 3D game - kinda like Pokemon Blue, and I'm TRYING to transition between rooms by colliding with an object at the edge of my ROOM. Um, I ALREADY made my character and movement, and a collision situation between the character's collision mask and a barrier object - just to STOP him when he gets to a wall. But then I followed both Shaun Spalding's Persistent Levels tutorial, and Beyond Us Games Transition Rooms tutorial, BOTH on YouTube, to try to make the character transition to another ROOM when colliding with a WARP object. But it's not WORKING.
I made the WARP object,
obj_warp
Then I made a CREATE event, and set three variables:
var targetX, targetY, targetRoom ;
Then I made a COLLISION event with my character, let's call him obj_player. And I set his next room x and y location and the room_goto () command with a targetRoom variable.
obj_player.x = targetX ;
obj_player.y = targetY ;
room_goto(targetRoom) ;
Then I put the warp object along the top EDGE of the room, making sure it was actually IN the room, and covering the WHOLE top of the level. The width of the room is 880 and the HEIGHT is 1244. And then I double clicked the INSTANCE and clicked on Creation Code, and put in the FOLLOWING
targetX = 440 ;
targetY = 646 ;
targetRoom = room_2;
I made it so as not to transition back over the NEXT warp object, that I put at the BOTTOM of the NEXT room. The NEXT room is IDENTICAL to room_1. The PROPER targetY position should be WAY closer to the BOTTOM of the screen, but I'll set that later.
So for the warp object instance at the bottom of room_2, the Creation Code, is:
targetX = 440 ;
targetY = 640 ;
targetRoom = room_1;
And in my Player movement. I have obj_player. With a Collision mask, spr_collision_mask. With a Create Event, and the following code:
image_speed = 0;
image_index = 0;
Then I have a STEP event, with the following code:
image_speed = 0;
if(keyboard_check(ord("W"))){
if(!position_meeting(x,y-1,obj_barrier))
y-=1;
sprite_index = spr_player_up;
image_speed = .2;
key_up = true;
}
if(keyboard_check(ord("A"))){
if(!position_meeting(x-2,y,obj_barrier))
x-=2;
sprite_index = spr_player_left;
image_speed = .2;
key_left = true;
}
if(keyboard_check(ord("S"))){
if(!position_meeting(x,y+1,obj_barrier))
y+=1;
sprite_index = spr_player_down;
image_speed = .2;
key_down = true;
}
if(keyboard_check(ord("D"))){
if(!position_meeting(x+2,y,obj_barrier))
x+=2;
sprite_index = spr_player_right;
image_speed = .2;
key_right = true;
}
if(image_speed = 0)
{
image_index = 0
}
depth = -y;
So BASICALLY, the whole WARP function, or transitioning between rooms ISN'T working for me. If you could help me figure out how to transition rooms that would be great.
Thanks.
So I made a fake 3D game - kinda like Pokemon Blue, and I'm TRYING to transition between rooms by colliding with an object at the edge of my ROOM. Um, I ALREADY made my character and movement, and a collision situation between the character's collision mask and a barrier object - just to STOP him when he gets to a wall. But then I followed both Shaun Spalding's Persistent Levels tutorial, and Beyond Us Games Transition Rooms tutorial, BOTH on YouTube, to try to make the character transition to another ROOM when colliding with a WARP object. But it's not WORKING.
I made the WARP object,
obj_warp
Then I made a CREATE event, and set three variables:
var targetX, targetY, targetRoom ;
Then I made a COLLISION event with my character, let's call him obj_player. And I set his next room x and y location and the room_goto () command with a targetRoom variable.
obj_player.x = targetX ;
obj_player.y = targetY ;
room_goto(targetRoom) ;
Then I put the warp object along the top EDGE of the room, making sure it was actually IN the room, and covering the WHOLE top of the level. The width of the room is 880 and the HEIGHT is 1244. And then I double clicked the INSTANCE and clicked on Creation Code, and put in the FOLLOWING
targetX = 440 ;
targetY = 646 ;
targetRoom = room_2;
I made it so as not to transition back over the NEXT warp object, that I put at the BOTTOM of the NEXT room. The NEXT room is IDENTICAL to room_1. The PROPER targetY position should be WAY closer to the BOTTOM of the screen, but I'll set that later.
So for the warp object instance at the bottom of room_2, the Creation Code, is:
targetX = 440 ;
targetY = 640 ;
targetRoom = room_1;
And in my Player movement. I have obj_player. With a Collision mask, spr_collision_mask. With a Create Event, and the following code:
image_speed = 0;
image_index = 0;
Then I have a STEP event, with the following code:
image_speed = 0;
if(keyboard_check(ord("W"))){
if(!position_meeting(x,y-1,obj_barrier))
y-=1;
sprite_index = spr_player_up;
image_speed = .2;
key_up = true;
}
if(keyboard_check(ord("A"))){
if(!position_meeting(x-2,y,obj_barrier))
x-=2;
sprite_index = spr_player_left;
image_speed = .2;
key_left = true;
}
if(keyboard_check(ord("S"))){
if(!position_meeting(x,y+1,obj_barrier))
y+=1;
sprite_index = spr_player_down;
image_speed = .2;
key_down = true;
}
if(keyboard_check(ord("D"))){
if(!position_meeting(x+2,y,obj_barrier))
x+=2;
sprite_index = spr_player_right;
image_speed = .2;
key_right = true;
}
if(image_speed = 0)
{
image_index = 0
}
depth = -y;
So BASICALLY, the whole WARP function, or transitioning between rooms ISN'T working for me. If you could help me figure out how to transition rooms that would be great.
Thanks.