There are boundary conditions for our hero: enemy collision, left edge collision & right collision. Can you program what should happen in each of these cases?
When the hero collides with the enemy, the hero should disappear an the game should be over. So we'll add an If Statement and add the "touching Enemy?" as the condition. Then we can grab a "hide" block, "wait .25 seconds" and "stop all" to hide the character briefly and end the game.
When the hero collides with the left edge of the screen, it should bounce and enable the controls to quickly move to the right. What should our X speed be set to when we hit the edge of the screen? A good setting would be zero, that way we don't have to move too quickly in the opposite direction. So to test for the condition we'll add an If statement, and a "touching edge" block. Then head to the Motion tab and grab the "if on edge, bounce" block, then finally get the "set x speed to 0" block from Variables.
We need to make sure that our hero doesn't rotate when it hits the edge of the screen. Head to the right side of the screen to the Sprite Manager and click on the Direction button. Set the rotation style to "do not rotate" on the right.
Add the Two Conditions we built to the forever loop. Any time we build new functionality, we want to test our project to make sure that it is working as intended. Does the game end when the enemy collides with the hero? Does the hero bounce off of the left and right portions of the screen?