Hi. I have made a game and have been trying to move the enemy towards the character.So far, I have gotten the enemy to move towards the player, but never actually meetsthe x and y of the player. Can anyone help?Here is the code:

I have made a game and have been trying to move the enemy towards the character.So far, I have gotten the enemy to move towards the player, but never actually meetsthe x and y of the player. Can anyone help?

1) I dont see how this is successful? The so called enemy is all over the place when you move the character ... not moving towards the player. It is almost by chance that they meet.

5) It would make it a lot easier if you start using classes/functions. And if you do not know how...You should stop pygame and start learning basic programming.

6) i strongly get the feeling that you are over your head, but whatever. Check out:Enemy.pos_towards_player() and Enemy.update() in the code:https://github.com/metulburr/fighter/bl ... fighter.pySeriously...if it looks like gibberish, or unkown python code, your way over your head and should return to basic python coding

As Metul said, as harsh as it may sound, the way you are coding currently just isn't going to get you very far.

Try at the very least to use pygame.Rect in your next program. You shouldn't have one letter global variables like x, y, ex, and ey.

Also I would like to know if you understand basic triangle geometry. Currently you are arbitrarily changing the enemies speed based on the x and y of the player, but there isn't much logic behind it. If you don't know the Pythagorean theorem, you will need to look it up; and if you don't understand sine, cosine, and tangent you likely have a bit of math related reading ahead of you.

Also, I STRONGLY advise you to go through a basic, non game-related, function and class tutorial.Give these two interactive tutorials at Codecademy a try. They are pretty light weight.FunctionsClasses

No one wants you to give up, but you have to learn things in the right order. The way you are proceeding now is going to create unmaintainable, completely undebuggable code.-Mek