Unit 3: Student's Game Design

A student of mine is working on designing his own game. He has a sprite following another sprite. When you let the player stop for a bit, “enemy” will catch up and stop as well, however it vibrates on top of the player. do you know a way to stop the vibration of “enemy1”?

Any help would be appreciated. Thank you!


Clever game. My trigonometry is a little outdated, but the vibrating is most likely a function of line 101 where the velocity of the enemy is determined. The cosine of the angle that is being calculated doesn’t ever appear to reach that point to make that calculation = 0 and stop the velocity.

He may want to find a way to add a conditional to stop the velocity if the characters are touching (or something like that). At least that’s my best suggestion. Sometimes when you do the math in such a precise manner, you also have to add a condition to catch the cases that cause glitches like this.

Anyone else have a better idea?