Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: REQUEST: help with swords...  (Read 1181 times)

0 Members and 1 Guest are viewing this topic.

X-Morsl-X

REQUEST: help with swords...
« on: February 03, 2007, 12:29:20 pm »
Hi  :). Im new on these forums and am in some need of some programming help. Im using GM6.1 unregistered and am making a Zelda sidescroller using Semijuggalos Link sprites. The effect I am trying to achieve is you can press the attack button (default Z) and he swings right BUT then if you press it again quickly before he has finished the slash he swings his sword to the left AND if you swing quickly after that he does a powerful strike! But i also need him to be able to just slash once or twice in a row so the player doesnt HAVE to do the 3X combo. Im really stuck for ways of doing this. Can anyone write some code that might help or give me a simple tutorial?
X-Morsl-X
Logged
Re: REQUEST: help with swords...
« Reply #1 on: February 03, 2007, 12:33:09 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 2245
when you press the key, check wat sprite it is
Logged

X-Morsl-X

Re: REQUEST: help with swords...
« Reply #2 on: February 03, 2007, 12:43:48 pm »
Thats basicly what I did but it only lets me slash right once then if i click the z button again it slashes left it really confuses me!!  :(
Logged
Re: REQUEST: help with swords...
« Reply #3 on: February 03, 2007, 12:57:58 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 6206
You have a big chance in getting help if you post the gm6.
Logged

X-Morsl-X

Re: REQUEST: help with swords...
« Reply #4 on: February 03, 2007, 01:58:13 pm »
thats the problem... i havent made the sword engine yet sorry... its just ive tried on it before and it didnt work no matter how i tried it...  :(
Logged
Re: REQUEST: help with swords...
« Reply #5 on: February 04, 2007, 06:05:45 am »
  • Huzzowee!
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 571
So... you're asking for help with something that doesn't exist? Go back and make it as well as you can and come back when you're really stumped again. We can't really help with nothing.

To get you started though, I might have figured out the problem based on what you've said. In theory, you have it so that it checks what the sprite is when you attack and then attacks again accordingly, but somehow it always does the triple attack instead of just one. Odds are you coded yourself a trap. Picture it this way:

Let's assume the code is something like this:
Code: [Select]
When you push 'z':
    if Link has a normal sprite{
         change the sprite to the first attack
    }
    if Link has the first attack sprite{
         change the sprite to the second attack
    }
    if Link has the second attack sprite{
         change the sprite to the third attack
    }

Now, if that's the case, it's something that looks like it should be right, but it's not quite there yet. If you read through it carefully, you'll find the flaw. First, it checks if the sprite is an attacking one. if it's not, it starts the first attack. Then it checks if you're doing the first attack. If you are it starts the second attack, and so on and so forth. The problem is, GameMaker, just like any program, is stupid. It doesn't know what you want so it doesn't stop when it's acheived your goal. It's going to go through that whole block of code. So after you've started the attack it goes to check for the second attack whether you want it to or not. The problem is that you've just set it to attack, so no matter what it's going to find the next statement true and start the next attack. It'll do the same thing for the third. There's nothing that tells it to stop. Or is there? There is indeed a magic piece of code that will save you! if you type "break" inside each "if" statement at the end, as soon as it hits that it'll jump out of the event and stop thinking about what to do with the "z" button. Then, the next time you push it, it'll bypass the first "break" since the first statement isn't true and go on straight to the second, stopping after that one's "break". The working code would look something like this:
Code: [Select]
When you push 'z':
    if Link has a normal sprite{
         change the sprite to the first attack
         break;
    }
    if Link has the first attack sprite{
         change the sprite to the second attack
         break;
    }
    if Link has the second attack sprite{
         change the sprite to the third attack
         break;
    }
Of course, you would have to replace all the other !@#$% (besides "break") there with real code. The alternative to that is a Switch/Case statement, which you can read up in the manual (since I don't want to explain it).
Logged
"They say 'Don't sweat the little things!', but in the end, the little things are all that matter..."
--Alex2539
Re: REQUEST: help with swords...
« Reply #6 on: February 04, 2007, 11:47:29 am »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 413
Use what Alex said. Alternatively, you could use alarms to trigger a 'current attack' variable, which determines whether you can use the next move in the sequence or not.
I like those sprites, I hope you do a good job with them, just like MattCoz did...
Logged

X-Morsl-X

Re: REQUEST: help with swords...
« Reply #7 on: February 04, 2007, 05:09:21 pm »
Alex, youre code didn't work It just made him slash his sword forever only in one animation... see if you can fix it... http://h1.ripway.com/XMorslX/LoZ.gm6
Logged
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.058 seconds with 54 queries.

anything