Unit 3: Student's Game Design

Hello,
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!

@heath.kelley,

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?

Mike

Hey all, my student is working on a game. He is having an issue with line #53. This is what he said “My game will not work at all and I don’t know what is wrong with it.” Here is the link to his game. Game Lab - Code.org

@kristingarner ,

The problem starts on line 50. He has the draw loop declared, but without the opening {

Then, the closing } is also missing. Not sure how that would have happened (ie. get this far in the game without those). So, something must have happened in text mode to delete them.

Once he adds the opening { and then decides where the draw loop is supposed to end and places the closing } there, it should be back to where he can work on it again.

Mike

Thank you! I was looking for the error for a long time!