|
1 registered members (Grant),
999
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
2 vars and 3 keys
#326808
06/03/10 01:27
06/03/10 01:27
|
Joined: May 2009
Posts: 5,365 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,365
Caucasus
|
I have 2 variables, crawl, prone and a have 3 keys: key_space, key_c, key_ctrl. So on key_space player jumps, on the key_c he crawls and on the key_ctrl he pones. All I need is to be able to toggle this 2 variables with this 3 keys like in Call of Duty. For example is player is crawling, we press key_space, and he stands, or if we press key_ctrl while he crawl, he starts to prone. How to do that? Will be really grateful is some one will teach me. Thank you, sorry for English 
|
|
|
Re: 2 vars and 3 keys
[Re: 3run]
#326809
06/03/10 01:43
06/03/10 01:43
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
void change_stance(){
if(key_space){
prone = 0;
crawl = 0;
}
else if(key_ctrl){
prone = 1 - prone;
crawl = 0;
}
else if(key_c){
crawl = 1 - crawl;
prone = 0;
}
}
either call this function when playe press theese keys or: on_space = change_stance; on_c = change_stance; on_ctrl = change_stance;
3333333333
|
|
|
Re: 2 vars and 3 keys
[Re: 3run]
#326810
06/03/10 01:51
06/03/10 01:51
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
Hey man, that is the easiest thing for programming.
#define anim_stand 1
#define anim_prone 2
#define anim_crawl 3
var my_animation = 1;
...
if (my_animation |= anim_drawl && key_c)
{
my_animation = anim_crawl;
...
}
make this "if()" for every key and set all in a while loop
|
|
|
Re: 2 vars and 3 keys
[Re: Lukas]
#326852
06/03/10 12:26
06/03/10 12:26
|
Joined: Aug 2007
Posts: 1,922 Schweiz
Widi
Serious User
|
Serious User
Joined: Aug 2007
Posts: 1,922
Schweiz
|
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|