Head First TVN now produces game shows

It's more than just sports at Head First TVN, as the station has entered the lucrative world of live game show broadcasting. Their flagship show, Who Wants to Win a Swivel Chair, is attracting viewing figures in the millions... not bad for a station that operates on a shoestring budget.

You've been approached by their stressed-out (but incredibly smooth) game show host to help with a program he needs. TVN was so impressed with your work last time that they are offering two free, front-row tickets to the Grand Final as payment for your work.

You've had a few conversations with the host and determined a list of program requirements:

1. The host wants to be prompted after a question has been asked to press either 1 for a correct answer or 2 for a wrong answer.

2. Based on the key pressed, an appropriate sound effect needs to play.

3. The program needs to remember how many answers were correct and how many were wrong.

4. The host will end the quiz by pressing 0. Then the program will display the number of right, wrong, and asked questions.

Let's flesh out what's required in pseudo-code.

TVN's show host-

TVN's show host-

Use the space provided below to write the pseudo-code for the program you've been asked to write for TVN:

pseudo-tode here-

game show pseudo-code

You were asked to use the space provided below to write the pseudo-code for the program you've been asked to write for TVN:

(number_asked = 0 You need to remember how j many questions were asked, M number_correct = 0 how many were correct, i and how many were wrong. number_wr┬░ng = 0

ask the host to press 1 for correct, 2 for incorrect, or 0 to end

Begin by asking the

while the host response is not 0 if host response was 1 'add 1 to number asked

This Will run ** ^dS^V ^TV add 1 to number correct was answered CORRECTLY A -

play a sound effect if host response was 2 -acid 1 to number asked*

This will run the add 1 to number wrong was answered - ^yxY J

play a sound effect

Ask the host at the end of each loop what he wants to do next-

finally, display the scores.

Don't worry if your answer doesn't look EXACTLY like this. There are a few ways of writing the Code.

finally, display the scores.

ask the host to press 1 for correct, 2 for incorrect, or 0 to end display the values of number_asked, number_correct and number_wrong on screen

Frank: I think sound is going to be a problem. Jim: Sounds easy to me... Joe & Frank: <groan>.

Jim: Sorry, couldn't resist that one. Seriously, though, how hard can it be to play a sound from a program?

Joe: Playing a sound is not the problem; getting it to work on multiple platforms can be. For instance, what works on Windows might not work on Mac OS X or Linux.

Jim: That's not a problem. I only use Windows, so I'll be OK.

Frank: Good for you, but the rest of us want to play, too, and we don't want to have to... um... eh... downgrade to Windows.

Jim: Typical: have a swipe at Windows when something doesn't work on your non-Windows computer.

Joe: Cool it, guys. We need to stop bickering and come up with a solution that lets us play sounds and works on Windows, Mac OS X, and Linux. And it has to work with Python, too.

Jim: You mean Python doesn't support sound as standard?!?

Frank: No, not really. In fact, very few programming languages support sound in a cross-platform way. This isn't just a Python problem.

Jim: So... we're outta luck then. Does that mean it's time to go home?

Joe: Not so fast, Jim! I'm pretty sure pygame can help here.

Jim: So... I can't go home early, but I can play games?

Frank: Seriously, Jim, I think Joe's right. We can use pygame to play our sounds in Python.

Jim: And it'll work on Windows, Mac OS X, and Linux?

Joe: Yes, I'm pretty sure it will. Granted, pygame's a set of gaming libraries for Python, but all we need to use is the bit that handles playing sounds.

Jim: Sounds great. I can't wait to see it in action. Frank: Didn't you mean "hear it in action"? Jim & Joe: <groan>.

Frank Joe

Frank Joe get in the pygame

Was this article helpful?

0 0

Post a comment