• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

SOLVED Debugging help

H

Helpmeplzimdying

Guest
Howdy!
I'm having trouble understanding what's happening with my code.
So, I got this error message:

___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object ob_player:

Variable ob_player.phy_position_x(55, -2147483648) not set before reading it.
at gml_Script_scr_move_state (line 29) - phy_position_x += hspd;
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scr_move_state (line 29)
called from - gml_Object_ob_player_StepNormalEvent_1 (line 2) - script_execute(state);

And I'm not sure what's wrong with my own code for movement:
///scr_move_state
spd = 2.25;
scr_get_input();

//Speedwalk
if (M_key) {
spd = 3;
}

// Get the axis
var xaxis = (D_key - A_key);
var yaxis = (S_key - W_key);

//Get direction
var dir = point_direction(0,0, xaxis, yaxis);

//Get length
if (xaxis == 0 and yaxis = 0) {
len = 0;
} else {
len = spd;
}

//Hspd and Vspd
hspd = lengthdir_x(len,dir)*spd;
vspd = lengthdir_y(len,dir)*spd;

//Move
phy_position_x += hspd;
phy_position_y += vspd;

// Control Sprite
image_speed = sign(len)*.1
if (len == 0) image_index = 0;

// Vertical Sprites
if (vspd > 0) {
sprite_index = player_down;
} else if (vspd <0) {
sprite_index = player_up;
}

//Horizontal Sprites
if (hspd > 0) {
sprite_index = player_right;
} else if (hspd < 0) {
sprite_index = player_left;
}

//Speedwalk sprite
if (M_key) {
image_speed = sign(len)*.2
}

This only happens when I try to move to the next room.
I'm currently following a HeartBeast RPG Tutorial at the moment, and I checked over it
I did copy it correctly, I believe
Would someone help? Thanks if you do!
 
H

Helpmeplzimdying

Guest
Oh it hasn't!
Thank you so much

Edit:
One problem is solved, but another one arises.
Hm...I wonder what could be wrong.
Now it suddenly comes to a halt whenever I reach the door.
There is no error message or Fatal Error

Hm....
Here's my door code:
///Initialize the door
new_x = 0;
new_y = 0;
new_room = noone;

Collision with the player:
///Go through the door
if(room_exists(other.new_room)) {
room_goto(other.new_room)
x = other.new_x
y = other.new_y
}

Creation code for one door:

new_room = testing_room2;
new_x = 64;
new_y = 36;

And the other:

new_room = testing_room1;
new_x = room_width - 64;
new_y = room_height - 52;
 
H

Helpmeplzimdying

Guest
Oh!
Thank you so much again
I really appreciate it!
 
Top