Need Help Distinguishing Between Character Front and Back

Talk about making games.

Need Help Distinguishing Between Character Front and Back

Postby Archaeaologist » Thu Mar 15, 2012 1:25 pm

Hello Everyone,

I'm rather new to this whole game development thing, and I was wondering if you guys could help me in what will undoubtedly be the first of many questions. My problem is this: I'm making a top-down Legend of Zelda kind of game, and I need to distinguish the front and back of enemies and my character (for shield placement or detection or whatever). Now, I know how to change their animation so it's related to the angle of their movement, and I'm sure I could extrapolate on that so that if their at some angle, their state has changed (though I do wonder if there are other ways to do it so that they could, say, walk backwards), but I don't know how to determine that they are behind the main character or the main character is behind them.

One way I can think to do it would be with wire-frame actors that have the character actor as their parent. If a character is in a certain wire-frame while the other character faces a direction, then the state of the first character is seen as behind the second character, and they'll behave accordingly. My main problem there, besides the volumes of coding I'd likely have to do, is I'd have to create many, many wire-frame actors to accommodate all the characters. Is there an easier way? Could I somehow distinguish between one part of a sprite and another?

Any help for this problem would be greatly appreciated.

Cheers.
Archaeaologist
 
Posts: 2
Joined: Wed Mar 14, 2012 3:28 pm
Score: 0 Give a positive score

Re: Need Help Distinguishing Between Character Front and Bac

Postby jimmynewguy » Thu Mar 15, 2012 4:44 pm

Something like this? Just check x/y values and the direction the enemy is facing.

For enemies being behind the player you could store their x, y, dir in a 2d array and loop through them. Wasn't sure if you needed that though. (It didn't make sense since the actually player would still see the enemies)

wasd will face the enemy, arrow keys will move the player, if the debug is red the player is behind the enemy.

And if this doesn't help, or isn't what you meant let me know
Attachments
Face.zip
(107.11 KiB) Downloaded 92 times
Working on a probably too ambitious project! Wild-west-adventure-RPG-shooter-thing.
User avatar
jimmynewguy
 
Posts: 1137
Joined: Sat Mar 31, 2007 6:27 pm
Score: 89 Give a positive score

Re: Need Help Distinguishing Between Character Front and Bac

Postby Archaeaologist » Thu Mar 15, 2012 5:47 pm

That does help, actually. If I understand correctly, the code is first checking the direction the enemy is facing (which is based on animpos) and then checks the relative position of the player to the enemy. I'll have to play around with that concept and see how far I can adapt it.

Thank you very much.
Archaeaologist
 
Posts: 2
Joined: Wed Mar 14, 2012 3:28 pm
Score: 0 Give a positive score

Re: Need Help Distinguishing Between Character Front and Bac

Postby skydereign » Thu Mar 15, 2012 5:53 pm

Archaeaologist wrote:Now, I know how to change their animation so it's related to the angle of their movement, and I'm sure I could extrapolate on that so that if their at some angle, their state has changed (though I do wonder if there are other ways to do it so that they could, say, walk backwards), but I don't know how to determine that they are behind the main character or the main character is behind them.

For this I'd recommend setting a variable to hold the direction the player is moving in. Assuming you are going to add a few more animations, the use of animpos is going to get very annoying to deal with. With the variable, it is always set in the direction the player is facing, that way you can then compare with the position of the enemy, relative to the position and direction of the player.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest