|
Re: Lite-c key pressed question
[Re: Helghast]
#255112
03/07/09 18:01
03/07/09 18:01
|
Joined: Dec 2008
Posts: 56
binsky33333
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2008
Posts: 56
|
Are there any other ways? Like a way where you have to release the space key in order for the my.z += 10 to work?
Last edited by binsky33333; 03/07/09 18:02.
|
|
|
Re: Lite-c key pressed question
[Re: binsky33333]
#255115
03/07/09 18:16
03/07/09 18:16
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
You could use the "on_space" function. IE: function main()
{
...
on_space=player_jump; //call this just once
...
}
function player_jump()
{
player_entity.z += 10; //ME is not valid here
} or a messier way (but still acceptble) would be
action your_action()
{
var space_pressed = 0; //before WHILE loop starts
...
if(key_space==0)
{
space_pressed = 0;
}
else
{
space_pressed = 1;
if(space_pressed==0) my.z += 10;
}
...
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Lite-c key pressed question
[Re: EvilSOB]
#255118
03/07/09 18:39
03/07/09 18:39
|
Joined: Dec 2008
Posts: 56
binsky33333
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2008
Posts: 56
|
Thanks for the reply but neither or those worked?
Hmmm... i wonder what i should do?
Last edited by binsky33333; 03/07/09 19:01.
|
|
|
Re: Lite-c key pressed question
[Re: binsky33333]
#255120
03/07/09 19:05
03/07/09 19:05
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Post the rest of the function/action it is in.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Lite-c key pressed question
[Re: EvilSOB]
#255121
03/07/09 19:08
03/07/09 19:08
|
Joined: Dec 2008
Posts: 56
binsky33333
OP
Junior Member
|
OP
Junior Member
Joined: Dec 2008
Posts: 56
|
Here you go:
action player_move
{
player= me;
wait(1);
camera.genius = player;
shift_sense= 2;
while(player!=NULL)
{
//Walking function arrow keys
move_vec[0]= (key_cuu - key_cud)*8*time;
move_vec[1]= (key_comma - key_period)*6*time;
//Stair Climbing and falling
vec_set(temp,my.x);
temp.z -= 4000;
trace_mode = ignore_me+ignore_sprites+IGNORE_MODELS+USE_BOX;
move_vec.z=(-trace(my.x,temp))*3*time;
player.pan -= (key_force.x)*1.5*time;
move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE;
ent_move(move_vec,NULLVECTOR);
//jumping
//Running with arrow keys
if(key_shift == 1)
{
move_vec[0]= (key_cuu - key_cud)*4*time;
}
player.pan += (key_cul - key_cur)*2*time;
ent_move(move_vec,NULLVECTOR);
if(move_vec[0]== 0 && move_vec[1]==0)
{
//Idle
idle_percent= (idle_percent +5*time)%100;
ent_animate(me,"stand",idle_percent,ANM_CYCLE);
}
else
{
//Running animation
if(key_shift)
{
run_percent = (run_percent + sign(move_vec[0])*5*time)%100;
ent_animate(player,"run",run_percent,ANM_CYCLE);
}
else
{
//Walking animation
walk_percent = (walk_percent+ sign(move_vec[0])*5*time)%100;
ent_animate(player,"walk",walk_percent,ANM_CYCLE);
}
}
//The Camera
vec_set(Camera.x,player.x);
camera.z += 39;
camera.pan = player.pan;
temptilt += (key_pgup - key_pgdn)*4*time;
if(key_home){ temptilt =0;}
if (temptilt > 75)
{
temptilt = 75;
}
else
{
if(temptilt < -75)
{
temptilt= -75;
}
}
camera.tilt =0 +temptilt;
wait(1);
}
}
|
|
|
Re: Lite-c key pressed question
[Re: binsky33333]
#255130
03/07/09 20:01
03/07/09 20:01
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I cant see anywhere in the code mentioning trying to use the space key, so I'll guess its the apparently blank junping section. action player_move
{
player= me;
wait(1);
camera.genius = player;
shift_sense= 2;
var space_held = 0; //<<Added
while(player!=NULL)
{
//Walking function arrow keys
move_vec[0]= (key_cuu - key_cud)*8*time;
move_vec[1]= (key_comma - key_period)*6*time;
//Stair Climbing and falling
vec_set(temp,my.x);
temp.z -= 4000;
trace_mode = ignore_me+ignore_sprites+IGNORE_MODELS+USE_BOX;
move_vec.z=(-trace(my.x,temp))*3*time;
player.pan -= (key_force.x)*1.5*time;
move_mode = IGNORE_YOU + IGNORE_PASSABLE + IGNORE_PUSH + ACTIVATE_TRIGGER + GLIDE;
ent_move(move_vec,NULLVECTOR);
//jumping
if(key_space==0)
space_pressed = 0;
else
{
space_pressed = 1;
if(space_pressed==0) player.z += 10;
}
//Running with arrow keys
if(key_shift == 1)
{
move_vec[0]= (key_cuu - key_cud)*4*time;
}
player.pan += (key_cul - key_cur)*2*time;
ent_move(move_vec,NULLVECTOR);
if(move_vec[0]== 0 && move_vec[1]==0)
{
//Idle
idle_percent= (idle_percent +5*time)%100;
ent_animate(me,"stand",idle_percent,ANM_CYCLE);
}
else
{
//Running animation
if(key_shift)
{
run_percent = (run_percent + sign(move_vec[0])*5*time)%100;
ent_animate(player,"run",run_percent,ANM_CYCLE);
}
else
{
//Walking animation
walk_percent = (walk_percent+ sign(move_vec[0])*5*time)%100;
ent_animate(player,"walk",walk_percent,ANM_CYCLE);
}
}
//The Camera
vec_set(Camera.x,player.x);
camera.z += 39;
camera.pan = player.pan;
temptilt += (key_pgup - key_pgdn)*4*time;
if(key_home){ temptilt =0;}
if (temptilt > 75)
{
temptilt = 75;
}
else
{
if(temptilt < -75)
{
temptilt= -75;
}
}
camera.tilt =0 +temptilt;
wait(1);
}
}
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Lite-c key pressed question
[Re: EvilSOB]
#255132
03/07/09 20:18
03/07/09 20:18
|
Joined: Jul 2002
Posts: 4,436 Germany, Luebeck
Xarthor
Expert
|
Expert
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
|
@EvilSOB: You reckon that your code will never execute the "my.z += 10;" part? The problem is this section:
space_pressed = 1;
if(space_pressed==0) player.z += 10;
First you set space_pressed to 1 and then check if its 0. But at that point it'll never be 0 because you set it to 1 first. Try replacing the whole jumping part with:
if(key_space}
{
space_pressed = 1;
}
else
{
if(space_pressed)
{
space_pressed = 0;
my.z += 10;
}
}
|
|
|
Re: Lite-c key pressed question
[Re: Xarthor]
#255139
03/07/09 23:24
03/07/09 23:24
|
Joined: Oct 2004
Posts: 1,655
testDummy
Serious User
|
Serious User
Joined: Oct 2004
Posts: 1,655
|
#define k_space 57
//define k_space = 57;
var k_nSt[50];
var in_n1 = 0;
var in_n2 = 0;
function kf2(var _nScanCode) {
in_n1 = key_pressed(_nScanCode);
in_n2 = in_n1 && !k_nSt[_nScanCode];
k_nSt[_nScanCode] = in_n1;
return(in_n2);
}
// usage:
if (kf2(k_space)) {
}
|
|
|
|