The Program of the Game
The code initializes all the variables it needs so that it can be accessed and modified these objects.
Using the Enter key to input numbers.
Validate the input numbers:
Prevents players from entering anything except numbers.
Moving the game objects:
The render( ) function moves all the game’s object based on the game information:
Figuring out if the alien has been hit:
When the player clicks the button, the playGame( ) function is called.
The playGame function finds the alien’s next new position. It gives a random X position between 0 and 280 and then and 30 to its current Y position.If the gameWon variable is true, then the player has won and the appropriate message is displayed. But if gameWon is false, the function tells the player that he or she has lost.
Files to Download
Alien Attack Font