Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, AndrewAMD), 656 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
how to get the input in orders? #468883
10/25/17 13:28
10/25/17 13:28
Joined: Jun 2009
Posts: 8
ChongQing,China
J
jockerob Offline OP
Newbie
jockerob  Offline OP
Newbie
J

Joined: Jun 2009
Posts: 8
ChongQing,China
say that I'm making a action game.
And I'm try to get the player run. I want you to double tap the key(like →→)for the running(of course, the 2nd → have to be hold).

Or maybe I'm making a fighting game. That I have to read player input for a special attack(like ↓→+punch = hadoken, →↓→+ punch = shoyoken). Or in the training stage, the player can see what he had inputed(like showing the input "→↓←→←↓→↑↓→←...").

I think I need a function that reads the player's input in orders(and store them or show them). Then if the input order fits some kind of sequence, the player make a special move.

Re: how to get the input in orders? [Re: jockerob] #468890
10/25/17 19:41
10/25/17 19:41
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
I'd use both timers and a complex "SWITCH" setup.

Not functioning code.
Code:
...
var key_timer =0;

var run_yes = 0; // false
var comboo_1 = 0; // false

while(1)
{

if(key_cur) 
key_timer = 10;
if(key_1) 
key_timer = 5;
if(key_2) 
key_timer = 5;
...Subtract timer here...

switch(key_lastpressed )
{
  case 77:
    if(key_timer >0)
    if(key_cur)
    run_yes =1;
    //... Call run function or code below switch
    break;

  case 2:
    if(key_timer >0)
    if(key_1)
    comboo_1 = 0.5;
    else
    {
    comboo_1 = 0;
    key_timer = 0;
    } 
    break;

  case 3: 
   if(key_timer >0)
    if(key_2)
    comboo_1 = 1;
    //... Call comboo function or code below switch
    else
    {
    comboo_1 = 0;
    key_timer = 0;
    } 
    break;

  default:
    printf("None of them! ");
    break;
}

wait(1);
}



reading ...
http://www.conitec.net/beta/akeyboard.htm
http://www.conitec.net/beta/akey_a.htm
http://www.conitec.net/beta/akey_lastpressed.htm
http://www.conitec.net/beta/switch.htm
http://www.conitec.net/beta/acrt-break.htm

You can also use a time and an array to store last-hit key scan codes. Using a "For" loop you can check the array for patterns of combos each frame.

so like
Code:
......
var key_timer =0;
var key_store[5];
var key_index_max = 4;
var key_index =0;

while(1)
{


if(key_cur) 
key_timer = 10;
if(key_1) 
key_timer = 5;
if(key_2) 
key_timer = 5;
...Subtract timer here...

 switch(key_lastpressed)

switch(key_lastpressed )
{
  case 77:
    if(key_timer > 0)
    {
    for(key_index =0; key_index <= key_index_max; key_index++)
    {
      if(key_store[key_index] == 0)
        {
       key_store[key_index] = 77;
         break;
       
     } 
     }
     else
     {
       for(key_index =0; key_index <= key_index_max; key_index++)
        key_store[key_index] = 0;
      }
    run_yes =1;
    //... Call run function or code below switch
    break;

  case 2:
    ......
    break;

  case 3: 
   .........
    break;

  default:
    printf("None of them! ");
    break;
}

//....... Checking the array
if(key_store[0] !=0) // ?One key was hit
{
  if(key_store[1] !=0)
   {
   if(key_store[0] == 77 && key_store[1] == 77 )
     ///...Call RUN here
    }
}
wait(1);
}



http://www.conitec.net/beta/for.htm
http://www.conitec.net/beta/keys_c.htm

The above code doesn't work and is bugged, but you should get an idea of how you can use it to build a combo system.

Also please check the AUM mags, I'm sure a combo system has been done before.

Last edited by DriftWood; 10/25/17 20:03.
Re: how to get the input in orders? [Re: DriftWood] #468898
10/26/17 13:05
10/26/17 13:05
Joined: Jun 2009
Posts: 8
ChongQing,China
J
jockerob Offline OP
Newbie
jockerob  Offline OP
Newbie
J

Joined: Jun 2009
Posts: 8
ChongQing,China
Thank you for replying.

I got your idea. A timer that would count down, and use "key_lastpressed" function for the last input.

But there is some problem remaining. what about "&#8600;", that require both "&#8595;"&"&#8594;". And what about holding, say I'm making a guy like GUILE(street fighter).

OK I'll check the AUM for answer or some ider.

Thanks again for the kindheart! wish you happy.

Re: how to get the input in orders? [Re: jockerob] #468901
10/26/17 15:18
10/26/17 15:18
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
That's not a trivial task to do. In my opinion you would need some kind of queue data structure to save an arbitrary number of the last key presses. Therefore, you would wrap each key press to a command structure and store the commands in the queue. Your fighter would need a finite state machine to determine if the last key presses are relevant for the current state he's in.

There was a very old fighting game workshop for A5. I don't know if they used the same ideas but I think the workshop is available on Acknex Unlimited. Maybe you can find some inspiration there.

Re: how to get the input in orders? [Re: Ezzett] #468927
10/27/17 20:52
10/27/17 20:52
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
Add a new timer called charge timer - for the charge key. You need to step out of the switch and into IF trees.
Code:
.........
var charge_timer =0;
if( key_a)
 charge_time =5;
...sub charge_timer...

if(key_d && key_lastpressed(--key_a--) && charge_time<=0)
----do attack----



As per double keys, it's not complex,
Code:
if(key_a && key_d && key_timer < 0)
{
 .... do -x- .....
}



If you like give each optional key it's own timer... key_a_timer, key_d_timer, ect + key_a_charge timer.....

Also look at this http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=468925#Post468925 , by the Master @txesmi


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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