help pls

Posted By: joh

help pls - 01/30/10 15:39

i need help with this i cant access my buildings anymore and it doesn't climb on stairs anymore please help me i need it so badly my deadline is on friday

here's the link of my project.. thanks for those who will help

http://hotfile.com/dl/26424446/58bd754/myproject.rar.html
Posted By: Aku_Aku

Re: help pls - 01/30/10 17:35

If you want to get help, you should give some hints where is/are the problem/s in your code...
File name, function name etc.

Moreover, what does it mean
Quote:
i cant access my buildings anymore
and
Quote:
it doesn't climb on stairs anymore
?
Posted By: joh

Re: help pls - 01/30/10 17:50

i think it has to do with the movement of the player or the player_control
Posted By: Superku

Re: help pls - 01/30/10 21:27

Quote:
here's the link of my project.. thanks for those who will help


You won't get any help until friday if you don't post the relevant code.
Posted By: joh

Re: help pls - 01/31/10 03:45

ok here's the code.. but i put the link to atleast you can see everything thay may cause the problem and also the player model that i guess something to do with the malfunctions...


function player_control(){ //This is the code the player will run in order to move around
var me_run = 1; //The multiplier for running
var lock_camera_pan = 0; //When X is pressed, lock the panning from the mouse
var gravity = -10; //Set the gravity here
var mickey_zoom = 0; //The value of the camera zoom from the player
var temp2 = 0; //This is the temp variable to help the zooming of the camera
var finish_x = -1500;
var finish_y = -1000;
var old_x = 0;
var old_y = 0;
var old_z = 0;
var diff_x = 0;
var diff_y = 0;
var diff_z = 0;
var height_counter = 0;
var reference_x = 550;
var reference_y = 3000;
var y_compensation = 0;
var x_compensation = 0;
var gravity_counter = 0;

//The player properties
my.push = 25; //Set the push to 25, so player can interact with other objects and terrain
my.narrow = on; //Used for collision detection
my.ambient = 25; //Give the player an ambient brightness
my.scale_x = 2.4; //Set the player scale X
my.scale_y = me.scale_x; //Set the player scale Y
my.scale_z = me.scale_x; //Set the player scale Z
my.shadow = on; //Set the player shadow
my.polygon = on; //Set the player polygon to on, for better collision detection
my.flag2 = on; //Set this so when another function checks FLAG2, they know how to operate
my.pan += 270;

pnlPlayerIcon.center_x = pnlPlayerIcon.size_x * 0.5;
pnlPlayerIcon.center_y = pnlPlayerIcon.size_y * 0.5;

//pnlFinishIcon
while (1){ //Setting this to 1 will force this loop to run forever, we need it to since players will always move
while(pnlBackground.visible == on){wait(1);}

//Rotate player icon for pointing
pnlPlayerIcon.angle = my.pan;

//Update position on map for player
if(player.x <= 14672){
player_map_y = (420 - ((((my.x + reference_x) / 27800)* 100) * 4.2)) - 150;
}
else{
x_compensation = 75 - (((player.x/12578)) * 75);
if(player.x < 27250){
pnlPlayerIcon.pos_y = 75 + x_compensation;
}
}
if(player.y <= 0){
player_map_x = (((((abs(my.y) + reference_y) / 21000)* 100) * 4.2)) - 55;
}
else{
y_compensation = ((player.y/3000)) * 75;
if(player.y < 3000){
pnlPlayerIcon.pos_x = 75 - y_compensation;
}
}

if(replaying == 0){
//Save Player Positions so other functions can use them
player_x = my.x;
player_y = my.y;
player_z = my.z;
player_pan = my.pan;
//If the shift key is pressed, speed the player up, else just walk at normal speeds
if(key_shift == 1 && key_cud == 0 && key_cul == 0 && key_cur == 0){me_run = 1;}
else{me_run = 1;}

//Get input keys from player
me.force_x = ((key_cuu - key_cud) * 1 * me_run);
if(key_cuu != 1 && key_cud != 1 && key_W != 1 && key_S != 1){me.force_y = ((key_cul - key_cur)* 0.05);} //LEFT AND RIGHT STRAFE
//if(me.force_x == 0){me.force_x = ((key_W - key_S) * 1 * me_run);}
me.force_y = ((key_A - key_D)* 0.05);
me.force_y = ((key_cul - key_cur)* 0.05);

//Player pan and tilt
if (mouse_left == 1 && mouse_right == 0){ //If statement changes pan on view but also stops mousemovement
me.pan -= (mouse_force.x) * 3; // mouse movement changes PAN
}
if(me.force_y != 0){
my.pan += me.force_y;
}
if (mouse_left == 1 && mouse_right == 0 && me.local_tilt <=90 && me.local_tilt >= -90){
me.local_tilt += (mouse_force.y)* 2;
}
if (me.local_tilt >= 90){me.local_tilt = 90;}
if (me.local_tilt <= -90){me.local_tilt = -90;}
}
else{
wait(1);
}

//Physically move the player using the forces
my.force_x *= 10; //Multiplay speed by 3
my.force_y *= 3; //""
if(my.force_x == 0 && my.force_y == 0){move_mode = ACTIVATE_TRIGGER + IGNORE_PASSABLE + USE_AABB + IGNORE_PUSH + IGNORE_FLAG2;}
else{move_mode = ACTIVATE_TRIGGER + GLIDE + IGNORE_PASSABLE + IGNORE_PUSH + IGNORE_FLAG2;}
c_move(me,vector(me.force_x,0,gravity),vector(0,0,0), move_mode);
my.z += 4;

if(my.x <= -8700){my.x = -8700;}
if(my.x >= 27500){my.x = 27500;}
if(my.y >= 3000){my.y = 3000;}
if(my.y <= -18000){my.y = -18000;}

//Make sure player doesn't go straight up
height_counter += 1;
if(height_counter == 1){
old_x = my.x;
old_y = my.y;
old_z = my.z;
}
if(height_counter >= 10){
diff_x = abs(old_x-my.x);
diff_y = abs(old_y-my.y);
diff_z = abs(old_z-my.z);
if(diff_z >= 25){
height_counter = 0;
while(height_counter <= 2){
c_move(me,vector(0,0,-50),vector(0,0,0), move_mode);
height_counter += 1;
wait(1);
}
}
height_counter = 0;
}

//Camera Movement
//If the Z key is pressed, rotate camera going left around player
if(key_z == 1){camera.pan -= 1;lock_camera_pan = 1;}
//If the C key is pressed, rotate camera going right around player
if(key_c == 1){camera.pan += 1;lock_camera_pan = 1;}
//If the X key is hit, place the camera back behind the player
if(key_x == 1){lock_camera_pan = 0;}
//Normal movement of camera
if(key_c != 1 && key_z != 1 && lock_camera_pan == 0){camera.pan = me.pan;}

//Adjust camera on the player along with zooming in and out
camera.x = me.x - (mickey_zoom * (1-abs(camera.tilt/90))) * cos(camera.pan);
camera.y = me.y - (mickey_zoom * (1-abs(camera.tilt/90))) * sin(camera.pan);
camera.z = me.z + 75 + abs(me.local_tilt / 5);
camera.tilt = me.local_tilt;
mickey_zoom += mickey.z / 25;

//If the scroll wheel is moved, move the camera in and out
vec_set(temp2.x,me.x);trace_mode = IGNORE_ME + IGNORE_FLAG2;
if(c_trace(camera.x,temp2.x,trace_mode) != 0){mickey_zoom -= 10;}
//Fix the max zooming of the camera
if(mickey_zoom > 250){mickey_zoom = 250;}
if(mickey_zoom < 0){mickey_zoom = 0;}
if(mickey_zoom <= 15){me.transparent = on; me.alpha = 25;}
else{me.transparent = off;} //mtl_playermat


//Animations
if(my.force_x > 0){
if(key_shift == 1){
ent_animate(me,"run",me.animation,anm_cycle);
me.animation += 0.25;
}
if(key_shift == 0){
ent_animate(me,"walk",me.animation,anm_cycle);
me.animation += 0.25;
}
}
else{
ent_animate(me,"stand",me.animation,anm_cycle);
me.animation += 0.1;
}
wait(1);
}
}
Posted By: Ottawa

Re: help pls - 01/31/10 15:04

Hi!

Place all your variables outside the function
so that
they will be global and then
they will be available to all functions.

Break your code in smaller functions
ex : all the code my.push = 25...
This way you will be able to call these functions many times.
© 2024 lite-C Forums