Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
1 registered members (Grant), 999 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
2 vars and 3 keys #326808
06/03/10 01:27
06/03/10 01:27
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline OP
Senior Expert
3run  Offline 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 tongue


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Code:
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 Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Hey man, that is the easiest thing for programming.
Code:
#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: Widi] #326811
06/03/10 01:54
06/03/10 01:54
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
Widi, I do not have animations for that laugh But thank you any way. Quadraxas, thank you too, I'll give it a try.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: 2 vars and 3 keys [Re: 3run] #326812
06/03/10 01:56
06/03/10 01:56
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
It is only a var, you can rename it if you want (have notting to do with animations)...

Re: 2 vars and 3 keys [Re: Widi] #326813
06/03/10 02:10
06/03/10 02:10
Joined: May 2009
Posts: 5,365
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,365
Caucasus
OK thank you mate wink


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: 2 vars and 3 keys [Re: 3run] #326834
06/03/10 10:52
06/03/10 10:52
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
if (my_animation |= anim_drawl && key_c)

I think you meant this:

if (my_animation != anim_drawl && key_c)

Because the first line will behave quite differrently.

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 Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
oops, my mistake, sorry


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1