F
Finsie
Guest
Hi
I'm having trouble figuring out what's causing my game to freeze when I hit my o_transition object.
My o_transition object only has a create event with "targetRoom = -1;" and each instance in a room of the object sets the room name as the value in the creation code.
Here's my player code (the transition code is at the bottom under // Objects):
Even if I remove the // Objects code, add a collision event with the code "room_goto(r_bar);" in the player for the o_transition, it still freezes.
I'm having trouble figuring out what's causing my game to freeze when I hit my o_transition object.
My o_transition object only has a create event with "targetRoom = -1;" and each instance in a room of the object sets the room name as the value in the creation code.
Here's my player code (the transition code is at the bottom under // Objects):
GML:
// check for movement inputs and change to true or false
input_left = keyboard_check(ord("A"));
input_right = keyboard_check(ord("D"));
input_up = keyboard_check(ord("W"));
input_down = keyboard_check(ord("S"));
input_run = keyboard_check(vk_shift);
//----------ALTER SPEED
if(input_run){spd = runSpeed;}
else {spd = walkSpeed;}
//----------RESET THE MOVEMENT VARIABLES
moveX = 0;
moveY = 0;
// get the intended movement of the player, and stop them moving if multiple keys are pressed
moveX = (input_right - input_left) * spd;
if(moveX == 0){moveY = (input_down - input_up) * spd;}
//----------COLLISION CHECK
// checks that the player is moving
if(moveX != 0){
// chesk for collision
if(place_meeting(x+moveX, y, o_collision)){
// checks there isn't a collision 1 space ahead, and keeps player moving
repeat(abs(moveX)){
if(!place_meeting(x+sign(moveX), y, o_collision)){ x += sign(moveX);}
else{ break;}
}
moveX = 0;
}
}
// checks that the player is moving
if(moveY != 0){
if(place_meeting(x, y+moveY, o_collision)){
// checks there isn't a collision 1 space ahead, and keeps player moving
repeat(abs(moveY)){
if(!place_meeting(x, y+sign(moveY), o_collision)){ y += sign(moveY);}
else{ break;}
}
moveY = 0;
}
}
// Objects
var inst = instance_place(x, y, o_transition);
if(inst != noone){
room_goto(inst.targetRoom);
}
// actually move the player
x += moveX;
y += moveY;
Last edited by a moderator: