Code:
// PlayerControls.wdl
// ** Global variables
var moveVector[3] = 0, 0, 0;
action playerControl {
player = me;
wait(1);
// ** Loop while player exists - check for keyboard / mouse input
while(player != null) {
// *************************************
// ** Control and update player movement
moveVector[0] = ((key_w - key_s) * 12 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the player's forward
// ** / reverse movement
moveVector[1] = ((key_a - key_d) * 6 * time); // ** Sets "reldist" vector that sets the
// ** "direction" of the players strafing
// ** movement
player.pan -= (mouse_force.x * 24 * time); // ** Pans the camera - controls x-rotation
// ** Tilts the camera while restricting the amount of tilt to + / - 75 degrees
var newTilt = 0;
var tempTilt = 0;
tempTilt = (mouse_force.y * 8 * time);
if((camera.tilt + tempTilt) > 75) {
newTilt = 75;
} else {
if((camera.tilt + tempTilt) < -75) {
newTilt = -75;
} else {
newTilt = (camera.tilt + tempTilt);
}
}
ent_move(moveVector, NULLVECTOR); // ** Moves the player
camera.x = player.x;
camera.y = player.y; // ** Moves the camera in relation to player
camera.z = (player.z + 125);
camera.pan = player.pan; // ** Rotates the camera
camera.tilt = newTilt; // ** Tilts the camera
if(mouse_left == 1) {
c_scan(camera.x, camera.pan, vector(15, 15, 1500), SCAN_ENTS);
}
wait(1);
}
}
Code:
// DoorFunctions.wdl
function manipulateDoor() {
if(event_type == EVENT_CLICK) {
my.pan += 45;
}
}
action doorControls {
my.ENABLE_CLICK = ON;
my.event = manipulateDoor;
}