Posted By: Stansmedia
if(key_e) running without input - 05/26/14 20:30
I've got some doors in my map that check the distance of the player, and when in range if the player presses the E key, it runs some commands. Now... it's running without keyboard input. The first door works fine, waits until you press E. But in the next level the door triggers without the keyboard input.
Code:
if(vec_dist(camera.x,my.x) < 40) { VECTOR temp; ANGLE temp2; vec_diff(temp,my.x,camera.x); vec_to_angle(temp2,temp); if((ang(temp2.pan-camera.pan) < 45) && (ang(temp2.pan-camera.pan) > -45)) //test visibility so vec_to_screen doesn't display when facing opposite { VECTOR* vTextpos = vector(my.x,my.y,my.z); vec_to_screen(vTextpos,camera); // convert to screen coordinates if(vTextpos != NULL) { if(items >= 2) // item collected? { draw_text("Press E to open the door",vTextpos.x,vTextpos.y,vector(0,0,255)); if(key_e) { snd_play(door,100,0); my.skill10 = 1; // terminate loop and run level_load at end of function } } else { draw_text("You're missing a required item",vTextpos.x,vTextpos.y,vector(0,0,255)); } } } }