Jump to content

Combination of keys and taking damage in fighting game


vernonr
 Share

Recommended Posts

Hi guys, I'm really new to Phaser and programing in general so I'm getting stuck really often with my first game. :lol: 

 

What I'm trying to do is some sort of a two players fighting game (this is a game for gamepads and keyboards, no mobile here). I kinda have the basics going, I mean, my characters move! But i have a list of things to do that keeps growing! Here I have my first two problems for you, kind people:

 

Problem number 1: The thing I'm trying to do is to have my character perform a special move with a combination of buttons. I'm guessing there should be a timer involved somehow. The idea is that if you press button 1 and quickly press button 2 and 3, a special move will happen (a set of frames of my animation sheet) but if you don't press them fast enough, then you will have the animations for each instead (button 1 is used for punching, button 2 is used for kicking and button 3 for blocking).

 

Problem number 2: How can the punch o the kick hit player 2? I have the two sprits on screen, each of them are moving but they don't hit each other. I would need to have some sort of lifemeter or something, one for each player, and a value for punching, kicking and any other special move, which will affect the lifemeter of the player being hit.

 

Many thanks in advance! I love this Phaser engine and the community in this forum. I'm really excited with this game  :D

Link to comment
Share on other sites

Many thanks! I'm looking but there's nothing phaser oriented. I know that to many of you it would be easy to translate an idea from one code to another but for me is very difficult. I'll keep looking but if someone around here could give me a hint as from where to begin the resolution of these issues, that would be the greatest  ;)

Link to comment
Share on other sites

Ok, so I was checking the forum and I found this idea about how to get a double tap action. Think that I could use it with a combination of keys for what I need to do. Here's the idea: 

 

You could do 2 things:

1. Always have a short delay on keyup.

e.g.

keyup

-> check if timer active,

if yes -> cancel timer and emit charge forward,

if no -> timer = setTimeout(normaltap, 100); <- or whatever delay

 

2. check last tap time

 

keyup

-> check if difference between time and last time you pressed the key is less than 100 ms (or whatever delay you prefer)

if yes, set the time to 0 and emit charge forward (0 so that the next keyup wont trigger another double tap if you mash the key too fast)

if no, emit normaltap and save the current time for this key

 

The thing is that I don't know how to do this. Any ideas? Thanks!

Link to comment
Share on other sites

Thanks a lot! Your code has been really helpful but I finally ended up using a JS library called mousetrap. It allows combinations of keys to be used. It works for now so I'll think I'll stick in my code. I still have to solve my problem number two, though :P

Link to comment
Share on other sites

I know this is from the now more-or-less defunct XNA framework, but luckily code doesn't stagnate. If you have some C# chops, why not try reading the source code for their sample "Input Sequence" which is a demonstration of doing just what you asked. It shouldn't be too hard to port their example to Phaser, I believe.

 

http://xbox.create.msdn.com/en-US/education/catalog/sample/input_sequence_sample

Link to comment
Share on other sites

  • 2 months later...

I'm trying to make a fighting game using Phaser as well! Have you worked at all on how to create different hitboxes for each frame? I'm not sure if I should create a different collision group for each frame and then cycle through the collision groups as I cycle through animation frames, or if I should be doing something else entirely.

Link to comment
Share on other sites

@NumberOneRobot, I don't have any experience, but I thought you don't need different hitboxes for every frame, but for different states like "sitting", "standing", "jumping", "kicking". You can toggle these states as the player animates to them. Later you can grow/shrink certain boxes, as you transition between states.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...