Beat em up Tutorial?
Blitz3D Forums/Blitz3D Beginners Area/Beat em up Tutorial?
| ||
Is there a Beat em up Tutorial for Blitz? There is one things I dont like is collisions where you have a man who punch. so you have work out the collisions for his arms such as x length and y for width of his arms I have never made beat em up before but for collisions what I said above was my thinking how to put it in. |
| ||
Well, i think the best way would be to parent pivots to his hands, feet, legs etc and make up the collision zones with these. |
| ||
I think 2D beat em up is easier than 3D beat em up I guess...is it? |
| ||
For me, 3D anything is easier than 2D. |
| ||
It's not really that difficult if you think about the logic first. Just make it that if an enemy is at a particular distance (both horizontally and vertically) from the player when the player punches, then the enemy gets punched (there are some other elements you need to worry about, like if the player is facing the enemy, etc.) Be aware that beat 'em ups are viewed in a certain "angle", you know? the vertical tolerance will be the "three-dimensionality" of your 2D beat 'em up, meaning that it will be the threshold between the punch hitting the enemy or not. If you place a tolerance of zero, that means that the enemy has to be in the exact plane of the player to be able to be hit (which would make your game very difficult). If you add a little tolerance, the enemy might be a bit higher or lower. To understand what a vertical distance is: The red arrow indicates the horizontal "plane" where the player is; The other two are the enemies planes. The vertical distance is the difference between the enemy's plane and the player's, it's nothing but the Y coordinate difference (and the horizontal distance follows the same logic but horizontally). You'd need to look up on your animation frames to see to which extent does the arm\leg of the player stretches out to be able to set up a nice horizontal distance based on that. You'd have to test and tweak a lot to see which horizontal and vertical distances make your game both fun and challenging (and realistic too, you don't want an enemy getting punched while being 5 meters away from the player). |
| ||
do you think I should make the character bigger?![]() |
| ||
I have made the character bigger and also put Enemys in too. When the Enemys get close to the player then the enemys punch the player but it not quite right. I need to fixed it.....Is anyone going help me to progress the scrolling beat em up? |
| ||
How can I fixed it by making enemys target the player more ACCURATE when come to punching the player?![]() I can send the code with graphics for you to test it if you are interesting in it |
| ||
make sure the player xPos and enemy xPos are within a certain distance aswell as both yPos. ie. if distance(xPos1,xPos2) < 20 if distance(yPos1,yPos2) < 5 'enemy throws punch endif endif you'd need a formula to find the difference between 2 numbers. function distance(num1,num2) if num1 >= num2 return (num1 - num2) else return (num2 - num1) endif endfunction not tested just a quick thought i typed in. |
| ||
thank you very much KingNothing |
| ||
At the moments...I am working on just One Enemys before I put some different Enemys in Here the part of the code on what I have done Function Enemy_Movement() Select State Case 1 DrawImage Enemy1,AI_X,AI_Y,1 Case 2 DrawImage Enemy1_Punch,AI_X,AI_Y End Select ; WORKING OUT X POSITION ; IF ENEMYS IS FAR WAY FROM THE PLAYER ; THEN GET ENEMYS CLOSE TO PLAYER AND PUNCH HIM! - (MOVE LEFT) If AI_X>GUY_X Then AI_X=AI_X-1 ; SAME JOB BUT MOVE RIGHT If AI_X<GUY_X Then AI_X=AI_X+1 ; WORKING OUT Y POSITION If AI_Y>GUY_Y Then AI_Y=AI_Y-1 If AI_Y<GUY_Y Then AI_Y=AI_Y+1 ; WORKING OUT DISTANCE BETWEEN PLAYER AND ENEMYS If distance(GUY_X,AI_X) < 20 If distance(GUY_Y,AI_Y) < 5 ;enemy throws punch state=2 EndIf Else state=1 EndIf End Function Function distance(num1,num2) If num1 >= num2 Return (num1 - num2) Else Return (num2 - num1) EndIf End Function |
| ||
What is the best way to work out for Collisions if enemys arm meet the player face? what the code would be like to work out the collisions? |
| ||
i haven't used b3d for about 2 years or so, so i'm very rusty with it. when your enemy's animation frame is whatever the punch frame is do a call to 'ImagesCollide (image1,x1,y1,frame1,image2,x2,y2,frame2)' if ex. image1 (the enemy) collides with image2 (the player) then the punch hit. as far as hitting the face you'd have to make sure the enemy's yPos was in a range so the enemy's fist was within the boundries of the players face. ie if enemyY > (playerY - 5) and enemyY < (playerY + 5) 'face hit endif also the 20 and 5 in my first post was just an example you might have to play with those numbers a bit to get it right. |
| ||
WOW What a Magic man you are :) Thank you very much KingNothing I will post the progress of the screenshot and when enemys punch is right to player face! Nice! BEFORE ![]() AFTER ( NOW IT Been Fixed but still need Tweaking to make sure Enemy touch player face) ![]() The Pink Glow is been FIXED and now no longer there :) |
| ||
Now the next step must be hardest one I have face so far....how do I get collisions for Feet when the feet been kick either lower and higher on to the face.... is the code nearly the same as punch? |
| ||
for the kick its exactly the same idea except with the kick frame(s). if you have say a high kick frame then range it from top of head to the bottom of the head. if you have a mid kick frame then range it from bottom of head to the crotch. if you have a low kick frame range it from crotch to players yPos(assuming yPos is the bottom of the image and not the middle) if yPos is the middle of the image then just add half the image height to it. |
| ||
thank you king nothings :) I have problem...if Enemys decide to punch player instead of kick to player. I should Used Random code like this Function Enemy_Movement() Select State Case 1 DrawImage Enemy1,AI_X,AI_Y,1 Case 2 DrawImage Enemy1a,AI_X,AI_Y End Select ; ============================================================================================= ; WORKING OUT DISTANCE BETWEEN PLAYER AND ENEMYS If distance(GUY_X,AI_X) < 40 If distance(GUY_Y,AI_Y) < 5 ; THE PROBLEM....I guess the Enemys cant decide which is which :( n=Rand(2) If n=1 ;enemy throws punch to player face If AI_Y > (GUY_Y - 5) And AI_Y < (GUY_Y + 5) Then DrawImage Enemy1_Punch,AI_X,AI_Y EndIf If n=2 ; Enemy kick to the player face If AI_Y > (GUY_Y - 5) And AI_Y < (GUY_Y + 5) Then DrawImage Enemy1_LowKick,AI_X,AI_Y,1 EndIf ;============================================================ EndIf Else ; WORKING OUT X POSITION ; IF ENEMYS IS FAR WAY FROM THE PLAYER ; THEN GET ENEMYS CLOSE TO PLAYER AND PUNCH HIM! - (MOVE LEFT) If AI_X>GUY_X Then AI_X=AI_X-1:State=1 ; SAME JOB BUT MOVE RIGHT If AI_X<GUY_X Then AI_X=AI_X+1:State=2 ; WORKING OUT Y POSITION If AI_Y>GUY_Y Then AI_Y=AI_Y-1 If AI_Y<GUY_Y Then AI_Y=AI_Y+1 EndIf ; MAKE SURE GUY AND ENEMYS NOT TO GO OFF PLAYING AREA! If GUY_Y >345 Then GUY_Y=345 End Function Function distance(num1,num2) If num1 >= num2 Return (num1 - num2) Else Return (num2 - num1) EndIf End Function |
| ||
; Enemy kick to the player face If AI_X > (GUY_X + 25) And AI_Y < (GUY_Y + 25) Then DrawImage Enemy1_LowKick,AI_X,AI_Y I have change the code for kicking it seem to work in the screenshot blow ![]() My next step is to have Enemys making Decision when to kick or when to punch. |
| ||
looks like its coming along alright, but perhaps before you get too far into it, you should concider putting the enemies into a 'Type'. would be much easier to handle in the long run. |
| ||
Yes I will put enemys type in when I have about 2 or 3 enemys on the screen but how can I make Enemys making Decision when to kick or when to punch as I was thinking that if enemys is quite far way from the player then the enemys will used the kick and if enemys is close to the player then the enemys will used the punch. What do you think? |
| ||
Decision = Rand(1,3) Select Decsision Case 1 ;Punch Case 2 ;Kick Case 3 ;Block End Select |
| ||
that is nice and I like that. thank you. |
| ||
Whatever you do, you should make it like Double Dragon 1 and 2 and have no continues. That's what made the old games so much more fun. When you lose, you lose everything, making the last levels really scary. |
| ||
I will take note of it but I can only do what is front of me knowing what I can program and what I cant program on as I am no expert programmer! :) Yes I have play Double Dragon 1 and 2 before and it was great game. |
| ||
I think there should be saves, at least every few levels like in Super Mario World. I've played games where you have to start over from the beginning after you die and it makes me mad and I end up not playing it anymore, so if I were you I would look into game saves. |
| ||
just to add onto what GIA_Green_Fire_ postedDecision = Rand(1,10) Select Decsision Case 1 if ;within punching distance ;Punch else return endif Case 2 if ;within kicking distance ;Kick else return endif Case 3 if ;player is within attacking distance and is attacking ;Block else return endif Default ;nothing happens(just to add a bit more randomness) End Select case 3 needs a bit of thought to actually get working properly but this is still one possible start. another way could be with if statements Decision = Rand(1,10) if Decision <= 5 ;do actions if ;player not attacking if ;within punching distance ;Punch return else return endif if ;within kicking distance ;Kick return else return endif if ;player is within attacking distance and is attacking ;Block return else return endif else return endif else ;do nothing endif just a thought. |
| ||
that is interesting coding example there and it is worth learning from it. GIA_Green_Fire_: I not sure about the save game but I just take step by step on working with the enemys first before I go any futher! |
| ||
i just noticed a booboo in my example above.if ;player is within attacking distance and is attacking ;Block return else return endif should be moved to Decision = Rand(1,10) if Decision <= 5 ;do actions if ;player not attacking . . . else if ;player is within attacking distance and is attacking ;Block return else return endif endif else ;do nothing endif |
| ||
Usually I would just call the function, and do the checking in that. Or you could check the distance before anything else.If distance <= 3 Decision = Rand(1,10) Select Decision Case 1 Punch() Case 2 ;Kick() Default ;Block() End Select EndIf |
| ||
Now I am using Enemys Type like this Type Enemy Field Image ; Image Field X,Y ; Enemys Position Hit ; Or Damage Dead ; Dead = 1 mean he is Dead, Dead = 0 mean he is alive End Type What does anyone know think of my type above.... |
| ||
Very Double Dragon ;) |
| ||
Now I am using Enemys Type like thisType Enemy Field Image ; Image Field X,Y ; Enemys Position Hit ; Or Damage Dead ; Dead = 1 mean he is Dead, Dead = 0 mean he is alive End Type What does anyone know think of my type above.... |