You are on page 1of 13

COMPUTER PROGRAMMING 1

Session 10: More Exercises (Exam 2)

Iván Amaya
CONTENTS
 ROCK-PAPER-SCISSORS-LIZARD-SPOCK (RPSLS)

 MOVING CAR

 BATTLE IT OUT!

 FURTHER READING

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 2


http://vignette4.wikia.nocookie.net/uncyclopedia/images/c/c3/Rpsls.jpg/revision/latest?cb=20110210144943
RPSLS
Improved version of Rock-Paper-Scissors

It is very simple:
Scissors cuts paper
Paper covers rock
Rock crushes lizard
Lizard poisons Spock
Spock smashes scissors
Scissors decapitates lizard
Lizard eats paper
Paper disproves Spock
Spock vaporizes rock

And as it always has been

Rock crushes scissors


COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 3
RPSLS
Improved version of Rock-Paper-Scissors

It is very simple:
Scissors cuts paper
Paper covers rock
Rock crushes lizard
Lizard poisons Spock Lose
Spock smashes scissors
Scissors decapitates lizard Win
Lizard eats paper
Paper disproves Spock
Spock vaporizes rock

And as it always has been

Rock crushes scissors


COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 4
RPSLS

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 5


MOVING CAR
Simulate moving car:

Read center and radius (wheel 1)

Read chassis length

Print simulation (front / back)

Start distance measured from center dist_b

whl_r dist_f
cha_l

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 6


MOVING CAR

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 7


BATTLE IT OUT !!!
Simulate battle: Determine winner (beware life < 0)

Three elements: Fire, Water, Leaf

Two actions: Attack, Defend

Defending doubles defense value


http://thumbs.dreamstime.com/x/fire-leaf-water-4861206.jpg

Damage = ATK – DEF


P1_HP / MAX_HP P2_HP / MAX_HP
Print actions and effectiveness
Action?
Refresh screen 1. Attack!
2. Defend

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 8


BATTLE IT OUT !!!

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 9


BATTLE IT OUT !!!

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 10


BATTLE IT OUT !!!

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 11


BATTLE IT OUT !!!

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 12


FURTHER READING
Look up and read information regarding:

Functions (definition and usage)

COMPUTER PROGRAMMING – SESSION 10 IVÁN MAURICIO AMAYA CONTRERAS 13

You might also like