Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Attack combo coding - Not quite working.

Author
Message
Gracus
12
Years of Service
User Offline
Joined: 10th Dec 2011
Location:
Posted: 25th Feb 2012 20:53
Hello all, stuck once again with coding!

In short I'm trying to make a three basic attack combo which goes like this. (User presses A to attack, sprite punches, the user cannot hold down A , the user needs to repeatedly press the A button for the combo to work. Once the A button has been pressed once the Player can press A again for the second attack and then lastly the third.)

What is actually happening:-

When Pressing A only the first punching sprite is shown. Looking at my coding I can't see how this is happening. Can anyone see the problem? Thanks.

WickedX
15
Years of Service
User Offline
Joined: 8th Feb 2009
Location: A Mile High
Posted: 26th Feb 2012 02:13
You have your, if statements nested; therefore if the first condition isn’t met the next two conditions aren’t checked. Try this.

Gracus
12
Years of Service
User Offline
Joined: 10th Dec 2011
Location:
Posted: 26th Feb 2012 03:40
Yes, this works perfect now, thank you WickedX!
Millenium7
19
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 26th Feb 2012 04:15 Edited at: 26th Feb 2012 04:23
I'm not a fan of the way your code handles combo's. If you are only ever going to use the A key and no other buttons I suppose it's ok but my way of thinking would be this sort of initial setup



Then the actual handling would be along the lines of this pseudo code

Gracus
12
Years of Service
User Offline
Joined: 10th Dec 2011
Location:
Posted: 26th Feb 2012 05:08
That was something I was going to add after I figure out a timer code (Thanks to you, that has been done )

I guess another thing I could add in would be a 'cooldown' to the combo; say for one second after pressing A you can't press A again. This will stop the player from mashing the A key, which would make the Player sprite look ridiculously fast by attacking 10 times with in a second.

I suppose I could manipulate the timer code for the disable?
Millenium7
19
Years of Service
User Offline
Joined: 13th Dec 2004
Location:
Posted: 26th Feb 2012 14:20
to save you a bit of hassle here's my 'KeyCheck' function


I'll leave this as is, as you may find it useful for menu's. Right now it basically replicates key repeating/locking, essentially it's used for typing. Enter key and some others do NOT repeat
If you want to make it unrepeatable, and merely a lock/unlock function just increase KeyTimer(0) to a really high value

For the key cooldown I suggest editting my function and adding an additional parameter, i.e. KeyValid(key,cooldown)
And use the cooldown value to invalidate the key for a time

Login to post a reply

Server time is: 2024-05-09 06:41:55
Your offset time is: 2024-05-09 06:41:55