• Content Count

  • Joined

  • Last visited

About mkhan074

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi everyone, I think I figured it out and I want to share with everyone. There might be a better way, so I'm not sure. I have a function called InputHandlers within my update method, as shown: function inputHandlers() { //TODO: Neutral jump: // playerKen.body.velocity.y = -50; //'neutralJump', 7, false); if (cursors.left.isDown && cursors.down.isUp) { lastLeftInput =; walkLeft(); } else if (cursors.right.isDown) { lastRightInput =; walkRight(); } else if (cursors.down.isDown) { lastDownInput =; crouch(); } else if (mediumPunchInput.isDown) { lastMediumPunchInput =; mediumPunch(); } else if (lightPunchInput.isDown) { lastLightPunchInput =; lightPunch(); } else { standing(); } } It keeps track of the last time you have put that input in. The logic in the below code is it detects whether your inputs are in a certain way. A nested if statement is below that which calculates whether you have hit that input fast enough to the the fireball. function specialMovesTracker() { if (inputString.includes("DR[LP]")) { if ((lastDownInput - lastLightPunchInput) < 0.44425) { console.log('hadouken'); inputString = ""; } else { console.log('Do not do hadouken, users inputs are too slow.'); } } else if (inputString.includes("DRD[LP]")) //Shoryuken (Dragon Punch) { if ((lastDownInput - lastLightPunchInput) < 1.5) { console.log('shoryuken'); inputString = ""; } } else { console.log("No Special moves detected."); } }
  2. Hi everyone, As you guys might know, I am working on a fighting game, and I want to be able to throw a hadouken (a fireball) when down, right, and the Q button is entered. I have a two methods I call from the update method. (Btw, I am an ASP.NET Developer so I will use the words method and function interchangeably) 1) I have a string variable I concatenate to whenever I press an input, this is what the variable inputString is for. function inputTracker() { if (cursors.left.downDuration(1)) { inputString += "L"; } else if (cursors.right.downDuration(1)) { inputString += "R"; } else if (cursors.down.downDuration(1)) { inputString += "D"; } else if (mediumPunchInput.downDuration(1)) { inputString += "[MP]"; } else if (lightPunchInput.downDuration(1)) { inputString += "[LP]"; } } 2) I have another method that determines if the user has done any special moves (Hadouken, tatsu, shoryuken) function specialMovesTracker() { if (inputString.includes("DR[LP]")) { console.log('hadouken'); inputString = ""; } } The way it is implemented works, but the only issue is that there is no time constraint. I would like to press down, right, Q (which is LP -- light punch) in a fluid motion and throw a hadouken. there needs to be a time constraint. But I am not sure how to implement that in javascript. I was thinking of an array that contains the input along with the time, but array comparisons are not as flexible as it is in C# and other OOP languages.
  3. I use Visual Studio Code on my mac, very lightweight and easy. All I do is run the index.html file and I'm able to run it. Not to be confused with Visual Studio Community Edition. Check out this site:
  4. mkhan074

    Phaser Books

    Hi Clicksys, I'm on my fourth day of phaser so I'm new myself. Other than simple DOM traversal and working with angularJS, I myself hadn't had much experience in Javascript (I'm an ASP.NET Developer by profession) The way I got my feet wet with Phaser are the examples shown on the website. Start off with this: Once you understand that, move on the animation: Then move on to keyboard/mouse inputs: Look at all the examples and play with the code. No books needed. The community here at html5devs is amazing, if you run into a problem it's most likely already solved here if you use the search bar in this forum. To actually run your code, you should read this: I personally use Visual Studio, and run in debug mode. This is so I don't have to set up a local server and such. If you want to take that route, read that tutorial on getting started.
  5. Great post aapo. Honestly, other than makgin games with RPG Maker 2000 way back, this is the only game dev experience I have. I've been using Phaser for about 4 days and I think I came a long way! I have researched how fighting game engines work, I know there is the concept of a hit stun (opponent cant press any buttons after being hit, which enables you to chain and link combos) and recovery frames (player can't press button for a certian period) that I plan on to implement some time in the future. I was actually thinking about what you said in your post, a couple of days ago actually. Having to create hitboxes and hurtboxes that change in size frame by frame, and setting it's x and y offsets, will be quite a daunting task, am I right? Is there an easy way to go about this? ------------ EDIT: I guess another issue I have is... When I punch the AI, for example I do Light punch which is 3 frames long (1 frame is the startup frame, the second frame is the actual jab frame, and the third frame is the recovery frame), how do I program it in a way that only damage is done on the second frame? The code is in my first post, the same logic is applied to my standing light punch. is there a way that says "if animation is the second frame, do so and so"? EDIT 2: I realised I can do if (playerKen.frame == 27){ //show hitbox } Shout outs to this example for giving me the idea: I realised putting this within the lightpunch() button wont give you the frames for the full punch animation. I guess I would call a method from my update method that keep track of what frame is being played and do my if statements there.
  6. Hi Samid, thanks for letting me know. A situation where that might occur is when I sweep the opponent with crouching heavy kick , but I plan to simply change the collission box horizontally when the opponent is lying on the floor, via setSize and perhaps an offset is needed. I haven't coded the kick functionality yet so I can't really tell. I'll keep you guys posted.
  7. Hi everyone, I was able to figure it out, I switched the physics to arcade physics. It has a better overlap detection overall and it's not as jittery as the p2 physics (I feel p2 physics still needs a lot of work to have it on par as the other physics systems in this engine in terms of collission, then again, I am a newb and still learning) This is my simple enemyAI method var isColliding = game.physics.arcade.collide(playerKen, enemyBison, hitEnemy, null, this); if (!(isColliding)){ bisonWalkingForward(); console.log('walking forward'); } else { bisonLightPunch(); } the collide method returns true if the size of the hitbox is collided rather than the size of the sprite, which is good. Doing a punching battle with the AI
  8. From doing a bit of reading, I guess Arcade Physics is the best way?
  9. Hi everyone, I am new to Phaser framework and it's great! I have made a lot of progress on this Street Fighter game I am doing. A little background of my problem: I have my code set up that when I press W (Medium Punch), I increase the width of the sprite by via setRectangle playerKen.body.setRectangle(70, 80, -18); once I expanded the hitbox , I play the sprite, then set the width back to its original size once the animation has finished playing: kenAnimation ='standingMediumPunch', 10, false).onComplete.add(function () { //reset the graphics back playerKen.body.setRectangle(35, 80, -18); playerKen.body.setCollisionGroup(kenCollisionGroup); playerKen.body.collides(mBisonCollisionGroup, hitEnemy, this); kenAttacking = false; playerKen.body.velocity.x = 0;'standing', 7, true); playerKen.body.static = false; //console.log('punching'); }, this); I have also programmed the AI too, won't get into that. But my issue is the overlapping hitboxes. See the attached photo... When a situation like this occurs when I am punching and the AI is punching as well, the health of the player and the AI does not decrease. I looked into but the getBounds() method only gets the width of the sprite, not the hitbox. How can I see whether the two hitboxes have intersected? By the way, I am using p2 physics. Thanks a bunch!