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.

DarkBASIC Professional Discussion / Collision for two seperate fighters

Author
Message
FiddleSticks
8
Years of Service
User Offline
Joined: 25th Nov 2015
Location:
Posted: 28th Nov 2015 02:34
I need help with the collision for my game. It is a fighting game so it naturally has health involved. However the problem is that while I implemented the collision and it works as coded, I need help getting it to do individual health.

The health collision takes -10 from both the players everytime they hit one another. How do I make the health collision to each individual player. The player who hits the other first will reduce the health of the other player.



Scorpyo
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 29th Nov 2015 09:00
These two if statements are totally equivalent:

Therefore they both operate at the same time (one after the other).

You have to link the discrimination between the two health values depending on some action/reaction of the specific player.

This is an attempt to the logic involved ( code may/will not run properly because it's too generic still):



Not sure what "gosub wattack" does, tho.



Suicidal Sledder
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 29th Nov 2015 22:15 Edited at: 29th Nov 2015 22:17
If I were you, I would calculate the "combat" aspect (i.e. hitting, blocking, taking/dealing damage) completely irrespective of sprite collision or sprite frame. I would have a set of states and then change the sprite frames based on the states. For example state 1 could be idle, state 2 could be block, state 3 = walk left, state 4 = walk right, state 5 = punch, etc.... this would make it simpler to do checks if actions are available or what the results of the actions would be.

For example,

p1_state = 2
p2_state = 5

if they are colliding then p2 is punching p1, but p1 is blocking, so deal no damage, deal small damage, reduce stamina, whatever the design of your game dictates.

if they are both punching and colliding then you could reduce damage from each player, or if you are deadset on whoever hits first gets the damage, you could have a state called just_got_hit. In this state the player could recoil from the blow and be unable to hit back, that way if p1 and p2 go to hit each other at ALMOST the exact same time, whoever was quicker would deal damage and the others attack would be nullified.

This would also make animating much easier. create a UDT with frame numbers and state numbers like so:


Then all you need to do is create a animation handler that updates animations ever so often (30 FPS is every 33ms) and cycle thru animation frames. Once you hit the last frame then loop back to the first frame, IF it is a looping animation. example idle would be looping, walking would be looping, blocking would be looping, but attacks, death, etc wouldnt be looping, you would want to return to the idle state after these animations. you could define a part of your UDT using "looping as boolean". In your animation handler if it is a looping animation you start back at the start frame. if it is not a looping animation then set state back to idle.

Thats how I would do it. Sorry my thoughts were kind of all over the place. This system also works quite well handling 3D animation sets. I would give credit where credit is due but I do not recall who introduced this system to me. Most likely Green Gandolf or BatVink.

edited spelling
Sadly, programming is only a hobby for me right now. As it turns out, driving a 70 ton, 7 million dollar Abrams tank requires less qualification than pecking away at a keyboard. Who\'da thunk it?

Login to post a reply

Server time is: 2024-04-20 10:55:33
Your offset time is: 2024-04-20 10:55:33