Beat 'Em Up Attribute Collision? Fighting An Enemy Help!?!?!

KenKKenK Member Posts: 4

Alright so I've been searching for a while and either I can't use the internet, or there isn't much about this online (I'm hoping the latter).
So I'm making a simple Beat 'Em Up game and It's pretty much a character in the middle of an area that has enemies coming at it from all sides and you have to fight to survive.

So my question is, how do I get the character to damage/destroy/kill an enemy, if the character is facing left and the enemy is on the left?

So far, I have only been able to get the enemy to die if there is a collision and when the "punch" button is pressed, but this way, it doesn't matter where the character is facing the enemy will be die.
I have tried setting an attribute called 'PlayerFront' so that when the left button is pressed the 'PlayerFront' attribute is set to the left side of the player (I used the expression: self.position.x-(self.width/2)+5 which is obviously different for each direction the player faces) but haven't been able to get it to collide with the attribute.

Is there a better way of doing this?

Please help!

Thanks,

Ken

Comments

  • colandercolander Member Posts: 1,610

    Try a three game level attribute and use Constrain to record the hero's rotation position, position.x and position.y and use these in you enemy rules to determine the relationship between the two and the outcome. For example if your enemy is coming from the left create a rule for your enemy self.position.x < game.heroPosX and self.position.y = game.heroPosY and game.heroRotation = 270 then blah blah.

    If you only have four or less directions this won't be too complex but if you have your enemies coming from all directions you will need to use a range for game.heroRotation and it will get more complex requiring some trial and error.

    Use the random() function in a rule for damage i.e. if actor enemy collides with actor hero then self.damage = self.damage + random(1,10) and self.damage = 10 destroy actor.

    There is probably a better way to do this but off the top of my head that's the best I can come up with.

  • KenKKenK Member Posts: 4

    Alright, I'm a bit of a noob when it comes to this, but you're pretty much saying:
    -Create hero.PosY, hero.PosX & heroRotation
    -Set the heroRotation to be 0, 90, 180 & 270 to match Right, Up, Left & Down when they're pressed
    ...then I don't really know...

    I'll probably do a mock-up to illustrate what I'm trying to achieve, but i'll be having it so you'll be able to walk around them and attack from any of their sides. So I don't know if I don't understand, haha a bit tired at the moment.

  • colandercolander Member Posts: 1,610

    @KenK This is what I mean see attached file. Use the enemy self attributes relative to the hero attributes to write your rules for what happens next.

    No one will write your project for you unless you pay them. With patience, time and study you will be able to do most of it yourself and when you get stuck post your questions in the forums. A great resource is the GS Cookbook on youtube http://www.youtube.com/user/GameSaladCookbook#p/u/0/A_99wDneVeg and FBS's videos also on youtube

Sign In or Register to comment.