Computer Programming I

Ocean by Laura

At left you see one of many beautiful drawings that Laura C. programmed as part of her mage game. It is a text-based role playing game, but in between each level you get to see scenes from the mountains, a forest, a canyon, a desert, and more. If you are familiar with role playing games, you know that some of the game's outcome is based on chance. Here is a section of Laura's code that determines how much damage the enemy will suffer when you attack:

damage = INT(RND * 41 + 50)
enemyHP = enemyHP - damage
	

In this situation, the damage to the enemy was somewhere between 50 and 90. Each time you play, that damage could come out differently, depending on the random number that is chosen by the RND function. The game designer has to decide if that's an appropriate numerical range for the amount of damage. We want the game to be a challenge for the player, but it shouldn't be impossible to win. Suppose the designer wanted the damage to be somewhere between 60 and 100. Can you figure out how to change the code to make the range be 60 to 100 instead of 50 to 90?

You can download the file for this game and play it yourself, if you like. It's not perfect but it's still fun to play. It runs only on a PC, unfortunately. But don't worry-- in Computer Programming III and Computer Programming IV, students learn to make programs that run on any platform.