solved, silly me never looked properly at the code

Posted By: jigalypuff

solved, silly me never looked properly at the code - 10/01/07 10:10

i`m a bit stuck here, the following code works ok untill i change the while (1) to while (my.healthpoints>0)
the mouse and keys just stops working, which is kind of a pain as the camera rotation is controled by the mouse, any thoughs on this.
Code:

function fnct_chc_1
{
me = ent_create (chc_1, vector(0,0,0), null);
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
var ship_speed;
while (my.healthpoints>0)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 10.0 * time;
}
}
else
{
if (ship_speed.x >= 0)
{
ship_speed.x -= 0.05 * time;
}
}
if (ship_speed.x < 0) {ship_speed.x = 0;}
if (key_a == on)
{
my.pan += 3 * time;
}
if (key_d == on)
{
my.pan -= 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_q == on)
{
my.tilt + = 3 * time;
}
if (ship_speed.z < 0) {ship_speed.z = 0;}
if (key_e == on)
{
my.tilt - = 3 * time;
}
ent_move (ship_speed.x, nullvector);
{

camera.pan -= mouse_force.x * 12 * time;
camera.tilt += mouse_force.y * 8 * time;
camera.tilt = clamp(camera.tilt,-30,10);
temp = fcos(camera.tilt,-camera_distance);
vec_set(camera.x,vector(my.x + fcos(camera.pan,temp),my.y + fsin(camera.pan,temp),my.z + 20 + fsin(camera.tilt,-camera_distance)));

vec_diff(temp.x,camera.x,my.x); //find the vector from the player to the camera
vec_normalize(temp.x,16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(temp.x,camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.

trace_mode = ignore_me+ignore_passable+ignore_models;
result = trace(my.x,temp.x); //trace from the player to 16 quants behind the camera.
IF (result > 0) {
vec_diff(temp.x,my.x,target.x); //find the vector from the point the trace hit to the player
vec_normalize(temp.x,16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x,target.x); //place the camera at the trace hit point
vec_add(camera.x,temp.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
wait(1);
}
}
}


Posted By: Bot190

Re: whats wrong with this (apart from me) - 10/01/07 10:19

Did you define "healthpoints" as a skill for "my" before the while?
Posted By: jigalypuff

Re: whats wrong with this (apart from me) - 10/01/07 10:23

define healthpoints, skill18;
yep
Posted By: rvL_eXile

Re: whats wrong with this (apart from me) - 10/01/07 11:28

Maybe write it not in the While Loop, take a If function. Like so:

Code:

function fnct_chc_1
{
me = ent_create (chc_1, vector(0,0,0), null);
player = my;
my.scale_x = 1.0;
my.scale_y = my.scale_x;
my.scale_z = my.scale_x;
var ship_speed;
while (1)
{
if(my.healthpoints>0)
{
if (key_w == on)
{
if (ship_speed.x < 1)
{
ship_speed.x += 10.0 * time;
}
.
.
.
}



cYa Sebastian
Posted By: nfs42

Re: whats wrong with this (apart from me) - 10/01/07 11:53

perhaps
Code:

my.healthpoints = 100;


before the while loop

or is this defined in 'chc_1'?
Posted By: jigalypuff

Re: whats wrong with this (apart from me) - 10/01/07 12:11

i solved it guys, it was because i had not put my.healthpoints=1000; in the chc_1 function
© 2024 lite-C Forums